问题1:apr not found
解决:
1.解压
tar -zxf apr-1.4.5.tar.gz
2.配置
cd apr-1.4.5
./configure --prefix=/usr/local/apr
3.编译
make
4.安装
make install
问题2:APR-util not found
1.解压
tar -zxf apr-util-1.3.9.tar.gz
2.配置
cd apr-util-1.3.9/
./configure --prefix=/usr/local/apr-util
--with-apr=/usr/local/apr/bin/apr-1-config
3.编译
make
4.安装
make install
问题3:pcre-config for libpcrenot found
1.解压
tar -zxf pcre-8.31.tar.gz
2.配置
yum install gcc gcc-c++ gcc-g77
./configure --prefix=/usr/local/pcre
3.编译
make
4.安装
make install
注意:
CentOS7默认已经安装了Apache Httpd,端口80
启动:service httpdstart
1.解压
tar -zxf httpd-2.4.23.tar.gz
解压
2.配置(需要安装apr、apr-util和pcre并指定参数)
./configure --prefix=/usr/local/apache-httpd
--with-apr=/usr/local/apr
--with-apr-util=/usr/local/apr-util
--with-pcre=/usr/local/pcre
3.编译
make
4.安装
make install
基本配置
注意:修改/usr/local/apache-httped/conf/httpd.conf配置文件时,注意权限问题
1.修改端口
Listen 80
2.管理员邮箱
ServerAdmin [email protected]
3.ServerName
ServerName 127.0.0.1
4.修改服务端口转发
ProxyRequests on
ProxyPreserveHost On
ProxyPass /qt-front http://127.0.0.1:8080/qt-front
ProxyPassReverse /qt-front http://127.0.0.1:8080/qt-front
ProxyPass /qt-back http://127.0.0.1:8080/qt-back
ProxyPassReverse /qt-back http://127.0.0.1:8080/qt-back
ProxyPass /qt-front_upload http://127.0.0.1:8080/qt-front_upload
ProxyPassReverse /qt-front_upload http://127.0.0.1:8080/qt-front_upload
ProxyPass / http://127.0.0.1:8080/qt-front
ProxyPassReverse / http://127.0.0.1:8080/qt-front
ProxyPass / ajp://127.0.0.1:9009/qt-front
报错:Invalid command 'ProxyRequests', perhaps misspelled or defined by a module ...
解决的方法就在httpd这个配置文件里,找到以下两条:
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
前面有# 号,说明被注释掉了,不起作用,把#号去掉,就可以了。
5.启动
cd bin
在/usr/local/apache-httpd/bin目录下
./apachectl start
启动apache
6.配置为服务并开机启动
cp /usr/local/apache-httpd/bin/apachectl /etc/init.d
#复制运行脚本到etc/init.d
#chkconfig: 2345 10 90
#description: apache httpd service
#编辑该文件,并添加chkconfig和description
mv apachectl apache-httpd
#修改文件名,文件名就是最终的服务名,不要使用httpd,因为会和系统自带的httpd冲突
chkconfig --add apache-httpd
#添加服务
chkconfgi --list
#查看服务,应该会显示,如果没有显示,则使用chkconfig --list apache-httpd查看是否存在,如果存在则说明和系统的冲突了,需要换名称
#如果2,3,4,5都是on,则会开机自启动
service apache-httpd start
#启动
service apache-httpd stop
#停止