zoukankan      html  css  js  c++  java
  • Centos7下PHP的卸载与安装nginx

    Centos7下PHP的卸载与安装nginx

    CentOS上PHP完全卸载,想把PHP卸载干净,直接用yum的remove命令是不行的,需要查看有多少rpm包,然后按照依赖顺序逐一卸载。
    1.首先查看机器上安装的所有php相关的rpm包
    [root@localhost nginx]# rpm -qa | grep php
    php-cli-5.3.3-22.el6.x86_64
    php-pdo-5.3.3-22.el6.x86_64
    php-gd-5.3.3-22.el6.x86_64
    php-fpm-5.3.3-22.el6.x86_64
    php-common-5.3.3-22.el6.x86_64
    php-5.3.3-22.el6.x86_64
    php-xml-5.3.3-22.el6.x86_64
    php-pear-1.9.4-4.el6.noarch

    2.按依赖顺序进行删除
    rpm -e php-fpm-5.3.3-22.el6.x86_64
    rpm-e php-pdo-5.3.3-22.el6.x86_64
    rpm -e php-pear-1.9.4-4.el6.noarch
    rpm-e php-cli-5.3.3-22.el6.x86_64
    rpm -e php-5.3.3-22.el6.x86_64
    rpm-e php-xml-5.3.3-22.el6.x86_64
    rpm -e php-gd-5.3.3-22.el6.x86_64
    rpm-e php-common-5.3.3-22.el6.x86_64

    ==========================
    centos7安装nginx和php

    nginx安装,参考网址:https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-7

    rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

    yum install nginx

    安装PHP和php-fpm
    yum install --enablerepo=remi --enablerepo=remi-php56 php php-fpm

    因为我的php安装的是5.6的,所以的指定这个源里面安装php-fpm,不然一直报错

    修改php配置文件
    vi /etc/php.ini
    修改成0(这个配置值说是不安全的设置,参考网址:http://www.laruence.com/2010/05/20/1495.html)

    cgi.fix_pathinfo=0
    修改配置文件

    vim /etc/nginx/conf.d/default.conf

    server {
    listen 80;
    server_name www.scchary.com;
    root /home/samba1/public_html;
    #charset koi8-r;
    #access_log /var/log/nginx/log/host.access.log main;

    location / {
    #root /usr/share/nginx/html;
    #root /home/samba1/public_html;
    index index.php index.html index.htm;
    }

    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ .php$ {
    # proxy_pass http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ .php$ {
    #root /home/samba1/public_html;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /.ht {
    # deny all;
    #}
    }
    修改上面配置文件的时候,运行php文件的时候,老是显示没有找到,后来在这里找到了答案,参考网址http://www.nginx.cn/562.html

    server {
    listen [::]:80;
    server_name example.com www.example.com;
    access_log /var/www/logs/example.com.access.log;

    location / {
    root /var/www/example.com;
    index index.html index.htm index.pl;
    }

    location /images {
    autoindex on;
    }

    location ~ .php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /var/www/example.com$fastcgi_script_name;
    include fastcgi_params;
    }
    }
    这个配置中有很多不合理的地方,其中一个明显的问题就是root指令被放到了location / 块。如果root指令被定义在location块中那么该root指令只能对其所在的location生效。其它locaiont中没有root指令,像location /images块不会匹配任何请求,需要在每个请求中重复配置root指令来解决这个问题。因此我们需要把root指令放在server块,这样各个location就会继承父server块定义的$document_root,如果某个location需要定义一个不同的$document_root,则可以在location单独定义一个root指令。

    另一个问题就是fastCGI参数SCRIPT_FILENAME 是写死的。如果修改了root指令的值或者移动文件到别的目录,php-fpm会返回“No input file specified”错误,因为SCRIPT_FILENAME在配置中是写死的并没有随着$doucument_root变化而变化,我们可以修改SCRIPT_FILENAME配置如下:

    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    所以我们不能忘记在server块中配置root指令,不然$document_root的值为空,只会传$fastcgi_script_name到php-fpm,这样就会导致“No input file specified”错误。

    最后在测试php文件里面输出phpinfo的时候,出现了一个未定义时区的错误,修改了配置文件还是报错,最后重启了下php-fpm就好了

    ------------------------------

     本人微信公众帐号: 心禅道(xinchandao)

    本人微信公众帐号:双色球预测合买(ssqyuce)

  • 相关阅读:
    架构师维度理解 程序=数据+算法
    vuejs 中 select 动态填充数据,后台的数据
    vuejs 的错误代码,有助于理解
    graphviz 绘制架构图
    graphviz 布局和子图,表格教程
    graphviz layer 教程(非布局)
    待学习
    Linux进程管理
    TCP连接的11种状态,三次握手四次挥手原因
    Linux基本命令使用(三)
  • 原文地址:https://www.cnblogs.com/zdz8207/p/php-centos-uninstall-install.html
Copyright © 2011-2022 走看看