将Laravel项目从Apache移至Nginx [英] Moved Laravel project from Apache to Nginx

查看:204
本文介绍了将Laravel项目从Apache移至Nginx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将laravel应用程序部署在centos服务器上,必须在httpd.conf中添加以下提到的行才能使它工作

I have deployed my laravel app on a centos server and I had to add below mentioned lines in httpd.conf to make it work

<Directory "/var/www/html/ezschedular2/public">
  Allowoverride All
</Directory>

我们现在决定使用nginx,这些行的替代内容是什么?我必须在文件夹/etc/nginx/conf.d

We have decided to use nginx now, what is the alternate of these lines? I have to add alternate of these lines on default.conf in folder /etc/nginx/conf.d

推荐答案

这是我的Laravel Nginx配置.根据您的需要更改变量

This is my nginx config for Laravel. Change variable suit your need

server {
    listen 80;
    server_name YOURSERVERNAME_OR_IP;
    root YOUR_PATH_TO_LARAVEL_PUBLIC_FOLDER;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

这篇关于将Laravel项目从Apache移至Nginx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