Installing NGINX with PHP on CentOS 6 can be a hassle depending on the install and packages you use.

We've made a short and easy guide to install a minimal NGINX web server with PHP-FPM (5.6) support ready to go.

This is beind done in a fresh CentOS 6.6 64-bit Minimal installation.

First do a yum update (optional):
yum update -y

Once that's done install the latest Webtatic repository which holds our recommended PHP 5.6 and NGINX 1.8 packages:
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm
 
新:
yum install epel-release
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
 
 
rpm -Uvh https://mirror.webtatic.com/yum/el7/latest.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
Now install Nginx:
yum install nginx18 -y

Start the service and make it run after boot:
service nginx start
chkconfig nginx on

Now we can install PHP-FPM, we do not need the regular PHP package installed. If you need any modules such as MySQL, just do "yum install php56w-mysql":
yum install php56w-fpm -y

Start the service and run at boot:
service php-fpm start
chkconfig php-fpm on

Now we need to edit a part of the nginx.conf at /etc/nginx/nginx.conf. Look for the following section and change it accordingly to below (bolded text):
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

Uncomment the location section and edit the fastcgi_param script location from /scripts to our public directory like what is bolded below:
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            f#astcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

Save the nginx.conf file now once those are changed and restart nginx.
service nginx restart

Now lets make a phpinfo page to confirm that PHP is working correctly with Nginx and as an index page. Make a new "index.php" in the /usr/share/nginx/html/ directory with the following contents:
<?php
phpinfo();
?>

Save the file as "index.php" in /usr/share/nginx/html/, delete the index.html in the same directory, then visit the page in your web browser (http://your_server_ip/index.php). You should see the phpinfo() page with all of the information there like the screenshot below.

Create an IPTables firewall rule to allow access to port 80 (web server):
iptables -I INPUT 5 -p tcp -m tcp --dport 80 -j ACCEPT
service iptables save

 

yum install php56w-mbstring
yum install php56w-gd
yum install php56w-curl
yum install php56w-mysql

 
It's recommended to disable SELinux as it may cause some permissions issues. Type "setenforce 0" in SSH then edit the "/etc/selinux/config" file and change "enabled" to "disabled".

Done!

 
 
卸载php7
yum remove php
yum remove php*
yum remove php-*
yum remove php7
yum remove php70
yum remove php7.0
yum remove php-common

Install NGINX, PHP-FPM (5.6) on CentOS 6的更多相关文章

  1. [转载]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/ ...

  2. 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 ...

  3. How To Install Linux, nginx, MySQL, PHP (LEMP) stack on CentOS 6

    About Lemp LEMP stack is a group of open source software to get web servers up and running. The acro ...

  4. Centos 7下安装nginx,使用yum install nginx,提示没有可用的软件包

    Centos 7下安装nginx,使用yum install nginx,提示没有可用的软件包. 18 (flaskApi) [root@67 flaskDemo]# yum -y install n ...

  5. How To Install Nginx on CentOS 7(转)

    How To Install Nginx on CentOS 7 PostedJuly 22, 2014 427.4kviews NGINX CENTOS About Nginx Nginx is a ...

  6. Cenos7 编译安装 Mariadb Nginx PHP Memcache ZendOpcache (实测 笔记 Centos 7.0 + Mariadb 10.0.15 + Nginx 1.6.2 + PHP 5.5.19)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...

  7. 记录一次自己对nginx+fastcgi(fpm)+mysql压力测试结果

    nginx + fastcgi(fpm) 压力测试: CentOS release 5.9 16核12G内存 静态页面: 并发1000,压测200秒,测试结果: 系统最大负载5.47 成功响应: 25 ...

  8. yum install nginx

    先安装nginx的yum源 http://nginx.org/en/linux_packages.html#stable 找到链接,安装: rpm -ivh http://nginx.org/pack ...

  9. linux应用之nginx的安装及配置(centos)

    Ubuntu/CentOS 系统上安装与配置Nginx 一.在线安装: Ubuntu:sudo apt-get install nginx CentOS: sudo yum install nginx ...

随机推荐

  1. IDEA创建Maven项目一直显示正在加载的问题

    在用idea创建maven项目的时候 有时候会出现下面这种情况 出现原因 IDEA根据maven archetype的本质,其实是执行mvn archetype:generate命令,该命令执行时,需 ...

  2. css知多少(1)——我来问你来答(转)

    css知多少(1)——我来问你来答   1. 引言 各位前端或者伪前端(比如作者本人)的同志们,css对你们来说不是很陌生.比如我,在几年之前上大学的时候,给外面做网站就用css,而且必须用css.这 ...

  3. bzoj 2653 middle(主席树)

    题面:https://vjudge.net/problem/HYSBZ-2653 博客:https://blog.csdn.net/litble/article/details/78984846 这个 ...

  4. SpringBoot07 异常枚举、自定义异常、统一的全局异常处理

    1 异常编号和提示信息统一管理 利用枚举来实现异常的统一管理 package cn.xiangxu.springboottest.enums; import lombok.Getter; /** * ...

  5. windows平台下用C#访问HBase

    Hadoop中的HBase有多种数据访问方式,ubuntu里可以用hbase shell查看操作hbase数据库,但windows平台下需要用thrift对它进行访问. 例如hadoop安装在/usr ...

  6. AJAX的dataType问题

    dataType是预期服务器返回的数据类型.如果不指定,jQuery 将自动根据 HTTP 包 MIME 信息来智能判断,比如 XML MIME 类型就被识别为 XML.在 1.4 中,JSON 就会 ...

  7. review backpropagation

    The goal of backpropagation is to compute the partial derivatives ∂C/∂w and ∂C/∂b of the cost functi ...

  8. java全栈day12----final static 匿名对象 内部类 包的声明与访问

    final关键字概念 继承的出现提高了代码的复用性,并方便开发.但随之也有问题,有些类在描述完之后,不想被继承, 或者有些类中的部分方法功能是固定的,不想让子类重写.可是当子类继承了这些特殊类之后, ...

  9. Gremlin:图遍历语言

    Gremlin简介 Gremlin是Apache TinkerPop 框架下的图遍历语言.Gremlin是一种函数式数据流语言,可以使得用户使用简洁的方式表述复杂的属性图(property graph ...

  10. 简单的linux service(linux服务)编写,运行示例

    1.写一个简单小程序 #include<stdio.h> #include<stdlib.h> int main(int argc,char **argv) { while(1 ...