美文网首页laravel如何优雅的用Laravellaravel学习笔记
LNMP环境配置Laravel虚拟主机(补)

LNMP环境配置Laravel虚拟主机(补)

作者: 浅水码农 | 来源:发表于2019-05-09 10:18 被阅读0次

    哈喽小伙伴们,这篇呢主要是为了补充上一篇没写完的虚拟主机写的,感谢大家的喜欢,浅农会继续努力的。

    创建子配置文件

    我习惯性的将配置文件叫做主配置文件和子配置文件,主配置文件就是安装的时候就有的配置文件,即nginx.conf,那子配置文件呢就是我们创建项目需要的文件

    cd /etc/nginx/sites-available
    

    通过上一条命令,我们就到了nginx的默认子配置文件位置
    创建一个子配置文件

    touch laravel
    

    如果没有意外的话,这里会有两个文件

    default    laravel
    

    创建子配置文件成功

    配置创建的配置文件

    下面是我的配置文件

    server {
             listen 80;
             listen [::]:80 ipv6only=on;
    
             # Log files for Debugging
             access_log /var/log/nginx/laravel-access.log;
             error_log /var/log/nginx/laravel-error.log;
    
             # Webroot Directory for Laravel project
             root /var/www/jou/public;
             index index.php index.html index.htm;
    
             # Your Domain Name
             server_name laravel.co;
    
             location / {
                     try_files $uri $uri/ /index.php?$query_string;
             }
    
             # PHP-FPM Configuration Nginx
             location ~ \.php$ {
                     try_files $uri =404;
                     fastcgi_split_path_info ^(.+\.php)(/.+)$;
                     fastcgi_pass unix:/run/php/php7.2-fpm.sock;
                     fastcgi_index index.php;
                     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                     include fastcgi_params;
             }
     }
    
    引入子配置文件

    打开nginx.conf文件

    vim /etc/nginx/nginx.conf
    

    在末尾位置加上这句话

    include /etc/nginx/sites-enabled/*;
    

    细心的朋友可能发现了,对,这个在配置文件上面已经有了,所以就是说,配置完子配置文件后就相当于完成了,主配置文件不需要你修改。

    相关文章

      网友评论

        本文标题:LNMP环境配置Laravel虚拟主机(补)

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