ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

lnmp安装全流程

2021-07-15 09:32:02  阅读:202  来源: 互联网

标签:index 流程 lnmp location conf php 安装 fastcgi


下载安装包并安装

wget http://soft.vpser.net/lnmp/lnmp1.8.tar.gz -cO lnmp1.8.tar.gz && tar zxf lnmp1.8.tar.gz && cd lnmp1.8 && ./install.sh lnmp

其他按下一步提示

添加vhost

lnmp vhost add
其他按下一步提示

重点部分

进入 /usr/local/nginx/conf/vhost
vim www.test.com.conf

修改conf

server
    {
        listen 80;
        #listen [::]:80;
        server_name www.test.com.conf ;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/laravel/public;


        include y.conf;
        #error_page   404   /404.html;


        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }


#注意这里注释掉不然 报错500 ,因为引入了php 配置,其中有句 try_files 开启就有报错
        #include enable-php.conf;



#新增 支持laravel 优雅链接,在laravel 文档里有说明
        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }


#新增 支持php 的配置 
        location ~ \.php$ {
   #不能有下面这句 try_files ,不然报错500
           # try_files $uri /index.php =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;

  #这句注意 后面是.sock 不是127.0.0..1

            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;

    include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            
        }



#下面的默认不做修改

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }


        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }


        location ~ /.well-known {
            allow all;
        }


        location ~ /\.
        {
            deny all;
        }


        access_log  /home/wwwlogs/laravel.local.com.log;
    }

坑爹的地方

如果 是用 lnmp vhost add 命令 添加的虚拟域名

会在根目录生成   .user.ini

这个.user.ini 一定要删掉,不然怎么配置都是报错500



删除方法:
在 根目录,即 .user.ini 所在目录

chattr -i .user.ini

rm .user.ini

标签:index,流程,lnmp,location,conf,php,安装,fastcgi
来源: https://blog.csdn.net/weixin_40581279/article/details/118751484

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有