赞
踩
#!/bin/bash read -p "输入域名www.xxx.com:" a systemctl stop firewalld systemctl disable firewalld setenforce 0 yum -y install gcc gcc-c++ make pcre pcre-devel expat-devel perl cd /opt/ tar zxvf apr-1.6.2.tar.gz tar zxvf apr-util-1.6.0.tar.gz tar jxvf httpd-2.4.29.tar.bz2 mv apr-1.6.2 /opt/httpd-2.4.29/srclib/apr mv apr-util-1.6.0 /opt/httpd-2.4.29/srclib/apr-util cd /opt/httpd-2.4.29/ ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi make && make install ln -s /usr/local/httpd/conf/httpd.conf /etc/ ln -s /usr/local/httpd/bin/* /usr/local/bin/ echo '[Unit] Description=The Apache HTTP Server After=network.target [Service] Type=forking PIDFile=/usr/local/httpd/logs/httpd.pid ExecStart=/usr/local/bin/apachectl $OPTIONS ExecReload=/bin/kill -HUP $MAINPID [Install] WantedBy=multi-user.target' > /lib/systemd/system/httpd.service systemctl start httpd.service cp /etc/httpd.conf{,.bak} c=`ifconfig | awk 'NR==2{print $2}'` sed -i "51c Listen $c:80" /etc/httpd.conf.bak sed -i '52 s/^/#/' /etc/httpd.conf.bak sed -i '197d' /etc/httpd.conf.bak sed -i "196a ServerName $a:80" /etc/httpd.conf.bak cat /etc/httpd.conf.bak > /etc/httpd.conf httpd -t cat /usr/local/httpd/htdocs/index.html systemctl start httpd.service systemctl restart httpd.service echo "$c $a" >> /etc/hosts netstat -anpt | grep 80 if [ $? -eq 0 ];then echo "Apache服务已启动" else echo 启动失败 exit 1 fi
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。