美文网首页
折腾LNMP: Nginx + thinkphp5

折腾LNMP: Nginx + thinkphp5

作者: AbbyLC | 来源:发表于2017-12-24 23:15 被阅读0次

重装多遍。记录。


一、自己纯装

Nginx 搭配php 要搭配 有php-fpm的。
配置Nginx,样例:


二、 腾讯云全能镜像

解决thinkphp5 + Nginx 访问出现Access denied的方法:

参考原文

  1. 配置权限
    chmod -R 777 目录名
  2. 改php.ini文件
  • 将cgi.fix_pathinfo的值改成1
    vim 进入对应文件 /cgi.fix到这个地方,修改成cgi.fix_pathinfo=1

  • 到nginx.conf中,添加fastcgi_split_path_info ^(.+\.php)(/.+)$

    图示
  • 到配置域名解析的文件下(一般是以域名命名的配置文件)。加上这三句:

fastcgi_split_path_info ^(.+\.php)(/.+)$;  
fastcgi_param   PATH_INFO   $fastcgi_path_info;  
fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;  
图示
  • 最后重启nginx和php-fpm
 systemctl restart nginx.service
 systemctl restart php

nginx.conf 样例:

######################## default ############################
  server {
  listen 80;
  server_name _;
  access_log /data/wwwlogs/access_nginx.log combined;
  root /data/wwwroot/default;
  index index.html index.htm index.php;
  location /nginx_status {
    stub_status on;
    access_log off;
    allow 127.0.0.1;
    deny all;
    }
  location ~ [^/]\.php(/|$) {
    #fastcgi_pass remote_php_ip:9000;

# LC add
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
##

    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi.conf;

# LC add
    fastcgi_param   PATH_INFO   $fastcgi_path_info;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
##
    }
  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
    expires 30d;
    access_log off;
    }
  location ~ .*\.(js|css)?$ {
    expires 7d;
    access_log off;
    }
  location ~ /\.ht {
    deny all;
    }
  }

########################## vhost #############################
  include vhost/*.conf;
}


测试

我的nginx的root路径是 /data/wwwroot/default,因此摆一个名字为phpinfo.php,内容为:

<?php
  phpinfo() 
?>

的php文件。
然后访问[公网ip]/phpinfo.php
可以看见下面的信息:

php信息
这个信息表很重要!
配置mongodb时可以在这里看到是否配置好 mongodb的php扩展了。

相关文章

  • 折腾LNMP:mongoDB的php扩展

    前事提要:折腾LNMP: Nginx + thinkphp5折腾LNMP:mongoDB折腾LNMP:robo 3...

  • 折腾LNMP: Nginx + thinkphp5

    重装多遍。记录。 一、自己纯装 Nginx 搭配php 要搭配 有php-fpm的。配置Nginx,样例: 二、 ...

  • LNMP环境的搭建

    lnmp环境的搭建 lnmp是黄金搭档,是linux、nginx、mysql、php的合称。昨天刚好折腾了下,装成...

  • lnmp1.4环境下运行thinkphp5

    1、lnmp 1.4安装完成后,部署thinkphp5的一个应用目录启动nginx后发现500 2.查看500的原...

  • 源码安装LNMP centos+nginx+php7.4+mys

    lnmp : linux(centos7.4)+nginx+php7.4 +mysql 写在前面的 最近又来折腾自...

  • LNMP的安装及配置

    LNMP LNMP是四个单词的首字母合称,Linux+Nginx+MySQL+PHP。 安装Nginx nginx...

  • LNMP基本架构

    介绍LNMP nginx+mysql+php lnmp最常见的架构 L linux --系统平台N nginx ...

  • 小知识

    LNMP LNMP = Linux + Nginx + Mysql + PHP LAMP LAMP = Linux...

  • 部署LNMP

    一.LNMP简介 1.LNMP的组成 LNMP分别代表Linux、 Nginx、MySQL和PHP。 2.LNMP...

  • 折腾LNMP:robo 3t 连接mongodb

    前面的工作都要做好了: 装nginx+php-fpm。 装mongodb,并能配置好。 可以参考一下:折腾LNMP...

网友评论

      本文标题:折腾LNMP: Nginx + thinkphp5

      本文链接:https://www.haomeiwen.com/subject/qkrkgxtx.html