您的位置:首页 > 运维架构 > Apache

Apache+PHP开发环境的配置

2016-04-26 17:40 453 查看
Apache+PHP开发环境的配置

系统:redhat 32位(rhel-server-6.5-i386-dvd)

在配置apache+php的开发过程遇到了许多问题,大部分都在网上找到了解决方法,在此谢谢那些分享过相关经验的前辈们。

下面就是我在配置的详细过程:

相关软件链接:链接:http://pan.baidu.com/s/1hs0eSHA 密码:x7rd

1、卸载linux上已安装的apache和php

(1) #rpm -pa | grep httpd //检测apache是否安装

# httpd-2.2.15-29.el6_4.i686//存在

#rpm –e httpd-2.2.15-29.el6_4.i686 –nodeps//卸载

(2)#rpm –pa | grep -i php //检测php是否安装

# //不存在,若存在,就卸载

2、进入安装包存放目录:#cd /usr/local/src

/*

*每一步的安装过程

*1、解压安装包

*2、使用“configure”命令检查并配置安装需要的系统环境,并生成安装配置文件

*3、使用“make”命令编译源代码文件并生成安装文件

*4、使用“make install”命令安装编译过的文件

*/

步骤一、安装libxml2库文件

1、tar -xvzf libxml2-2.6.30.tar.gz
2、cd libxml2-2.6.30
3、./configure --prefix=/usr/local/libxml2/
4、make && make install


步骤二、安装libmcrypt库文件

1、tar -xvzf libmcrypt-2.5.7.tar.gz
2、cd libmcrypt-2.5.7
3、./configure --prefix=/usr/local/libmcrypt
4、make && make install


步骤三、安装zlib库文件

1、tar -xvzf zlib-1.2.7.tar.gz
2、cd zlib-1.2.7
3、./configure --prefix=/usr/local/zlib/
4、make && make install


步骤四、安装libpng库文件

1、tar -xvzf libpng-1.2.31.tar.gz
2、cd libpng-1.2.31
3、./configure --prefix=/usr/local/libpng/
4、make && make install

安装时可能遇到的问题:configure: error: ZLib not installed
解决方法:
1、cd 、/usr/local/src/zlib-1.2.7  //进入zlib的源文件目录,
2、make clean //执行命令 make clean,清除zlib;
2、 ./configure  //重新配置 ./configure,后面不要接--prefix参数;
3、make &&make install //编辑 && 安装;
4、cd /usr/local/libpng-1.2.31//进入libpng目录,执行命令 ./configure --prefix=/usr/local/libpng;
5、make && make clean //编译 && 安装;
6、安装成功;


步骤五、安装jpeg文件

1、tar -xvzf jpegsrc.v9b.tar.gz
2、cd jpeg-9b/
3、./configure --prefix=/usr/local/jpeg/ --enable-shared --enable-static
4、make && make install


步骤六、安装freetype库文件

1、tar -xvzf freetype-2.3.11.tar.gz
2、cd freetype-2.3.11
3、./configure --prefix=/usr/local/freetype
4、make && make install

安装过程可能遇到的问题:
make: Nothing to be done for `unix'.
解决方法:
builds/unix在freetype下载解压的目录下。
进入 builds/unix目录,然后在里边运行./configure命令,运行该命令不会出现上边错误。
#cd  /usr/local/src/freetype-2.5.3/builds/unix
# ./configure --prefix=/usr/local/freetype --enable-shared
#cd  /usr/local/src/freetype-2.5.3/
#make  &&  make install


步骤七、安装autoconf库文件

1、tar -xvzf autoconf-2.63.tar.gz
2、cd autoconf-2.63
3、./configure
4、make && make install


步骤八、安装gd(新版本叫libgd)库文件

1、tar -xvzf libgd-2.1.1.tar.gz
2、cd libgd-2.1.1
3、./configure --prefix=/usr/local/gd --with-zlib=/usr/local/zlib/ --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype
4、make && make install


步骤九、安装apr库文件

1、tar -jxvf apr-1.4.6.tar.bz2
2、cd apr-1.4.6
3、./configure --prefix=/usr/local/apr
4、make && make install


步骤十、安装apr-util库文件

1、tar -xvjf apr-util-1.4.1.tar.bz2
2、cd apr-util-1.4.1
3、./configure --pref=/usr/local/apr-util --with-apr=/usr/local/apr
4、make && make install


步骤十一、安装pcre库文件

1、tar -xvjf pcre-8.12.tar.bz2
2、cd pcre-8.12
3、./configure --prefix=/usr/local/pcre/
4、make && make install


步骤十二、安装apache

1、tar- xvjf httpd-2.2.31.tar.bz2
2、cd httpd-2.2.31
3、./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --with-z=/usr/local/zlib --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --disable-userdir --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support  --enable-module=shared
(--enable-module=shared 表示Apache可以动态的加载模块,要记得加上,否则无法使用php)
4、make && make install

启动apache服务:/usr/local/apache/bin/apachectl start

启动apache服务时可能出现问的题:
httpd: Could not reliably determine the server's fully qualified domain name
解决方法:修改配置文件,该配置文件由上面第三步的--sysconfdir=/etc/httpd 指定
将/etc/httpd /httpd.conf 中的#ServerName localhost:80注释去掉,修改为
ServerName 本机IP:80  //本机ip必须写本机的ip地址,而非127.0.0.1和localhost

查看80端口是否开启:netstat -tnl|grep 80
tcp        0      0 :::80            :::*            LISTEN

[root@htsuccess httpd-2.4.1]# ps -ef|grep httpd
root      2986     1  0 01:13 ?        00:00:00 /usr/local/apache/bin/httpd -k start
daemon    2987  2986  0 01:13 ?        00:00:00 /usr/local/apache/bin/httpd -k start
daemon    2988  2986  0 01:13 ?        00:00:00 /usr/local/apache/bin/httpd -k start
daemon    2989  2986  0 01:13 ?        00:00:00 /usr/local/apache/bin/httpd -k start

在浏览器地址栏中输入127.0.0.1跳转到显示it works的页面
通过以上步骤确认apache 安装成功

5、将apache设置成开机启动
echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.d/rc.local


步骤十三:安装php

1、tat -xvzf php-5.2.6.tar.gz

2、cd php-5.2.6

3、

./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-apxs2=/usr/local/apache/bin/apxs –with-libxml-dir=/usr/local/libxml2 –with-jpeg-dir=/usr/local/jpeg –with-png-dir=/usr/local/libpng –with-freetype-dir=/usr/local/freetype –with-gd –with-zlib-dir=/usr/local/zlib –with-mcrypt=/usr/local/libmcrypt –enable-soap –enable-mbstring=all

4、make && make install

5、cp php.ini-dist /usr/local/php/etc/php.ini

6、//配置apache配置文件,让php处理.php文件

vi /etc/httpd/httpd.conf

加入:

Addtype application/x-httpd-php .php

Addtype application/x-httpd-php-source .phps

7、 重启apache服务:

/usr/local/apache/bin/apachectl stop

/usr/local/apache/bin/apachectl start

vi /usr/local/apache/htdocs/test.php
内容:
<?php
phpinfo();
?>
访问:http://127.0.0.1/test.php 显示php页面


以上就是我配置的过程,希望我的分享可以帮到你!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: