首页 > 代码库 > php环境搭建

php环境搭建

一、步骤:

1) 安装所需要的一些库           //可以直接进入第二步,安装时出现所需库未安装返回第一步

2) 安装apache

3) 安装php

4) 修改配置文件

5) 测试

二、安装库

安装时可能出现一些软件包未安装 比如:APR APR-util PCRE  C++ 或其他库

安装方法如下:

  1. yum  安装   //yum install -y 包名
  2. tar  安装 如下
  1. tar zxvf apr-1.4.8.tar.gz
  2. cd apr-1.4.8
  3. ./configure --prefix=/usr/local/apr //注意路径 安装httpd时免得找不到
  4. make
  5. make install
  6. tar zxvf apr-util-1.5.2.tar.gz
  7. cd apr-util-1.5.2
  8. ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
  9. make
  10. make install
  11. yum install -y gcc gcc-c++
  12. tar zxvf pcre-8.33.tar.gz
  13. cd pcre-8.33
  14. ./configure --prefix=/usr/local/pcre
  15. make
  16. make install

三、安装apache
  1. tar zxvf httpd-2.4.6.tar.gz
  2. cd httpd-2.4.6
  3. ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-module=so --with-pcre=/usr/local/pcre
  4. make
  5. make install

四、安装PHP
  1. yum list libxml2
  2. yum install libxml2-devel.i686
  3. tar zxvf php-5.5.4.tar.gz
  4. cd php-5.5.4
  5. ./configure --with-apxs2=/usr/local/apache/bin/apxs --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5 --with-mysql=shared,mysqlnd
  6. make
  7. make install

五、修改配置文件

Apache

     配置文件在/usr/local/apache/conf/httpd.conf

     网页文件在/usr/local/apache/htdocs/

php 

 配置文件在 /etc/php.ini

cp xxx/php.ini-development  /etc/php/ini

vi  /usr/local/apache/conf/httpd.conf

 添加  //自动添加了libphp5.so

 AddType application/x-httpd-php .php .phtml .php3 .inc

 

 /usr/local/apache/htdocs/下

 vi index.php 

  1. <?php
  2. phpinfo()
  3. ?>


  1.  /usr/local/apache/bin/httpd -k restart
  2.  service httpd start
  3.  ps -ef |grep httpd

六、测试

 关闭防火墙

service iptables stop

 关闭selinux

setenforce 0

 

此时:

/usr/local/apache/conf/httpd.conf下只有index.html

技术分享 

技术分享 

测试及访问:

http://192.168.89.139

技术分享 

技术分享 

修改httpd.conf

vi /usr/local/apache/conf/httpd.conf

技术分享 

重启服务:

service httpd restart

再次访问:

http://192.168.89.133

技术分享七、安装XDebug
  1.  tar -xvf xdebug-2.4.1.tgz
  2.  /usr/local/php5/bin/phpize  --执行后出现configuate文件
  3. ./configure
  4. make && make install
  5. cd xdebug-2.4.1
  6. yum install autoconf


  1. [xdebug]
  2. zend_extension="/usr/local/php5/lib/php/extensions/no-debug-zts-20121212/xdebug.so"
  3. xdebug.remote_enable = On
  4. xdebug.remote_handler = dbgp   
  5. xdebug.remote_host= localhost
  6. xdebug.remote_port = 9000
  7. xdebug.idekey = PHPSTORM
八、最小安装可能出现以下情况:
  1. service httpd restart 出现 httpd:unrecognized service 错误
  2. 解决:
  3. cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
  4. chmod 700 /etc/rc.d/init.d/httpd
  5. make //no found make //编译时出现
  6. 解决:
  7. yum install make



来自为知笔记(Wiz)


php环境搭建