Apache编译安装c++
一,须要软件:apache
http://mirrors.cnnic.cn/apache//apr/apr-1.5.2.tar.gzbash
1.apr-1.5.2.tar.gz服务器
http://mirrors.cnnic.cn/apache//apr/apr-util-1.5.4.tar.gztcp
2.apr-util-1.5.4.tar.gzspa
http://exim.mirror.fr/pcre/pcre-8.38.tar.gzcode
3.pcre-8.38.tar.gzserver
http://apache.fayea.com//httpd/httpd-2.4.25.tar.gzip
4.httpd-2.4.25.tar.gzci
二,安装apr
yum
install
gcc libtools -y
tar
zxf apache
/apr-1
.5.2.
tar
.gz
cd
apr-1
.5.2
.
/configure
--prefix=
/usr/local/apr
make
&&
make
install
|
三,安装apr-util
tar
zxf apr-util-1.5.4.
tar
.gz
cd
apr-util-1.5.4
.
/configure
--prefix=
/usr/local/apr-util
--with-apr=
/usr/local/apr
make
&&
make
install
|
四,安装pcre库
yum
install
gcc-c++ -y
tar
zxf pcre-8.38.
tar
.gz
cd
pcre-8.38
.
/configure
--prefix=
/usr/local/pcre
make
&&
make
install
|
五,安装Apache服务器
tar
zxf httpd-2.4.25.
tar
.gz
cd
httpd-2.4.25
.
/configure --prefix
=
/usr/local/apache
--with-apr=
/usr/local/apr
--with-apr-util=
/usr/local/apr-util
--with-pcre=
/usr/local/pcre
make
&&
make
install
|
六,配置Apache
cd /usr/local/apache/conf/
vi httpd.conf
修改条目以下:
1.搜索ServerName www.example.com:80 去掉前面的注释
2.修改DocumentRoot:"/home/htdocs"
以及下面的一句
<Directory "/home/htdocs">
出错error:在主机输入 IP不能访问
缘由:防火墙拦截了80端口
解决:firewall-cmd --permanent --add-port=80/tcp
设置Apache为Linux服务并实现开机自启动
添加Apache到Linux服务
cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/
mv /etc/rc.d/init.d/apachectl /etc/rc.d/init.d/httpd
cd /etc/rc.d/init.d/
vi httpd
在第一行下添加以下三行文字
# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 90 90
# description:http server
注册该服务
chkconfig --add httpd #全部开机模式下自启动
chkconfig httpd on #345开机模式下自启动
加入PATH
vi /etc/profile
在最下面以行输入
PATH=$PATH:/usr/local/apache/bin
启动apache服务命令
apachectl -k start
若是要中止输入命令
apachectl -k stop
再输入地址发现能够了:
