php生产环境配置,PHP生产环境配置 - osc_ifi9q17t的个人空间 - OSCHINA - 中文开源技术交流社区...

生产环境:操作系统使用Centos6.5、服务器选择Nginx

0.准备安装介质

Nginx选择稳定版本:http://nginx.org/download/nginx-1.16.1.tar.gz

Nginx安装:

1.下载好的nginx移动到/usr/local下并解压,然后重命名为nginx

2.进入nginx目录执行./configure命令

执行make命令

执行make install命令

3.启动nginx

执行./sbin/nginx

Php选择版本较老(5.6):https://www.php.net/distributions/php-5.6.40.tar.gz

PHP安装:

1.先安装依赖包

yum -y install libxml2

yum -y install libxml2-devel

yum -y install openssl

yum -y install openssl-devel

yum -y install curl

yum -y install curl-devel

yum -y install libjpeg

yum -y install libjpeg-devel

yum -y install libpng

yum -y install libpng-devel

yum -y install freetype

yum -y install freetype-devel

yum -y install pcre

yum -y install pcre-devel

yum -y install libxslt

yum -y install libxslt-devel

yum -y install bzip2

yum -y install bzip2-devel

2.进入php目录

执行

./configure --prefix=/data/php --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-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --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-sysvshm --enable-xml --enable-zip

3.执行make

4.执行make install

PS:Nginx比较好装,Php相对难一些,有较多的前置模块需要安装,安装到哪一步报错就自行百度加装模块

1.Php配置;php主要配置两个文件php.ini、php-fpm.conf

(1)php.ini文件:该文件在php安装根目录下,有对应的模板php.ini-development  php.ini-production,这两个文件对应了开发和生产环境;将其中一个复制到php根目录下的etc目录下面;PS:小白基本上不用动这个配置

(2)php-fpm.conf文件:该文件在php根目录的etc目录下,有对应模板php-fpm.conf.default;拷贝一下成php-fpm.conf;PS:小白基本也不动它

(3)启动php-fpm:php安装根目录下执行./sbin/php-fpm     PS:可以加上 -y php-fpm配置文件地址(用于配置多个实例,多实例需要复制出多个php-fpm.conf文件,通过修改监听的端口、区分不同实例)默认端口是9000 PS:小白基本用默认配置耍耍

2.Nginx配置;nginx的配置在安装目录的conf下,nginx.conf文件

#其他我也没动,小白一个

#注意的是root 路径设置好,以后PHP项目就放到这里了

#location 照着复制过去就行= =#9090端口是我谁便取的

#127.0.0.1:9000这里有些讲究,端口和php-fpm.conf中的监听端口保持#一致,若没改conf配置,默认还是9000

#location正则和fastcgi_split_path_info 需要注意配置对

server{

listen9090;

root/data/www;

location/{

index index.php index.html index.htm;

}

location~ .+\.php($|/) {

fastcgi_pass127.0.0.1:9000;

fastcgi_split_path_info^((?U).+.php)(/?.+)$;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

}

PS:可能会出现nginx和php-fpm用户不匹配问题,需要统一用户(Nginx在配置文件首行指定用户、php-fpm.conf中搜索user、group指定用户)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值