安装php7

下载

wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2

解压

tar zxf php-7.1.6.tar.bz2
cd php-7.1.6

安装

./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc  --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif


make && make install

配置

cp php.ini-production  /usr/local/php7/etc/php.ini

php命令

  • /usr/local/php7/bin/php -m :查看静态模块

  • /usr/local/php7/bin/php -i :查看相关配置

测试php解析

# vim /usr/local/apache/htdocs/index1.php
<?php
  echo "Hello World";
?>

同时要修改httpd的配置文件/usr/local/apache/conf/httpd.conf

# 去掉注释
# ServerName www.example.com:80

Require all denied
# 改成
Require all granted

AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
# 两行下加入
AddType application/x-httpd-php .php    


DirectoryIndex index.html
# 改为
DirectoryIndex index.html index.php

/usr/local/apache/bin/apachectl -t 检查配置文件语法错误

/usr/local/apache/bin/apachectl graceful 加载配置文件

最后更新于

这有帮助吗?