zoukankan      html  css  js  c++  java
  • nginx 部署php

    一:nginx安装:

      yum install nginx

      安装完成即可,在/usr/sbin/目录下是nginx命令所在目录,在/etc/nginx/目录下是nginx所有的配置文件,用于配置nginx服务器以及负载均衡等信息

      启动:nginx

      停止:$ nginx -s stop  or   $ nginx -s quit

      配置:

    二:PHP 安装

    yum list installed | grep php 

    先删除已有的php版本 ,执行下面的命令删除php

    yum remove php-common

    然后像安装那样问你是否继续的,输入yes即可

    添加 yum 源

    CentOS 6.x 的源

    # rpm -Uvh http://download.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
    # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

    CentOS 7.x 的源

    # rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/7/x86_64/e/epel-release-7-5.noarch.rpm 
    # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

    安装 PHP

    # yum install --enablerepo=remi,remi-php56 php php-opcache php-pecl-apcu php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process php-gd php-common

    注:安装5.6版本为remi-php56,安装5.5版本为remi-php55

    查看 PHP 版本

    # php -v
    PHP 5.6.18 (cli) (built: Feb 3 2016 10:25:33) 
    Copyright (c) 1997-2016 The PHP Group

    启动 php-fpm

    /usr/sbin/php-fpm
    

      查看是否启动成功

    复制代码
    root@iZ25fm7iewtZ:/usr/local/etc# ps -ef | grep php-fpm
    root      3691     1  0 18:49 ?        00:00:00 php-fpm: master process (/usr/local/etc/php-fpm.conf)
    www-data  3692  3691  0 18:49 ?        00:00:00 php-fpm: pool www      
    www-data  3693  3691  0 18:49 ?        00:00:00 php-fpm: pool www      
    root      4982 29553  0 18:59 pts/1    00:00:00 grep --color=auto php-fpm
    
    
    root@iZ25fm7iewtZ:/usr/local/etc# netstat -tnl | grep 9000
    tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN  

    开机启动php-fpm,开机启动的配置文件是:/etc/rc.local ,加入 /usr/local/sbin/php-fpm 即可

    vi /etc/rc.local
    添加 /usr/local/sbin/php-fpm

    修改nginx的配置文件,支持php文件的解析,找到location的添加位置,在后面添加下面这个location

    复制代码
     location ~ .php$ {
                            root /var/www; #指定php的根目录
                            fastcgi_pass 127.0.0.1:9000;#php-fpm的默认端口是9000
                            fastcgi_index index.php;
                            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                            include fastcgi_params;
                    }
    复制代码

    测试nginx.conf是否修改成功

    /usr/sbin/nginx -t

    重起nginx

    /usr/sbin/nginx -s reload
    
    
  • 相关阅读:
    09.回文数
    08.字符串转换位整数
    背景图片自适应
    认证 (authentication) 和授权 (authorization) 的区别
    vue-组件之间传值
    数组对象去重
    二进制数转换十进制数
    node-删除对象中指定属性失效问题-JSON.parse实例化
    Vue-动态修改数组
    正则遇到的问题集合
  • 原文地址:https://www.cnblogs.com/royfans/p/10907875.html
Copyright © 2011-2022 走看看