- First, make sure the Ubuntu Repo. is up to date.
sudo apt-get update
- Check if Nginx is install in you machine:
nginx -v
- If the previous command didn't return the Nginx version, then it means Nginx is not installed. Try to install it by following command:
sudo apt-get install nginx
- Goto to this directory
cd /etc/nginx/sites-available
- Copy the default config file and change
example
to your project name. Make sure the extention is.conf
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/example.conf
Modify the .conf
file. Here is an example file
- Now that we have our server block files, we need to enable them. Create the symbolic link from the
.conf
file tosites-enabled
directory. Nginx reads them during startup
sudo ln -s /etc/nginx/sites-available/laravel.test.conf /etc/nginx/sites-enabled/
- If you need to check the link, type this comand in terminal:
ls -l /etc/nginx/sites-enabled/
- (Optional) Increase
server_names_hash
innginx.conf
file by uncommentingserver_names_hash_bucket_size 64;
line. In order to open the config file, tyoe this command:
sudo nano /etc/nginx/nginx.conf
- Now, add the virtual host to the system by modifying
hosts
file and adding this line:
127.0.0.1 www.example.test example.test
System hosts config file is accessible with this command:
sudo nano /etc/hosts
- Restart nginx
sudo systemctl restart nginx
sudo service nginx restart
- Check the syntax for nginx config files
sudo nginx -t
-
Install
php 7.1
and common modules in your machine. -
Make sure php is working with Nginx. Install
php-fpm
sudo apt-get install php-fpm php-mysql
- Modify the
php.ini
and enablecgi.fix_pathinfo=0
and set it to ZERO. In order to do this, type this command: (You will find it in line 775)
sudo nano /etc/php/7.1/fpm/php.ini
- Restart the
php-fpm
sudo systemctl restart php7.1-fpm
- If you need to change thee ownership of a directory to the current user:
sudo chown -R $USER:$USER /var/www/example.test
- Change the
www
direcotry permission for development server
sudo chmod -R 755 /var/www