zoukankan      html  css  js  c++  java
  • centos7安装并配置nginx+php

    1. 安装nginx

    yum install nginx

    1. 设置nginx开启起动

    systemctl start nginx

    1. 测试
      访问http://你的域名或IP/
    2. 查看nginx安装位置

    whereis nginx

    nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx /usr/share/man/man3/nginx.3pm.gz /usr/share/man/man8/nginx.8.gz

    1. 安装php

    yum install php php-mysql php-fpm

    安装过程中经常会见到如下问题:
    2:postfix-2.10.1-6.el7.x86_64 有缺少的需求 libmysqlclient.so.18()(64bit)
    2:postfix-2.10.1-6.el7.x86_64 有缺少的需求 libmysqlclient.so.18(libmysqlclient_18)(64bit)
    解决方法:
    把php-mysql换成php-mysqlnd
    即执行

    yum install php php-mysqlnd php-fpm

    1. 配置php处理器

    vim /etc/php.ini

    查找cgi.fix_pathinfo
    将 ;cgi.fix_pathinfo=1改为cgi.fix_pathinfo=0
    7. 配置www.conf

    vim /etc/php-fpm.d/www.conf


    user = nobody
    group = nobody
    改为
    user = nginx
    group = nginx
    前提是已经创建了nginx用户和nginx组。
    8. 起动php-fpm

    systemctl start php-fpm

    1. 设置php-fpm开机启动

    systemctl enable php-fpm

    1. 配置nginx
      打开/etc/nginx/conf.d/default.conf,如果不存在则创建
      粘贴
      server {
      listen 80;
      server_name server_domain_name_or_IP;

      note that these lines are originally from the "location /" block

      root /usr/share/nginx/html;
      index index.php index.html index.htm;

      location / {
      try_files $uri $uri/ =404;
      }
      error_page 404 /404.html;
      error_page 500 502 503 504 /50x.html;
      location = /50x.html {
      root /usr/share/nginx/html;
      }

      location ~ .php$ {
      try_files $uri =404;
      root /usr/share/nginx/html;
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include fastcgi.conf;
      }
      }

    2. 重起nginx

    systemctl restart nginx

    1. 测试php
      创建/usr/share/nginx/html/index.php

    /usr/share/nginx/html/info.php

    输入以下内容:

    访问http://你的IP/index.php,正常情况下会出现

  • 相关阅读:
    [POJ 2096]Collecting Bugs
    [SPOJ 375]Query on a tree
    [BZOJ 4423][AMPPZ2013]Bytehattan
    [BZOJ 2038][2009国家集训队]小Z的袜子(hose)
    [SDOI 2017]数字表格
    [NOI 2010]能量采集
    [HNOI 2014]世界树
    [HNOI 2016]序列
    [HNOI 2016]大数
    [HEOI 2014]大工程
  • 原文地址:https://www.cnblogs.com/cglWorkBook/p/5431571.html
Copyright © 2011-2022 走看看