编译安装httpd
一、安装前的说明:
httpd依赖于apr和apr-util所以在安装httpd之前要把这些东西都安装上去。
事先安装的依赖:
yum -y install gcc gcc-c++ pcre-devel openssl-devel
二、上传httpd-2.4.20.tar.gz,apr-1.5.2.tar.gz,apr-util-1.5.4.tar.gz 包到服务器
三、解压httpd-2.4.20.tar.gz,apr-1.5.2.tar.gz,apr-util-1.5.4.tar.gz
tar -xzvf httpd-2.4.20.tar.gz -C/usr/src tar -xzvf apr-1.5.2.tar.gz -C/usr/src tar -xzvf apr-util-1.5.4.tar.gz -C/usr/src
四、安装apr到/usr/local/apr
/usr/src/apr-1.5.2/configure --prefix=/usr/local/apr && make && make install
五、安装apr-util到/usr/local/apr-util
/usr/src/apr-util-1.5.4/configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install
六、安装httpd到/usr/local/httpd/
/usr/src/httpd-2.4.20/configure --prefix=/usr/local/httpd/ --enable-so --enable-rewrite --enable-ssl --enable-cgi --enable-cgid \ --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util && make && make install
七、编写linux 启动脚本
touch /etc/init.d/httpd
/etc/init.d/httpd 的内容如下:
#!/bin/bash # chkconfig: 2345 64 36 # description: httpd server script HTTPD=/usr/local/httpd/bin/httpd PID_FILE=/usr/local/httpd/logs/httpd.pid case $1 in "start") if test -e $PID_FILE then echo 'httpd is started ...' else echo 'httpd will start ...' $HTTPD fi ;; "stop") if test -e $PID_FILE then PID=`cat $PID_FILE` kill $PID else echo 'httpd is stoped' fi ;; "status") if test -e $PID_FILE then echo 'httpd has been started ' else echo 'httpd is stoped' fi ;; *) echo "not support option $1" ;; esac
9、启动httpd
service httpd start