搭建LAMP环境(源码方式)(2)

第二步,安装Apache

--1.解压
[root@serv02 httpd-2.2.21]# tar -xfhttpd-2.2.21.tar.gz -C /usr/src
--2.进入安装目录,检查配置
[root@serv02 httpd-2.2.21]# cd/usr/src/httpd-2.2.21/
[root@serv02 httpd-2.2.21]# ./configure--help
[root@serv02 httpd-2.2.21]# ./configure--prefix=/usr/local/apache --enable-modules=all --enable-mods-shared=all--enable-so --with-mpm=worker
checking for zlib location... not found
#如果出现zlib not found,安装zlib-devel
[root@serv02 httpd-2.2.21]# yum installzlib-devel -y
 
--3.编译
[root@serv02 httpd-2.2.21]# make
 
--4.安装
[root@serv02 bin]# make install
 
--5.进入/usr/local/apache/bin/目录,启动
[root@serv02 apache]# cd/usr/local/apache/bin/
[root@serv02 bin]# ./apachectl -k start
httpd: apr_sockaddr_info_get() failed forserv02.host.com
httpd: Could not reliably determine theserver's fully qualified domain name, using 127.0.0.1 for ServerName
[root@serv02 bin]# netstat -langput | grephttpd
#出现上述问题,编辑httpd.conf文件,加上ServerName serv02.host.com;编辑hosts文件,加上192.168.1.12 serv02.host.com(注意,本机IP是192.168.1.12)
[root@serv02 bin]# vim ../conf/httpd.conf
[root@serv02 bin]# grep"ServerName" /usr/local/apache/conf/httpd.conf
# ServerName gives the name and port that theserver uses to identify itself.
#ServerName :80
ServerName serv02.host.com
[root@serv02 bin]# echo "192.168.1.12serv02.host.com" >> /etc/hosts
hosts      hosts.allow  hosts.deny 
[root@serv02 bin]# echo "192.168.1.12serv02.host.com" >> /etc/hosts
[root@serv02 bin]# tail -n1 /etc/hosts
192.168.1.12 serv02.host.com
#再次启动,查看端口,成功
[root@serv02 bin]# ./apachectl -k start
[root@serv02 bin]# netstat -langput | grephttpd
tcp      0      0 :::80                      :::*                        LISTEN      20441/httpd
 
--6.测试
浏览器输入 如果出现“It works”则成功

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/45f0c23677b995a6f75e2091fa2ebba9.html