1.下载php-7.0.9 地址:http://php.net/downloads.php
2.安装编译运行库:yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y
3.编译安装PHP 5.5.0
以下参数支持,ftp,图片函数,pdo等支持,因为使用了php自带的mysqlnd,所以不需要额外安装mysql的lib库了.如果你是64位系统,参数后面加上--with-libdir=lib64,如果不是可以跳过。
tar zxvf php-7.0.9.tar.gz
cd php-7.0.9
./configure --prefix=/usr/local/php-7.0.9 --with-config-file-path=/usr/local/php-7.0.9/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
备注:如果PHP不需要curl和ftp的支持,可以将以上的--with-curl --enable-ftp去掉.
make
make install
有报错:configure: WARNING: unrecognized options: --with-mysql
更改只使用:--with-pdo-mysql
--with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd
4.配置php
cp php.ini-production /usr/local/php-7.0.9/etc/php.ini
cp /usr/local/php-7.0.9/etc/php-fpm.conf.default /usr/local/php-7.0.9/etc/php-fpm.conf
cd /usr/local/php-7.0.9/etc/php-fpm.d cp www.conf.default www.conf
启动php-fpm /usr/local/php-7.0.9/sbin/php-fpm
php启动报错:
cd /usr/local/php-7.0.9/etc/php-fpm.d cp www.conf.default www.conf 解决
5.安装nginx :http://www.cnblogs.com/chenjw-note/p/5683019.html
6.配置nginx.conf
在nginx.conf的http断中加上如下内容:
server {
listen 80;
server_name test.ttlsa.com;
access_log /data/logs/nginx/test.ttlsa.com.access.log main;
index index.php index.html index.html;
root /data/site/test.ttlsa.com;
location /
{
try_files $uri $uri/ /index.php?$args;
}
location ~ .*\.(php)?$
{
expires -1s;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
配置讲解
nginx将会连接回环地址9000端口执行PHP文件,需要使用tcp/ip协议,速度比较慢.建议大家换成使用socket方式连接。将fastcgi_pass 127.0.0.1:9000;改成fastcgi_pass unix:/var/run/phpfpm.sock;
7.重启nginx
8.测试:http://192.168.3.150:90/info.php
![](https://images2015.cnblogs.com/blog/948623/201608/948623-20160810232625527-1714185312.png)
成功!