PHP7 + OPENRESTY安装,


OpenResty1.9.7.4源码包
下载地址:https://openresty.org/download/openresty-1.9.7.4.tar.gz

php下载地址 http://cn2.php.net/get/php-7.0.5.tar.gz/from/this/mirror

libicon 下载地址 http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

libmcrypt 下载地址 ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz

libiconv 安装

tar -zxvf libiconv-1.14.tar.gz 
./configure --prefix=/usr/local
 make
make install

libmcrypt安装

cd libmcrypt-2.5.7
./configure --prefix=/usr/local/libmcrypt
make 
make install

然后在php.ini里面添加:
extension=mcrypt.so

php安装依赖:
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql-devel pcre-devel libxslt-devel curl-devel openssl-devel

./configure --prefix=/usr/local/php705 --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip --with-iconv-dir=/usr/local

编译
make ZEND_EXTRA_LIBS=’-liconv’
make install

复制出配置文件
cp /usr/local/php705/etc/php-fpm.conf.default /usr/local/php705/etc/php-fpm.conf
cp /usr/local/php705/etc/php-fpm.d/www.conf.default /usr/local/php705/etc/php-fpm.d/www.conf
cp /root/software/php-7.0.5/php.ini-production /usr/local/php705/lib/php.ini

启动php-fpm
/usr/local/php705/sbin/php-fpm
nohup /usr/sbin/php-fpm -R >/dev/null 2>&1 &
若无报错,则说明启动成功

安装memcache扩展

     下载php7专用扩展包:

https://codeload.github.com/websupport-sk/pecl-memcache/zip/php7

     解压并进入软件包:

unzip pecl-memcache-php7.zip
cd pecl-memcache-php7

     开始安装:

/usr/local/php705/bin/phpize
./configure –with-php-config=/usr/local/php705/bin/php-config
make && make install

     修改php.ini

vim /usr/local/php705/lib/php.ini

加入下面这行

extension=memcache.so

     检查是否成功

/usr/local/php705/bin/php -m

若有memcache,则说明安装成功

安装OpenResty 1.9.7.4

     安装依赖:

yum install readline-devel pcre-devel openssl-devel

     解压并进入软件包:

tar xvzf openresty-1.9.7.4.tar.gz
cd openresty-1.9.7.4

     依次执行下面两条命令编译安装:

./configure –prefix=/usr/local/openresty1974
gmake && gmake install

     启动nginx

/usr/local/openresty1974/nginx/sbin/nginx
若无报错,则说明启动成功

配置Nginx

     打开配置文件

vim /usr/local/openresty1974/nginx/conf/nginx.conf

     修改web根目录

找到这段配置代码:

location / {
root html;
index index.html index.htm;
}

其中,html为web根目录,改为自己定义的路径

location / {
root /root/workspace;
index index.php index.html index.htm;
}

     支持PHP。

找到这段配置代码:

location ~ .php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

include fastcgi_params;

}

去掉注释,改为

location ~ .php{  
    root           /root/workspace;  
    fastcgi_pass   127.0.0.1:9000;  
    fastcgi_index  index.php;  
    fastcgi_param  SCRIPT_FILENAME  /root/workspace
fastcgi_script_name;
include fastcgi_params;
}

     配置虚拟主机。

在配置文件最后一个大括号(})的上一行插入下面一条命令:

include vhost/vhost_*.conf;

保存并退出nginx.conf。

mkdir vhost
vim vhost/vhost_pay.v1game.v1cn.conf

加入以下内容:

server {
listen 80;
server_name pay.v1game.v1cn;
location / {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /root/workspace/gplatform/websitefastcgiscriptname;fastcgipass127.0.0.1:9000;fastcgiindexindex.php;if(!frequest_filename ) {
rewrite ^/(.*) /bootstrap.php?var=1 break;  
        }  
    }  
    location ~ .php
{
rewrite /(.*).php/1 redirect;
}
}

原文链接:http://straiway.sinaapp.com/2016/06/01/coding/linux/bulit-openresty-nginx-php-7-php-fpm-mysql5-7-environment-on-centos-6-7.html

相关内容

    暂无相关文章