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. Solr搜索的排序打分规则探讨

    使用Solr搭建搜索引擎很容易,但是如何制定合理的打分规则(boost)做排序却是一个很头痛的事情.Solr本身的排序打分规则是继承自Lucene的文本相关度的打分即boost,这一套算法对于通用的提 ...

  2. Codeforces 1137C Museums Tour (强连通分量, DP)

    题意和思路看这篇博客就行了:https://www.cnblogs.com/cjyyb/p/10507937.html 有个问题需要注意:对于每个scc,只需要考虑进入这个scc的时间即可,其实和从哪 ...

  3. echarts柱状图每个柱子显示不同颜色,并且能够实现点击每种颜色影藏对应柱子的功能

    ---------------------------------------------------------代码区---------------------------------------- ...

  4. session,cookie总结

    不同的域名生成的session_id是不一样的,(就算是相同的主域,例如:www.test.com, blog.test.com 都不一样); 相同的主域,不同的二级域名,例如www和blog都是不共 ...

  5. hibernate 对象OID

    它是hibernate用于区分两个对象是否是同一个对象的标识. 我们都知道,虚拟机内存区分两个对象看的是内存的地址是否一致.数据库区分两个对象,靠的是表的主键.hibernate负责把内存中的对象持久 ...

  6. 3.内网渗透之reGeorg+Proxifier

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAxIAAAE2CAIAAAB6BDOVAAAgAElEQVR4Aey9Z5Aex3X327MRGVzkRH ...

  7. JSP或者说是JSP翻译引擎

    JSP最终输出就是底层去继承Servlet,然后输出JSP页面上的内容而已,不明白了看第六条. 页面java脚本,也就是JSP页面上写JAVA代码如下:  

  8. ElementUI的表单和vee-validate结合使用时发生冲突的解决

    在Vue项目中使用ElementUI表单时,同时又引入了vee-validate进行使用的时候,在浏览器上会出现这样的报错: [Vue warn]: The computed property &qu ...

  9. [raspberry pi3] zram设置

    linux 3.15之后添加了个和mac一样的功能,内存压缩zram, 之前还有个zswap, zram通常是以模块的方式被放在系统里面的,以便在可以根据需求的不同,定制化加载. raspberry ...

  10. C#检测系统是否激活[转自StackOverFlow]

    using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServi ...