Centos 安装Apache
1.下载apache相关包
wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.33.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
wget https://jaist.dl.sourceforge.net/project/pcre/pcre/8.42/pcre-8.42.tar.gz
2. 安装编译环境
#yum -y install gcc-c++
#yum install expat-devel
3.解压相关包并安装(必须按步骤来,先安装相应依赖才能编译通过)
a.
#tar -zxvf apr-1.6.3.tar.gz
#cd apr-1.6.3
#./configure --prefix=/usr/local/apr
#make
#make install
b.
#tar -zxvf apr-util-1.6.1.tar.gz
#cd apr-util-1.6.1
#./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
#make
#make install
c.
#tar -zxvf pcre-8.42.tar.gz
#cd pcre-8.42
#./configure --prefix=/usr/local/pcre
#make
#make install
d.
#tar -zxvf httpd-2.4.33.tar.gz
#cd httpd-2.4.33
#./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
#make
#make install
4.启动apache并访问网页
apache默认占用80端口,所以如果有应用占用80这个端口,就要注意会存在端口冲突问题。(可以在/usr/local/apache2/conf/目录下httpd.conf修改端口)
•启动Apache:/usr/local/apache2/bin/apachectl start
•停止Apache:/usr/local/apache2/bin/apachectl stop
•重启Apache:/usr/local/apache2/bin/apachectl restart
启动后在浏览器中通过http://ip:80,如果看到页面中显示“It works!”字样,则代表Apache验证通过。