0 votes
in NGINX by
How to Install NGINX, PHP, MySQL, SSL & WordPress on Ubuntu

1 Answer

0 votes
Here are the steps to install NGINX, PHP, MySQL, SSL, and WordPress on Ubuntu:

Update your Ubuntu system:


Copy code

sudo apt update

sudo apt upgrade

Install NGINX:

Copy code

sudo apt install nginx

Install MySQL:

Copy code

sudo apt install mysql-server

Install PHP and the required extensions:

Copy code

sudo apt install php-fpm php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc

Create a new MySQL database and user:


Copy code

sudo mysql -u root -p


CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';


Replace wordpressuser and password with your desired values.

Configure NGINX to use PHP:


Copy code

sudo nano /etc/nginx/sites-available/default

Replace the contents of the file with the following:


Copy code

server {

    listen 80 default_server;

    listen [::]:80 default_server;

    root /var/www/html;

    index index.php index.html index.htm;

    server_name example.com;

    location / {

        try_files $uri $uri/ /index.php?$args;


    location ~ \.php$ {

        include snippets/fastcgi-php.conf;

        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;


    location ~ /\.ht {

        deny all;



Replace example.com with your domain name.

Enable SSL:


Copy code

sudo add-apt-repository ppa:certbot/certbot

sudo apt update

sudo apt install python3-certbot-nginx

sudo certbot --nginx -d example.com -d www.example.com

Follow the instructions to generate SSL certificates.

Install WordPress:


Copy code

cd /tmp

curl -O https://wordpress.org/latest.tar.gz

tar xzvf latest.tar.gz

sudo mv wordpress /var/www/html/

sudo chown -R www-data:www-data /var/www/html/wordpress

Complete the WordPress installation:

Open your web browser and navigate to your domain name. Follow the instructions to complete the WordPress installation, providing the MySQL database and user information created earlier.

That's it! You should now have NGINX, PHP, MySQL, SSL, and WordPress installed on your Ubuntu system.

Related questions

0 votes
asked Sep 5, 2019 in NGINX by Robin
0 votes
asked Feb 3, 2020 in NGINX by Tate