PHP安装与配置
PHP安装前提
Apache已安装
PHP安装
cd /data/software
wget https://cn.php.net/distributions/php-7.1.8.tar.gz
tar -zxvf php-7.1.8.tar.gz
cd php-7.1.8
./configure --with-apxs2=/usr/local/httpd/bin/apxs --with-mysqli --prefix=/usr/local/php
make
make install
PHP配置
cp php.ini-development /usr/local/php/lib/php.ini
vi /usr/local/httpd/conf/httpd.conf
去掉如下注释
LoadModule php7_module modules/libphp7.so
增加如下配置
SetHandler application/x-httpd-php
重启Apache
cd /usr/local/httpd/bin
./apachectl restart
PHP安装检测
假设Apache工作目录为/www/cz/com Apache监听端口为:10086
cd /www/cz/com
vi test.php
test.php内容如下
在浏览器内打开如下地址:https://localhost:10086/test.php
如果显示了php的信息,则说明安装成功
错误处理
错误:virtual memory exhausted: Cannot allocate memory
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1
解决:./configure改为
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysqli --prefix=/usr/local/php --disable-fileinfo
上一篇: ASP实用大全-实战ASP(7)