标签:http charset api lock gre 一个 gtest etc url
在实际项目中,有时因为老项目的原因而不得不在同一台服务器配置多个 php 环境,本文为配置多 PHP 环境教程
假设:已有 php7 的环境,需要配置一个 PHP5 的环境
sudo wget http://au1.php.net/get/php-5.6.27.tar.gz/from/this/mirror -O php-5.6.27
sudo tar -zxvf php-5.6.27 && cd php-5.6.27
sudo ./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-iconv-dir=/usr/local/lib --enable-fpm --enable-pcntl --enable-mysqlnd --with-pdo-mysql=mysqlnd --with-zlib --enable-zip --with-gd --with-curl=/usr/bin/curl --with-mysqli --with-pdo-mysql
sudo make && sudo make install
sudo cp /usr/local/src/php-5.6.27/php.ini-development /usr/local/php5/etc/php.ini
sudo cp /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf
# 修改 php.ini
sudo vim /usr/local/php5/etc/php.ini
cgi.fix_pathinfo=0;
# 修改 php-fpm.conf
user=www
group=www
listen.owner = www
listen.group = www
listen.mode = 0660
listen=/var/php/php5-cgi.sock
# 创建 sock 文件
sudo touch /var/php/php5-cgi.sock
# 链接 php 指令
sudo ln -s /usr/local/php5/bin/php /usr/bin/php5
sudo cp /usr/local/src/php-5.6.27/sapi/fpm/init.d.php-fpm /etc/init.d/php5-fpm
sudo chmod +x /etc/init.d/php5-fpm
sudo systemctl unmask php5-fpm.service # 使 php5-fpm 服务生效
sudo sysv-rc-conf php5-fpm on # 设置开机启动
服务管理
service php5-fpm status
service php5-fpm start
service php5-fpm stop
service php5-fpm restart
service php5-fpm reload
service php5-fpm help
service php5-fpm configtest
7.配置 nginx server
sudo touch /var/php/php5-fpm.sock
sudo vim /usr/local/nginx/conf/vhosts/shop.mt.conf
server {
listen 80;
server_name shop.mitao.me;
#server_name 10.1.16.162;
charset utf-8;
index index.php index.html index.htm;
#access_log logs/host.access.log main;
root /mnt/d/xmt-shop;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
#error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/php/php5-cgi.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
8.分别启动 php5 和 php7
sudo service php-fpm start
sudo service php5-fpm start
ps -ef|grep php-fpm
总结:其实多 PHP 环境配置的关键点就是,通过配置 nginx http server 项,
location ~ .php$ {
fastcgi_pass unix:/var/php/php-cgi.sock
# fastcgi_pass unix:/var/php/php5-cgi.sock
}
即通过监听不同的 监听socket套接字 来区分,同时也需要在 php-fpm.conf 配置对应 连接socket 套接字
标签:http charset api lock gre 一个 gtest etc url
原文地址:http://blog.51cto.com/12750968/2322967