1、安装PHP7
先安装依赖
yum install php-mcrypt libmcrypt libmcrypt-devel libxml2-devel openssl-devel libcurl-devel libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 libjpeg-turbo-devel libmcrypt-devel MySQL-devel libtidy-devel libtidy openldap openldap-devel libxslt libxslt-devel -y
cp -frp /usr/lib64/libldap* /usr/lib/
./configure --prefix=/Data/local/php-7.0.8 \
--with-config-file-path=/Data/local/php-7.0.8/etc \
--with-iconv-dir=/Data/local/libiconv-1.14/ \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-gettext \
--with-tidy \
--with-libxml-dir \
--with-xsl \
--with-curl \
--with-mcrypt \
--with-gd \
--with-openssl \
--with-mhash \
--with-ldap \
--with-ldap-sasl \
--with-xmlrpc \
--without-pear \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-pcntl \
--enable-sockets \
--enable-zip \
--enable-soap \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-pdo \
--enable-fpm \
--disable-debug \
--disable-ipv6
make
make install
mkdir /Data/local/php-7.0.8/etc
cp php.ini-production /Data/local/php-7.0.8/etc/php.ini
2、修改php-fpm配置
cd
/Data/local/php-7.0.8
cp
etc
/
php
-
fpm
.
conf
.
default
etc
/
php
-
fpm
.
conf
cd
/Data/local/php-7.0.8/etc/php-fpm.d
cp
cp www.conf.default localhost.conf
vi
localhost.conf
修改
user = www-data
group = www-data
如果www-data用户不存在,那么先添加www-data用户
groupadd www-data
useradd -g www-data www-data
启动php-fpm
/Data/local/php-7.0.8/sbin/php-fpm
3、修改nginx配置
server {
listen 80;
server_name vagrant;
#charset koi8-r;
#access_log /Data/logs/nginx/vagrant.access.log main;
error_log /Data/logs/nginx/vagrant.error.log info;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /var/www/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
我这边是把服务器的代码运行目录放在 /var/www/html 的,可以自行设置