一、步骤:
安装所需要的一些库 //可以直接进入第二步,安装时出现所需库未安装返回第一步
安装apache
安装php
修改配置文件
测试
二、安装库
安装时可能出现一些软件包未安装 比如:APR APR-util PCRE C++ 或其他库
安装方法如下:
yum 安装 //yum install -y 包名
tar 安装 如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | tar zxvf apr-1.4.8.tar.gz cd apr-1.4.8./configure --prefix=/usr/local/apr //注意路径安装httpd时免得找不到makemake install tar zxvf apr-util-1.5.2.tar.gz cd apr-util-1.5.2./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/aprmakemake install yum install -y gcc gcc-c++tar zxvf pcre-8.33.tar.gz cd pcre-8.33./configure --prefix=/usr/local/pcremakemake install |
三、安装apache
1 2 3 4 5 | tar zxvf httpd-2.4.6.tar.gz cd httpd-2.4.6./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-module=so --with-pcre=/usr/local/pcremakemake install |
四、安装PHP
1 2 3 4 5 6 7 | yum list libxml2yum install libxml2-devel.i686tar zxvf php-5.5.4.tar.gzcd php-5.5.4./configure --with-apxs2=/usr/local/apache/bin/apxs --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5 --with-mysql=shared,mysqlndmakemake install |
五、修改配置文件
Apache
配置文件在/usr/local/apache/conf/httpd.conf
网页文件在/usr/local/apache/htdocs/
php
配置文件在 /etc/php.ini
1 2 | cp xxx/php.ini-development /etc/php/inivi /usr/local/apache/conf/httpd.conf |
添加 //自动添加了libphp5.so
1 | AddType application/x-httpd-php .php .phtml .php3 .inc |
在/usr/local/apache/htdocs/下
1 2 3 4 5 6 | vi index.php <?phpphpinfo()?> |
1 2 3 | /usr/local/apache/bin/httpd -k restartservice httpd startps -ef |grep httpd |
六、测试
关闭防火墙
1 | service iptables stop |
关闭selinux
1 | setenforce 0 |
此时:/usr/local/apache/conf/httpd.conf下只有index.html
测试及访问:http://192.168.89.139
修改httpd.conf
1 | vi /usr/local/apache/conf/httpd.conf |
重启服务:
1 | service httpd restart |
再次访问:http://192.168.89.133
七、安装XDebug
1 2 3 4 5 6 | tar -xvf xdebug-2.4.1.tgz/usr/local/php5/bin/phpize --执行后出现configuate文件./configuremake && make installcd xdebug-2.4.1yum install autoconf |
1 2 3 4 5 6 7 | [xdebug]zend_extension="/usr/local/php5/lib/php/extensions/no-debug-zts-20121212/xdebug.so"xdebug.remote_enable = Onxdebug.remote_handler = dbgp xdebug.remote_host= localhostxdebug.remote_port = 9000xdebug.idekey = PHPSTORM |
八、最小安装可能出现以下情况:
service httpd restart 出现 httpd:unrecognized service 错误
解决:
1 2 3 | cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpdchmod 700 /etc/rc.d/init.d/httpdmake //no found make //编译时出现 |
解决:
1 | yum install make |