【高可用HA】Apache (1) —— Mac下安装Apache Httpd到自定义路径(非/etc/apache2)
Mac下安装Apache Httpd
httpd版本: httpd-2.4.17
参考来源:
Tomcat Clustering - A Step By Step Guide
Apache HTTP Server Version 2.4 - Compiling and Installing
Stackoverflow - configure: error: C compiler cannot create executables
Problems with compiling apache2 on Mac OS X Mountain Lion
安装
Download $ lynx http://httpd.apache.org/download.cgi
Extract $ gzip -d httpd-NN.tar.gz
$ tar xvf httpd-NN.tar
$ cd httpd-NN
Configure $ ./configure --prefix=PREFIX
Compile $ make
Install $ make install
Customize $ vi PREFIX/conf/httpd.conf
Test $ PREFIX/bin/apachectl -k start
运行错误
C compiler cannot create executables
$ sudo ./configure --prefix=/httpd-2.4.17-a
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-apple-darwin14.4.0
checking host system type... x86_64-apple-darwin14.4.0
checking target system type... x86_64-apple-darwin14.4.0
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... yes
setting CC to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc"
setting CPP to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc -E"
setting CFLAGS to " "
setting CPPFLAGS to " -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -DDARWIN_10"
setting LDFLAGS to " "
configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... yes
checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc
checking whether the C compiler works... no
configure: error: in `/Users/Richard/Documents/Dev/servers/cluster/httpd/httpd-2.4.17-a':
configure: error: C compiler cannot create executables
See `config.log' for more details
一个可行的解决办法
依次在Terminal中执行下面三行命令:
$ sudo xcode-select -switch /
.
sudo mkdir -p /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin
.
sudo ln -s /usr/bin/cc /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc
注意上面OSX10.10的版本号与本机操作系统的保持一致,可以在上面错误日志中找到
编译与安装
$ make
.
$ make install
当运行make时,Mac会提示错误
make: command not found
这是因为Mac下默认没有安装make,可以通过打开xcode,preferences -> Downloads -> Components,Command Line Tools安装
(Xcode5.1后不再支持通过此方式安装,需要访问Downloads for Apple Developers选择正确版本安装)
再运行make是,Mac会提示错误
make: *** No targets specified and no makefile found. Stop.
查看之前的./configure 执行的log发现最后执行出错"libpcre not found"
checking whether /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc accepts -g... yes
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc option to accept ISO C89... none needed
checking how to run the C preprocessor... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc -E
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc option to accept ISO C99... none needed
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
pcre的编译安装
$ tar -zxvf pcre-8.10.tar.gz
$ cd pcre-8.10
$ ./configure
$ make
$ make install
注意:此处要安装pcre,pcre2不适用
安装成功之后,在httpd目录下重新运行./configure(配置httpd到自定义目录)
$ ./configure --prefix=/Users/Richard/Documents/Dev/servers/cluster/httpd/node-a
执行结果末尾几行的输出:
config.status: creating support/split-logfile
config.status: creating build/rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
运行
$ make
执行结果末尾几行输出:
/usr/share/apr-1/build-1/libtool --silent --mode=link /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc -o mod_rewrite.la -rpath /Documents/Dev/servers/cluster/httpd/httpd-2.4.17-b/modules -module -avoid-version mod_rewrite.lo
关于make可能也会输出以下信息(可以暂时忽略,稍后再关注此问题)
Building shared: mod_status.la mod_autoindex.la mod_info.la mod_cgid.la
make[4]: Nothing to be done for `local-shared-build'.
Building shared: mod_dav_fs.la
make[4]: Nothing to be done for `local-shared-build'.
Building shared: mod_vhost_alias.la mod_negotiation.la mod_dir.la mod_actions.la mod_speling.la mod_userdir.la mod_alias.la mod_rewrite.la
make[4]: Nothing to be done for `local-shared-build'.
运行(sudo)
$ make install
执行结果末尾几行输出:
Installing man pages and online manual
mkdir /Documents/Dev/servers/cluster/httpd/httpd-2.4.17-b/man
mkdir /Documents/Dev/servers/cluster/httpd/httpd-2.4.17-b/man/man1
mkdir /Documents/Dev/servers/cluster/httpd/httpd-2.4.17-b/man/man8
mkdir /Documents/Dev/servers/cluster/httpd/httpd-2.4.17-b/manual
*查看端口占用
lsof -n -i TCP:80
测试
编译成功后,我们可以在编译的目标目录(此处为./cluster/httpd/node-a)下找到:
$ ls
httpd-2.4.17 node-a
$ cd node-a
$ ls
bin build cgi-bin conf error htdocs icons include logs man manual modules
先使用默认的httpd.conf配置,在/bin下执行
apachectl -k start
运行结果中会提示两个错误AH00558和AH00072
$ apachectl -k start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using weizhedeMacBook-Pro.local. Set the 'ServerName' directive globally to suppress this message
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
修改./cluster/httpd/node-a/conf/httpd.conf,加入配置ServerName
#ServerName www.example.com:80
ServerName localhost
然后再运行相同命令,仍然报相同错误。
如果对etc/apache2/conf/httpd.conf进行修改,再运行相同命令,发现AH00558错误解决,但AH00072错误仍然存在。
此处怀疑命令的权限不够
Apache error – (13)Permission denied: make_sock: could not bind to address,可以通过sudo运行,或者修改Apache的权限。此处暂时使用sudo
$ sudo apachectl -k start
然后AH00072错误没有了,用浏览器尝试访问localhost

此处怀疑当前运行的apachectl命令仍然使用Mac默认路径etc/apache2下的apache
为了验证这个想法,我们查看etc/apache2/conf/httpd.conf文件发现其DocumentRoot为:
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
我们在该路径下(Command+Shift+G),找到文件index.html.en并修改
<html><body><h1>It works! Apache2 Default</h1></body></html>
然后通过浏览器重新访问localhost得到运行结果

问题来了
如何才能运行我们自定义目录下的httpd呢?
因为默认情况下,运行apachectl或者httpd命令会指向系统自带的etc/apache2目录。
如果要运行我们自行安装的./node-a/httpd实例
$ ./bin/httpd -k start
默认情况下命令回去尝试寻找"/Documents/Dev/servers/cluster/httpd/node-a/conf/httpd.conf",而出错(为什么待解)
httpd: Could not open configuration file /Documents/Dev/servers/cluster/httpd/node-a/conf/httpd.conf: No such file or directory
我们用"-f"指定conf文件
$ ./bin/httpd -f /Users/Richard/Documents/Dev/servers/cluster/httpd/node-a/conf/httpd.conf -k start
这时可能会遇到错误
[Tue Dec 08 14:20:58.432961 2015] [core:error] [pid 18447:tid 4381061120] (13)Permission denied: [client ::1:50428] AH00035: access to / denied (filesystem path '/Users/Richard/Documents/Dev') because search permissions are missing on a component of the path
[Tue Dec 08 14:20:58.601201 2015] [core:error] [pid 18447:tid 4381061120] (13)Permission denied: [client ::1:50428] AH00035: access to /favicon.ico denied (filesystem path '/Users/Richard/Documents/Dev') because search permissions are missing on a component of the path, referer: http://localhost:81/
可以通过Httpd Wiki上的说明,
- AH00132: file permissions deny server access
- AH00035: access denied because search permissions are missing on a component of the path
查看"./node-a/htdocs/index.html"的授权
ls -l index.html
如果需要可以通过以下命令修正
chmod 644 index.html
最后我们修改"./node-a/htdocs/index.html"的内容
<html><body><h1>It works! Node-a</h1></body></html>
然后通过浏览器访问localhost:81

这样一个自定义路径的httpd实例就安装测试成功了
【高可用HA】Apache (1) —— Mac下安装Apache Httpd到自定义路径(非/etc/apache2)的更多相关文章
- 【高可用HA】Apache (4) —— Mac下配置Apache Httpd负载均衡(Load Balancer)之mod_jk
Mac下配置Apache Httpd负载均衡(Load Balancer)之mod_jk httpd版本: httpd-2.4.17 jk版本: tomcat-connectors-1.2.41 参考 ...
- 【高可用HA】Apache (3) —— Mac下配置Apache Httpd负载均衡(Load Balancer)之mod_proxy
Mac下配置Apache Httpd负载均衡(Load Balancer)之mod_proxy httpd版本: httpd-2.4.17 参考来源: Apache (1) -- Mac下安装Apac ...
- 【高可用HA】Apache (2) —— Mac下安装多个Apache Tomcat实例
Mac 下安装多个Apache Tomcat实例 tomcat版本:tomcat-8.0.29 参考来源: Installing Tomcat 7.0.x on OS X 在mac系统安装Apache ...
- mac下安装apache tomcat
目录 一. 默认版: 二. 自定义下载配置版: ———————————————————————正文—————————————————————————— 一. 默认版: ##一.mac 自带了apach ...
- mac下安装apache+php+mysql
运行“sudo apachectl start”,再输入帐号密码,这样Apache就运行了. 运行“sudo apachectl -v”,你会看到Mac OS X 10.6.3中的Apache版本号: ...
- Mac下安装Apache
没错,这一篇又是因为头头给我安排的任务得出来的总结. 本身Mac是有自带的Apache,但是对并发量有限制,这个可以在系统的配置参数里面看,所以本人决定重新安装一个,来,请按照下面的流程来走: 一.下 ...
- 【高可用HA】Nginx (1) —— Mac下配置Nginx Http负载均衡(Load Balancer)之101实例
[高可用HA]Nginx (1) -- Mac下配置Nginx Http负载均衡(Load Balancer)之101实例 nginx版本: nginx-1.9.8 参考来源: nginx.org [ ...
- Mac下配置Apache Httpd的Https/SSL
Mac下配置Apache Httpd的Https/SSL httpd版本: httpd-2.4.17 jdk版本: jdk1.8.0_65 参考来源: Mac下安装Apache Httpd Mac O ...
- Rancher安装多节点高可用(HA)
Rancher版本:Rancher v1.0.1 基本配置需求 多节点的HA配置请参照单节点需求 节点需要开放的端口 全局访问:TCP 端口22,80,443,18080(可选:用于在集群启动前 查看 ...
随机推荐
- 关于frameset中指定区域回退的实现
指定区域(Frame)的回退,网上大都写的是用 window.parent.window.mainFrame.rightFrame.history.back();来进行回退,但是我这边就是不行,一直 ...
- MySQL线上执行大事务或锁表操作
前提 在线执行一些大事务或锁表操作(给某个核心级表加一列或者执行修改操作),此时不但主库从库要长时间锁表,主从延迟也会变大.未避免大事务sql对整个集群产生影响,,我们希望一条SQL语句只在Maste ...
- JQuery识别键盘操作 & 键盘快捷键
前几天写的那个项目登陆页是直接点击but登陆的,后来做完了之后不断的测试的时候就发现蛋疼之处了 每次在键盘上输入一长串密码之后,还得抬起手拿鼠标点一下确认登陆 直接就搜了一下,看了一下书 = = 其实 ...
- WPF Event 在 Command 中的应用初级篇,支持所有Event 展示松耦合设计的全部代码 - 解决TextBoxBase.TextChanged或者TextBox.TextChanged等类似事件绑定问题。
做过WPF开发的人,都知道做MVVM架构,最麻烦的是Event的绑定,因为Event是不能被绑定的,同时现有的条件下,命令是无法替代Event.而在开发过程中无法避免Event事件,这样MVVM的架构 ...
- 图片模糊度判断程序(C++、opencv)
//#include<opencv2\opencv.hpp> //using namespace cv; #include <opencv2/core/core.hpp> #i ...
- Go语言的类型转化
Go语言要求不同的类型之间必须做显示的转换.转化分为类型转换和接口转化. 类型转换的思路是: X类型需要转换为Y类型,语法是T(x). 如果对于某些地方的优先级拿不准可以自己加()约束,变成(T)(X ...
- EF6 在原有数据库中使用 CodeFirst 总复习(三、重建迁移)
本来原来学的时候,挺顺利的,没想到再次使用,还是遇到很多问题,导致更新失败,所以,只能重建迁移,免得看着乱乱的. 一.删除迁移,将数据恢复到(一)结束状态 1.删除文件夹 2.删除表 3.删除列 4. ...
- asp.net mvc 错误路由默认配置
问题描述:默认情况下mvc已经将路由参数设置配置好了,这里就不在讲解,请到园子搜索,有很多这方面相关的文章.这里讲述的是,一个MVC项目中,我们输入一个错误的URL,或者根本不存在的URL,如:htt ...
- 17.Quartus 怎么回读CPLD里面的东西
可以使用Quartus® II Programmer的“Examine”特性回读编程目标文件(.POF)是CPLD不是FPGA 先用auto检测加没加加密位,然后执行ex,然后save,Examine ...
- 状压DP
今天稍微看了下状压DP,大概就是这样子的,最主要的就是位运算, i and (1<<k)=0 意味着i状态下没有 k : i and (1<<k)>0 意味着i状态下有 ...