安装 Nginx
Nginx 安装比较简单,可以到这里查看:
http://nginx.org/en/docs/install.html
https://www.nginx.com/resources/wiki/start/topics/tutorials/install/
https://www.runoob.com/linux/nginx-install-setup.html
安装 PHP
1.下载 PHP
到官方网站下载 PHP。网址 http://php-fpm.org/downloads/
2.解压 PHP
tar zxf php-x.x.x
3.编译 PHP (这里只简单设置支持 PHP-FPM 和 MySQL ),高级命令查看后文
cd ../php-x.x.x
./configure --enable-fpm --with-mysql
make
make install
4.复制配置文件到正确位置
cp php.ini-development /usr/local/php/php.ini
cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf
cp sapi/fpm/php-fpm /usr/local/bin
5. 如果访问 Nginx 的文件不存在时,要阻止请求传递到 PHP-FPM 后端,防止任意脚本注入。
我们可以通过设置我们的php.ini文件中的 cgi.fix_pathinfo 语句为 0 来解决这个问题。
查找 php.ini:
vim /usr/local/php/php.ini
找到 cgi.fix_pathinfo 语句:
cgi.fix_pathinfo=0
在启动服务之前,php-fpm.conf 必须修改指定 PHP-FPM 服务必须作为用户 www-data 和 组 www-data 运行 :
vim /usr/local/etc/php-fpm.conf
找到下面的代码,修改成下面这样:
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group ; will be used.
user = www-data
group = www-data
现在就能够启动 php-fpm 服务了:
/usr/local/bin/php-fpm
Nginx 配置支持PHP应用程序:
vim /usr/local/nginx/conf/nginx.conf
找到类似以下代码,修改如下,配置支持 .php 文件:
location / {
root html;
index index.php index.html index.htm;
}
下一步骤是确保 PHP 文件传递到 PHP-FPM 后端. 找到关于 PHP location 指令,输入以下内容:
location ~* \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
重启 Nginx.
sudo /usr/local/nginx/sbin/nginx -s stop
sudo /usr/local/nginx/sbin/nginx
创建测试文件
rm /usr/local/nginx/html/index.html
echo "<?php phpinfo(); ?>" >> /usr/local/nginx/html/index.php
在浏览器中打开 http://localhost 。 phpinfo() 就能够显示了。
编译 PHP 高级命令
./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt --enable-mbstring --with-curl --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli --with-gd --with-jpeg-dir --with-openssl --enable-xml --with-png-dir --disable-rpath --with-freetype-di
原文链接:http://woqilin.blogspot.com/2016/07/centos-nginx-phpfastcgi.html
相关推荐
NULL 博文链接:https://wsluozefeng.iteye.com/blog/2214138
下载的软件版本完全相同的情况下,复制粘贴,一次完成。经过了为期一周的调试,排除掉了N多错误。终于大功告成。
php+mysql+nginx安装与常遇到的错误 centos系统为例子 在高并发连接的情况下,Nginx是Apache服务器不错的替代品。Nginx同时也可以作为7层负载均衡服务器来使用。根据我的测试结果,Nginx 0.8.15 + PHP 5.2.10 ...
部署时间:2012-07-24 OS环境:CentOS 6.1 nginx:nginx-1.2.2 PHP:PHP5.3.14 0、安装依赖包 代码如下:yum install openssl-devel pcre-devel zlib-devel libjpeg-devel libpng-devel freetype-devel gcc make 1、...
前言 对于Nginx,一个IP上配置多个站点还是很常见的。...在centos上搭建php-fpm+nginx环境不是很难,网上有很多的帖子,按照上面讲解的,把需要安装的软件安装一下就行了。 目录一览 安装完毕后,配置文件通
/application/nginx-1.6.3/conf/fastcgi_params.default /application/nginx-1.6.3/conf/koi-utf /application/nginx-1.6.3/conf/koi-win /application/nginx-1.6.3/conf/mime.types /application/nginx-1.6.3/conf/...
在centos上成功编译安装nginx 1.4、php 5.4并成功启动nginx和php-fpm后,访问php提示”File not found.”,同时在错误日志中看到: 代码如下:2013/10/22 20:05:49 [error] 12691#0: *6 FastCGI sent in stderr: ...
我们先来看下nginx.conf server { listen 80; server_name www.a.com; index index.html index.htm index.php; root /data/htdocs/www.a.com/; #limit_conn crawler 20; location ~ .*\.(php|php5)?$...
一 、Nginx服务基础 Nginx (engine x)专为性能优化而开发,其特点是占有内存少,它的稳定性和低系统资源消耗,以及对并发连接的高处理能力,(单台物理服务器可支持5000...Nginx+PHP(FastCGI)服务器,在3万并发连接下
VPS(全称Virtual Private Server)是利用最新虚拟化技术在一台物理服务器上创建多个相互隔离的虚拟私有主机。它们以最大化的效率共享硬件、软件许可证以及管理资源。
nginx,mysql,php)搭建wordpress博客系统,同时使用fastcgi利用 LNMP 实现WordPress站点搭建,在搭建过程中需要使用PowerTools库,要记得打开,否则会报错,这个脚本,我在云服务器centos8Stream,和本地虚拟机...
只要是php-fpm,基本上都是与nginx搭配。查了一大批相关资料,写本文总结一下。 apache下有多个fastCGI的支持方案:至少有mod_fcgi、mod_fastcgi(git)、mod_proxy_fcgi等。这两个模块都有点老,尤其mod_fastcgi...
二,特点与优势3种Web环境自由组合lnmp , lamp , lanmp (Nginx前端Apache配置)可自主选择,甚至安装完后还可以自由调整。最新版本全部采用最新稳定版本的扩展,如PHP 5.4 (可选PHP 5.2 )系列, MySQL 5.5系列...
nginx一般是把请求发fastcgi管理进程处理,fascgi管理进程选择cgi子进程处理结果并返回被nginx。 PHP-FPM是一个PHP FastCGI管理器,是只用于PHP的。 PHP在 5.3.3 之后已经讲php-fpm写入php源码核心了。所以已经不...
之前一直使用Nginx+Fastcgi来搭建python web服务器,本文介绍Nginx+UWSGI组合来实现。uWSGI 是一个快速的、纯C语言开发的、自维护的、对开发者友好的WSGI服务器,旨在提供专业的 Python web应用发布和开发。它更符合...
Lnmp环境详细配置: Linux : CentOS 6.2 PHP : 5.4.9 Nginx : 1.2.5 Fastcgi 其中还包含了SSH 和 Redis的安装。 详细的操作步骤,很适合初学者。
经过志文工作室测试有效的相关配置主要内容如下: 代码如下:location ~ \.php(.*)$ { fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_...
listen = /tmp/php-fcgi.sock // 监听的地址,可以监听socket ,也可以监听端口 listen = 127.0.0.1:8089 或者这样写,php-fpm 通常在本地使用,php和nginx 通常在一台机器,所以可写127.0.0.1,别的机器 连接,需用...
listen = /tmp/php-fcgi.sock // 监听的地址,可以监听socket ,也可以监听端口 listen = 127.0.0.1:8089 或者这样写,php-fpm 通常在本地使用,php和nginx 通常在一台机器,所以可写127.0.0.1,别的机器 连接,需用...