[转载]How To Install Nginx And PHP-FPM On CentOS 6 Via Yum
http://www.lifelinux.com/how-to-install-nginx-and-php-fpm-on-centos-6-via-yum/
http://blog.csdn.net/seanchan/article/details/7680354
Today, I’m going to show you how to install Nginx with PHP-FPM via yum.
Before starting to install Nginx and PHP-FPM, you must uninstall all previous Apache and PHP related RPMs installed on your system. Login as root and type the following command
# yum remove httpd* php*
Enabling Additional Repositories
By default, php-fpm is not available from the official CentOS repositories, but from the Remi RPM repository which itself depends on the EPEL repository; we can enable both repositories as follows:
# yum install yum-priorities -y
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
Sample outputs
Retrieving http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
warning: /var/tmp/rpm-tmp.00kiDx: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ########################################### [100%]
1:epel-release ########################################### [100%]
Installing Nginx
Type the following command
# yum install nginx
Sample outputs
Dependencies Resolved ================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
nginx x86_64 0.8.54-1.el6 epel 358 k
Installing for dependencies:
GeoIP x86_64 1.4.8-1.el6 epel 620 k
fontconfig x86_64 2.8.0-3.el6 base 186 k
freetype x86_64 2.3.11-6.el6_1.8 updates 358 k
gd x86_64 2.0.35-10.el6 base 142 k
libX11 x86_64 1.3-2.el6 base 582 k
libX11-common noarch 1.3-2.el6 base 188 k
libXau x86_64 1.0.5-1.el6 base 22 k
libXpm x86_64 3.5.8-2.el6 base 59 k
libjpeg x86_64 6b-46.el6 base 134 k
libpng x86_64 2:1.2.46-1.el6_1 base 180 k
libxcb x86_64 1.5-1.el6 base 100 k
libxslt x86_64 1.1.26-2.el6 base 450 k
perl x86_64 4:5.10.1-119.el6_1.1 base 10 M
perl-Module-Pluggable x86_64 1:3.90-119.el6_1.1 base 37 k
perl-Pod-Escapes x86_64 1:1.04-119.el6_1.1 base 30 k
perl-Pod-Simple x86_64 1:3.13-119.el6_1.1 base 209 k
perl-libs x86_64 4:5.10.1-119.el6_1.1 base 575 k
perl-version x86_64 3:0.77-119.el6_1.1 base 49 k Transaction Summary
================================================================================
Install 19 Package(s)
Upgrade 0 Package(s) Total download size: 14 M
Installed size: 47 M
Is this ok [y/N]: y
If you want to run nginx by default when the system boots, type the following command
# chkconfig --level 345 nginx on
To start Nginx for the first time, type the following command
# /etc/init.d/nginx start
Sample output
Starting nginx: [ OK ]
Installing PHP-FPM
Type the following command
# yum --enablerepo=remi install php php-fpm
Sample outputs
Dependencies Resolved ====================================================================================
Package Arch Version Repository Size
====================================================================================
Installing:
php x86_64 5.3.10-2.el6.remi remi 2.3 M
php-fpm x86_64 5.3.10-2.el6.remi remi 1.1 M
Installing for dependencies:
apr x86_64 1.3.9-3.el6_1.2 base 123 k
apr-util x86_64 1.3.9-3.el6_0.1 base 87 k
apr-util-ldap x86_64 1.3.9-3.el6_0.1 base 15 k
httpd x86_64 2.2.15-15.el6.centos.1 updates 813 k
httpd-tools x86_64 2.2.15-15.el6.centos.1 updates 70 k
libedit x86_64 2.11-4.20080712cvs.1.el6 base 74 k
mailcap noarch 2.1.31-2.el6 base 27 k
php-cli x86_64 5.3.10-2.el6.remi remi 2.2 M Transaction Summary
====================================================================================
Install 10 Package(s)
Upgrade 0 Package(s) Total download size: 6.8 M
Installed size: 21 M
Is this ok [y/N]: y
If you want to run php-fpm by default when the system boots, type the following command
# chkconfig --level 345 php-fpm on
PHP was installed with only core modules. It’s very likely that additional modules will be desired, such as MySQL, XML, GD, etc. Type the following command
# yum --enablerepo=remi install php-gd php-mysql php-mbstring php-xml php-mcrypt
To start PHP-FPM for the first time, type the following command
# /etc/init.d/php-fpm restart
Sample output
Starting php-fpm: [ OK ]
Configure PHP-FPM and Nginx working together
The configuration file for Nginx is located at /etc/nginx/nginx.conf. To edit nginx.conf type the following command
# vi /etc/nginx/nginx.conf
Uncomment and edit as follows
...
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
...
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
...
Restart Nginx to reload new configuration, enter
# /etc/init.d/nginx reload
Now create the following PHP file in the document root
# vi /usr/share/nginx/html/info.php
Append content as follows:
<?php
phpinfo();
?>
Access it http://YOUR-SERVER-IP

