环境说明: 效果截图:
httpd编译安装编译安装apr
1) wget
2) tar xf apr-1.5.2.tar.gz
3) cd apr-1.5.2
4) ./configure
5) make&makeinstall
编译安装apr-util
1) wget
2) cd apr-util-1.5.4
3) tar xf apr-util-1.5.4.tar.gz
4) ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
5) make&makeinstall
编译安装httpd
1) yum install pcre pcre-devel -y
2) yum install openssl-devel -y
3) wget
4) cd httpd-2.4.25
5) ./configure \
--prefix=/usr/local/httpd \
--sysconfdir=/etc/httpd \
--enable-so \
--enable-rewrite \
--enable-ssl --enable-cgi \
--enable-cgid --enable-modules=most \
--enable-mpms-shared=all \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--with-ssl=/usr/local/openssl \
--enable-proxy \
--enable-proxy-fcgi
6) make && make install
关闭selinux和防火墙
1) getenforce
2) setenforce 0
3) vim /etc/selinux/config
4) getenforce
5) iptables -F
修改配置文件
1) vim /etc/httpd/httpd.conf
2) 添加 PidFile "/var/run/httpd.pid": 修改pid进程文件位置
服务启动验证
1) /usr/local/httpd/apachectl start
2) netstat -tnlp
创建启动文件
1) vim /etc/init.d/httpd
. /etc/rc.d/init.d/functions #chkconfig: 2345 10 90 # # pull in sysconfig settings [ -f /etc/sysconfig/httpd ] && . /etc/sysconfig/httpd HTTPD_LANG=${HTTPD_LANG-"C"} INITLOG_ARGS="" #apachectl=/usr/local/apache/bin/apachctl #httpd=${HTTPD-/usr/local/apache/bin/httpd} httpd=${HTTPD-/usr/local/httpd/bin/apachectl} prog=httpd pidfile=${PIDFILE-/var/run/httpd.pid} lockfile=${LOCKFILE-/var/lock/subsys/httpd} RETVAL=0 start() { echo -n $"Starting $prog: " LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $lockfile return $RETVAL } stop() { echo -n $"Stopping $prog: " killproc -p ${pidfile} -d 10 $httpd RETVAL=$? # if we are in halt or reboot runlevel kill all running sessions # so the TCP connections are closed cleanly echo [ $RETVAL -eq 0 ] && rm -f ${lockfile} ${pidfile} } reload() { echo -n $"Reloading $prog: " if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then RETVAL=$? echo $"not reloading due to configuration syntax error" failure $"not reloading $httpd due to configuration syntax error" else killproc -p ${pidfile} $httpd -HUP RETVAL=$? fi echo } restart() { stop start } case "$1" in start) start ;; stop) stop ;; status) status -p ${pidfile} $httpd RETVAL=$? ;; restart) restart ;; condrestart) if [ -f ${pidfile} ]; then stop start fi ;; reload) reload ;; graceful|help|configtest|fullstatus) $apachectl $@ RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}" exit 1 esac exit $RETVAL
httpd