How can I serve Laravel project on nginx on macOS?

  laravel, nginx

I created Laravel project with sudo composer create-project laravel/laravel MyProject --prefer-dist
command in “/Users/vala/Documents/laravel/” directory. Then I ran these commands:

sudo chown -R _www:_www /Users/vala/Documents/laravel/MyProject/
sudo chmod -R 755 /Users/vala/Documents/laravel/MyProject/

Then I create a file called “laravel” in “/usr/local/etc/nginx/sites-available/” and write text below ing it:

server {
  listen 80;
  listen [::]:80;
  root /Users/vala/Documents/laravel/MyProject/public;
  index  index.php index.html index.htm;

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

  location ~ .php$ {
     try_files $uri =404;
     fastcgi_split_path_info  ^(.+.php)(/.+)$;
     fastcgi_index            index.php;
     fastcgi_pass             unix:/var/run/php/php7.1-fpm.sock;
     include                  fastcgi_params;
     fastcgi_param   PATH_INFO       $fastcgi_path_info;
     fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;


Then I ran sudo ln -s /usr/local/etc/nginx/sites-available/laravel /usr/local/etc/nginx/sites-enabled/ and after that I ran these commands:

launchctl unload /usr/local/cellar/nginx/1.17.8/homebrew.mxcl.nginx.plist
launchctl load /usr/local/cellar/nginx/1.17.8/homebrew.mxcl.nginx.plist

But when I open “” on my browser my project doesn’t show up.

What did I miss?

Source: Laravel StackOverflow

Leave a Reply