linux 源码安装apache2.4并添加服务
源码安装apache,路径 /usr/local/httpd241.安装apr
yum -y install epel-release
wget -c http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
tar xf apr-1.5.2.tar.gz cd apr-1.5.2
./configure --prefix=/usr/local/apr;echo $?
make && make install;echo $?
2.安装apr-util
wget -c http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.gz
tar xf apr-util-1.5.2.tar.gz
cd apr-util-1.5.2
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr;echo $?
make && make install;echo $?
3.安装httpd2.4.12
yum install pcre-devel openssl-devel
wget -c http://www.apache.org/dist/httpd/httpd-2.4.12.tar.gz
tar xf httpd-2.4.12.tar.gz
cd httpd-2.4.12
./configure --prefix=/usr/local/httpd24 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=event;echo $?
make && make install;echo $?
4.测试
/usr/local/apache24/bin/apachectl start
netstat -utl |grep http
出现 0 *:http *:* LISTEN
浏览器访问centos机器IP,出现It works!
5.添加到系统服务实现开机启动:
cp /usr/local/httpd24/bin/apachectl /etc/init.d/httpdvim /etc/init.d/httpd
在文件开头加入下面几行:
#!/bin/sh
# chkconfig: 35 85 15
# description: Apacheserver.
保存推出,然后
chmod +x /etc/init.d/httpd
chkconfig --add httpd
chkconfig httpdon
页:
[1]