一、创建LAMP环境 Apache+MySQL+PHP for CentOS

(一)、Apache安装(使用yum安装或者官网下载软件包安装)

1、到Apache官网下载httpd软件包。网址:http://httpd.apache.org/解压到本地的httpd包

[root@info lamp]# tar -zxvf httpd-2.0.64.tar.gz (注意名称以你下载的软件包型号为准)

[root@info lamp]# cd httpd-2.0.64 (切换入目录)

完成解压后,对httpd进行编译安装,--enable-module=so:加载modul动态模块。

[root@info httpd-2.0.64]# ./configure --prefix=/usr/local/apache --enable-module=so

\\

编译安装出现如下问题及解决方法

#./configure --prefix……检查编辑环境时出现:

checking for APR... no

configure: error: APR not found . Please read the documentation

解决办法:

1.下载所需软件包:

wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz

wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz

wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip

2.编译安装:

yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs

具体步骤如下:

a:解决apr not found问题>>>>>>

[root@xt test]# tar -zxf apr-1.4.5.tar.gz

[root@xt test]# cd apr-1.4.5

[root@xt apr-1.4.5]# ./configure --prefix=/usr/local/apr

[root@xt apr-1.4.5]# make && make install

b:解决APR-util not found问题>>>>

[root@xt test]# tar -zxf apr-util-1.3.12.tar.gz

[root@xt test]# cd apr-util-1.3.12

[root@xt apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util -with- apr=/usr/local/apr/bin/apr-1-config

[root@xt apr-util-1.3.12]# make && make install

c:解决pcre问题>>>>>>>>>

[root@xt test]#unzip -o pcre-8.10.zip

[root@xt test]#cd pcre-8.10

[root@xt pcre-8.10]#./configure --prefix=/usr/local/pcre

[root@xt pcre-8.10]#make && make install

4.最后编译Apache时加上:

--with-apr=/usr/local/apr \

--with-apr-util=/usr/local/apr-util/ \

--with-pcre=/usr/local/pcre

成功编译完成~

\\

[root@info httpd-2.0.64]#make

[root@info httpd-2.0.64]#make install

[root@info httpd-2.0.64]/usr/local/apache/bin/apchectl –t (检查语法)

[root@info httpd-2.0.64]/usr/local/apache/bin/apchectl start (启动)

\\

服务启动过程遇到端口占用的情况及解决方法

# /etc/init.d/httpd start
Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

1.netstat -lnp|grep 80

tcp 0 0 192.168.180.68:61027 0.0.0.0:* LISTEN 6289/oproxyd
tcp 0 0 :::80 :::* LISTEN 846/httpd
tcp 0 0 ::ffff:192.168.180.68:7001 :::* LISTEN 32015/java

找到pid 846

#ps 846

查看
#kill -9 846

杀掉

#./apachectl start

\\