Moved Laravel project from Apache to Nginx

非 Y 不嫁゛ 提交于 2019-12-25 06:37:00

问题


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>

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


回答1:


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;
    }
}


来源:https://stackoverflow.com/questions/39040385/moved-laravel-project-from-apache-to-nginx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!