关闭防火墙:systemctl stop firewalld.service
关闭防火墙开机自启动:systemctl disable firewalld.service
安装vim及unzip:yum install -y vim unzip
安装编译环境:yum install -y gcc gcc-c++ autoconf libtool
安装apr
cd /usr/local/src/
wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-1.5.0.tar.gz
tar zxvf apr-1.5.0.tar.gz
cd apr-1.5.0
./configure –prefix=/usr/local/apr #安装目录
make && make install
安装apr-util
cd /usr/local/src/
wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-util-1.5.3.tar.gz
tar zxvf apr-util-1.5.3.tar.gz
cd apr-util-1.5.3
./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr #安装目录 及apr安装路径
make && make install
安装pcre
cd /usr/local/src/
wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/pcre/pcre-8.38.tar.gz
tar zxvf pcre-8.38.tar.gz
cd pcre-8.38
./configure –prefix=/usr/local/pcre #安装目录
make && make install
编译安装Apache
cd /usr/local/src/
wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/apache/httpd-2.4.23.tar.gz
tar zxvf httpd-2.4.23.tar.gz
cd httpd-2.4.23
./configure –prefix=/usr/local/httpd –with-pcre=/usr/local/pcre –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util
make && make install
修改httpd.conf配置文件参数
cd /usr/local/httpd/
vim httpd.conf
1.找到Directory参数,注释掉Require all denied添加Require all granted。
2.找到ServerName参数,添加ServerName localhost:80 然后,按Esc键后输入:wq保存退出。
设置PidFile路径: vim /usr/local/httpd/httpd.conf
在配置文件最后添加以下内容: PidFile “/var/run/httpd.pid”
启动Apache服务并验证
cd /usr/local/httpd/bin/
./apachectl start
netstat -tnlp #查看服务是否开启
设置开机自启
在rc.local文件中添加/usr/local/httpd/bin/apachectl start,然后输入:wq保存退出。
vim /etc/rc.d/rc.local
设置环境变量
vi /root/.bash_profile
PATH=
PATH:
P
A
T
H
:
HOME/bin:/usr/local/httpd/bin
然后输入:wq保存退出,执行:
source /root/.bash_profile