Install nginx server and configure a website

In this toturial you will learn how to install and configure nginx server and run a website on virtual host. According to the nginx website, virtual hosts are called Server Blocks on the nginx.

Install nginx on the ubuntu server

Start nginx server

Install php-fpm which is used for the communication with nginx and php.

You should edit and fix some lines in php.ini

The commands are

Change the following line, if it is different

Restart php-fpm

Create a folder for nginx project

chnage the ownership of that project folder

Set permissions for that folder

Create a file inside that project folder

Copy the default ngnix block configuration for this project

Edit this configuration file

Replace the code below and with your domain.


Now enable the available block by executing this command

Restart the server to see the changes

If you get a error “Your PHP installation appears to be missing the MySQL extension which is required by WordPress.”

Remove php-mysql and install it again.

Your website should working perfectly with nginx server.