Nginx Virtual Hosting Configuration
Your sample setup
IP: 192.168.1.113
Domain: domain.local
Hosted at: /home/www/domain.local
Type the following command to create user called www
# useradd www
Create necessary directories
# mkdir -p /home/www/domain.local/public_html
# mkdir -p /home/www/domain.local/log
# chown -R www.www /home/www/
# chmod 755 /home/www/
Creating virtual host config file
# cd /etc/nginx/conf.d/
# cp virtual.conf www.conf
Open www.conf, enter
# vi /etc/nginx/conf.d/www.conf
Append configuration as follows:
server {
        server_name  domain.local;
        root /home/www/domain.local/public_html;
        access_log /home/www/domain.local/log/domain.local-access.log;
        error_log /home/www/domain.local/log/domain.local-error.log;
        location / {
                index  index.html index.htm index.php;
        }
        location ~ \.php$ {
                include /etc/nginx/fastcgi_params;
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
}
You can also check the current status as well as the configuration syntax:
# /etc/init.d/nginx configtest
Sample outputs
the configuration file /etc/nginx/nginx.conf syntax is ok
configuration file /etc/nginx/nginx.conf test is successful
Now edit /etc/php-fpm.d/www.conf to change the users who own the php-fpm processes to www, enter
# vi /etc/php-fpm.d/www.conf
Find “group of processes” and edit as follows:
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = www
; RPM: Keep a group allowed to write in log dir.
group = www
Finally restart nginx
# /etc/init.d/nginx restart
# /etc/init.d/php-fpm restart
[转载]How To Install Nginx And PHP-FPM On CentOS 6 Via Yum的更多相关文章
- Install NGINX, PHP-FPM (5.6) on CentOS 6
		
Installing NGINX with PHP on CentOS 6 can be a hassle depending on the install and packages you use. ...
 - How to Install Apache Tomcat 8.5 on CentOS 7.3
		
How to Install Apache Tomcat 8.5 on CentOS 7.3 From: https://www.howtoforge.com/tutorial/how-to-inst ...
 - 【转载】CentOS-yum安装Nginx
		
查看系统版本 $ cat /etc/redhat-release Nginx 不在默认的 yum 源中,使用官网的 yum 源 $ rpm -ivh http://nginx.org/packages ...
 - yum install nginx
		
先安装nginx的yum源 http://nginx.org/en/linux_packages.html#stable 找到链接,安装: rpm -ivh http://nginx.org/pack ...
 - centos6.5 64位 yum install nginx的默认安装路径
		
yum install nginx网站文件存放默认目录 /usr/share/nginx/html 网站默认站点配置 /etc/nginx/conf.d/default.conf 自定义Nginx站点 ...
 - 【Ubuntu16.04】 install nginx
		
1. Download PGP key in order to pass the authentication of the nginx repository signature. click to ...
 - mac brew install nginx遇到的坑
		
默认使用 brew install nginx 出现了一下的错误: p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: ...
 - Install Nginx on CentOS 7
		
To set up the yum repository for RHEL/CentOS, create the file named /etc/yum.repos.d/nginx.repo with ...
 - ubuntu16 install nginx
		
1,更新系统 sudo apt-get update 2,安装nginx sudo apt-get install nginx 3,验证是否安装成功 curl 127.0.0.1 常用配置文件和命令 ...
 
随机推荐
- yum被锁定:Another app is currently holding the yum lock; waiting for it to exit…
			
yum被锁定无法使用,错误信息截图如下: 解决方法:rm -rf /var/run/yum.pid 来强行解除锁定,然后你的yum就可以运行了
 - dns隧道 dns2tcpd
			
有些网络的防火墙设置只允许端口53的UDP流量,就不能通过tcp搭建隧道,这种情况下我们可以通过UDP搭建DNS隧道,通过搭建一个DNS服务器委派的子域,这个子域因为使我们自己搭建的主机,这时候就可以 ...
 - openstack(pike 版)集群部署(一)----基础环境部署
			
一.环境 1.系统: a.CentOS Linux release 7.4.1708 (Core) b.更新yum源和安装常用软件 # yum -y install epel-release ba ...
 - layer数据表格换行
			
在使用layer数据表格的时候,默认是不可以换行的.这样显示 改动后 数据格式为 aa<br>bb就会显示为换行 比如我们的字符串是 a<br>b 这样的字符串浏览器 ...
 - Python+Selenium学习--操作测试对象
			
场景 前面已经讲解了如果定位对象,定位之后需要对这个对象进行操作.是鼠标点击还是键盘输入,取决于我们定位的对象缩支持的操作. webdriver中比较常用的操作元素的方法有下面几个: clear ...
 - oracle数据库查询出多条数据,合并,之后列转行
			
select B.enterprise_code, B.enterprise_name, sum(B.h0_overnum) AS over00, sum(B.h1_overnum) AS over0 ...
 - this.class.getClassLoader().getResourceAsStream与this.class.getResourceAsStream 文件地址获取
			
本文部分转自:http://xixinfei.iteye.com/blog/1256291 this.getClass().getClassLoader().getResource("tem ...
 - [剑指offer]51-数组中的逆序对(归并排序)
			
题目链接 https://www.nowcoder.com/questionTerminal/96bd6684e04a44eb80e6a68efc0ec6c5 题意 在数组中的两个数字,如果前面一个数 ...
 - 关于界面绘制过程多次回调ondraw()方法产生的问题
			
最近项目中,出现一个问题,要做成的效果是这样的,但是一进去就变成这样了, 后来发现,刚进去是正常的,一闪而过,就变成全部了. 界面绘制过程,ondraw() 会被多次回调. 就是说在第一次绘制的时候是 ...
 - gearman的持久化,以mysql的方式
			
1.为什么要持久化? gearman的job server中的工作队列存储在内存中,一旦服务器有未处理的任务时重启或者宕机,那么这些任务就会丢失.持久化存储队列可以允许添加后台任务,并将其存储在外部的 ...