pranayaryal
3/16/2017 - 5:04 PM

CONFIGURE NGINX FOR YOUR PROJECT

CONFIGURE NGINX FOR YOUR PROJECT

 Create a .conf file in /etc/nginx/sites-available
 for example type touch blog.app.conf

Copy and paste the code below to blog.app.conf
Be sure to change the server_name to blog.app and point the public directory properly to your laravel project's project directory

Then type sudo ln -s /etc/nginx/sites-available/blog.app.conf /etc/nginx/sites-enabled/ to create a symbolic link. Be sure to write out the full path
Check if there are any errors inside sites-enabled/ folder. If there are errors remove the conf file and try again.
 
 Then type sudo service nginx restart
 You should be good to go. By now I hope you have added it to your project url to your /etc/hosts file
 
 
 server {
      listen 80;
  
      root /home/oem/Code/sar-upgrade/public;
      index index.html index.htm index.php;
  
      server_name sar.app;
  
      location @rewrite {
          rewrite ^/(.*)$ /index.php?_url=/$1;
      }
  
      location / {
          try_files $uri $uri/ @rewrite;
      }
  
      location ~ \.php$ {
          try_files $uri =404;
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include fastcgi_params;
      }
  
      location /doc/ {
          alias /usr/share/doc/;
          autoindex on;
          allow 127.0.0.1;
          deny all;
      }
  
      location ~/\.ht {
          deny all;
      }
  }
  
  
  If you get '404 not found' error then please ensure and check doubly that your path next to 'root' is correct. I ran into problems because of incorrect path