yum -y install apr* pcre* openssl* gcc*
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
make && make install
ln -s /usr/local/httpd/bin/* /usr/local/bin
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
两种启动httpd服务方法
1.vim /etc/init.d/httpd
在/bin/bash下面加两条
#chkconfig: 35 85 21
#description: Startup script for the Apache HTTP Server
chkconfig --add httpd
结束
2.
vim /lib/systemd/system/httpd.service
添加以下内容:
[Unit]
Description-The Apache HTTP Server
After =network.target
[Service]
Type =forking
PIDFile =/usr/local/httpd/logs/httpd.pid
ExecStart =/usr/local/bin/apachectlSOPTIONS
ExecReload =/bin/kill- HUPSMAINPID
KillMode =process
Restart =on-failure
Restartsec =42s
[Install]
WantedBy =graphical.target
结束
mkdir -p /var/www/html/lylcom
echo "
who am i
" > /var/www/html/lylcom/index.html
mkdir -p /var/www/html/lyl2com
echo "
what is my name
" > /var/www/html/lyl2com/index.html
vim /usr/local/httpd/conf/httpd.conf
多端口必须在此配置文件中另写一条Listen 端口号
添加
Include conf/extra/httpd-vhosts.conf
vim /etc/hosts
192.168.1.1 www.lyl.com
三种方式(别忘了systemctl start httpd 如果启动后修改了就restart)
vim /usr/local/httpd/conf/extra/httpd-vhosts.conf
DocumentRoot "/var/www/html/lyl
ServerName www.lyl.com
Require all granted
DocumentRoot "/var/www/html/lyl2com
ServerName www.lyl2.com
2.基于端口
DocumentRoot "/var/www/html/lylcom
ServerName www.lyl.com
Require all granted
DocumentRoot "/var/www/html/lyl2com
ServerName www.lyl2.com
3.基于域名
DocumentRoot "/var/www/html/lylcom
ServerName www.lyl.com
Require all granted
DocumentRoot "/var/www/html/lyl2com
ServerName www.lyl2.com