php和nginx整合
前言
初学liunx系统。
本文章记录在阿里云服务器上安装php并整合到nginx服务器上的步骤
一、php安装
-
安装依赖组件
yum -y
install gcc gcc-c++ bzip2 bzip2-devel bzip2-libs python-devel ncurses
ncursesdevel openssl openssl-devel
yum
install -y libxml2-devel
-
在官网下载php的tar.gz包
-
上传到服务器
-
解压
-
检查当前的环境是否满足要安装软件的依赖关系
./configure --prefix=/usr/local/php
–with-config-file-path=/usr/local/php --enable-mbstring --enable-ftp --with-gd
–with-jpeg-dir=/usr --with-png-dir=/usr --with-mysql=mysqlnd
–with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --without-pear --disable-phar --enable-sockets
–with-freetype-dir=/usr --with-zlib --with-libxml-dir=/usr --with-xmlrpc
–enable-zip --enable-fpm --enable-xml --enable-sockets --with-gd --with-zlib
–with-iconv --enable-zip --with-freetype-dir=/usr/lib/ --enable-soap
–enable-pcntl --enable-cli --with-curl
-
编译安装
扫描二维码关注公众号,回复: 11595062 查看本文章make install
-
复制并重命名为php.ini
-
把display_errors=Off改成On
-
复制启动脚本
chmod
+x /etc/init.d/php-fpm
-
修改php-fpm配置文件:
去掉 pid = run/php-fpm.pid 前面的分号
修改user和group的用户为当前用户(也可以不改,默认会添加nobody这个用户和用户组)
-
启动php
-
检查是否已启动
查看监听端口
二、整合nginx测试php:
-
修改nginx配置文件并添加内容
-
location ~ .php$ {
root /usr/local/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME fastcgi_script_name;
include fastcgi_params;
}
-
修改后对nginx进行重启
-
在nginx的网站发布路径下创建index.php文件
-
访问测试
三、参考文章地址
1、https://blog.csdn.net/wxyf2018/article/details/102847478
2、https://www.cnblogs.com/houss/p/11296285.html