Install WordPress with Nginx and Let’s Encrypt SSL on Ubuntu 22.04


WordPress is without doubt one of the most well liked web content platforms on the net. It is a loose, open-source content material control device that works smartly with virtually any internet internet hosting provider, making it one of the most perfect to put in and use for publishing on-line content material.

Regular internet internet hosting will not be enough for traffic-intensive internet sites. So, it might be highest in case you have Ubuntu VPS to put in WordPress.

Here, we can see the best way to set up WordPress with Nginx on Ubuntu 22.04.

Install LEMP Stack

Follow the beneath hyperlink to put in the LEMP stack for your Ubuntu 22.04 device for a WordPress set up.

Set up LEMP (Nginx, MariaDB, and PHP) on Ubuntu 22.04

Configure PHP for WordPress

The default PHP values will not be suitable for everybody, and you’ll want to exchange them according to the requirement. So, replace the /and so forth/php/8.1/fpm/php.ini report as in keeping with your requirement. You might get started with the beneath values for now and build up or lower the values each time required.

max_connection_time = 300

upload_max_filesize = 64M

post_max_size = 64M

sudo sed -i 's/^max_execution_time = .*/max_execution_time = 300/g' /and so forth/php/8.1/fpm/php.ini

sudo sed -i 's/^upload_max_filesize = .*/upload_max_filesize = 64M/g' /and so forth/php/8.1/fpm/php.ini

sudo sed -i 's/^post_max_size = .*/post_max_size = 64M/g' /and so forth/php/8.1/fpm/php.ini

Setup Nginx Server Block

We will get started with making a server block for a WordPress set up. Typically a server block comprises domains, report root, log location, rapid CGI, and so forth.

Assume the next,

Domain identify: holhol24.web, www.holhol24.web
Port No: 80
Document root: /usr/percentage/nginx/www.holhol24.web/html
Logs: /usr/percentage/nginx/www.holhol24.web/logs
Server block: /and so forth/nginx/conf.d/www.holhol24.web.conf

If you’ve got put in Nginx from the Ubuntu repository, you wish to have to create a server block configuration report underneath /and so forth/nginx/sites-available listing and WordPress recordsdata underneath the /var/www/html listing

First, create a  server block configuration report.

sudo nano /and so forth/nginx/conf.d/www.holhol24.web.conf

Then, position the next server block data into the above report. However, you could want to exchange the server_name , root, and fastcgi_pass main points as in keeping with your requirement.

server {
	server_name holhol24.web www.holhol24.web;
	root /usr/percentage/nginx/www.holhol24.web/html;

	index index.php index.html;

	access_log /usr/percentage/nginx/www.holhol24.web/logs/get right of entry to.log;
	error_log /usr/percentage/nginx/www.holhol24.web/logs/error.log;

	# Prevent get right of entry to to hidden recordsdata
	location ~* /.(?!well known/) {
		deny all;

	# Prevent get right of entry to to positive report extensions
	location ~.(ini|log|conf)$ {
		deny all;

        # Enable WordPress Permananent Links
	location / {
		try_files $uri $uri/ /index.php?$args;

	location ~ .php$ {
               come with fastcgi_params;
               fastcgi_intercept_errors on;
               fastcgi_pass unix:/run/php/php8.1-fpm.sock;
               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


Next, create a report root and logs listing.

sudo mkdir -p /usr/percentage/nginx/www.holhol24.web/html/

sudo mkdir -p /usr/percentage/nginx/www.holhol24.web/logs/

Then, check the Nginx configuration report with the beneath command.

sudo nginx -t

If you get the next message, the server block configurations are right kind.

nginx: the configuration report /and so forth/nginx/nginx.conf syntax is fine
nginx: configuration report /and so forth/nginx/nginx.conf take a look at is a hit

Finally, restart the Nginx and PHP-FPM products and services.

sudo systemctl reload nginx php8.1-fpm

If you don’t need to safe WordPress set up with a loose SSL certificates, continue at once to putting in WordPress.

Install Let’s Encrypt SSL Certificate

Skip this SSL set up if you’re putting in WordPress on a neighborhood device i.e, a pc or on a digital gadget.

Create DNS Record

Visit your area registrar portal and create an A and CNAME (not obligatory if you happen to do wish to use the www subdomain) document in your area. Typically you’ll have to make two data in your WordPress web content.

  1. Non-www Domain Name (Ex. holhol24.web) >> A document level on your server IP
  2. www Domain Name (Ex. www.holhol24.web) >> CNAME document level to holhol24.web


DNS Records

Install Certbot shopper

The Certbot shopper, which is helping us set up the Let’s Encrypt SSL certificates, is now accessible as a snap bundle for Ubuntu running device. So first, set up snapd daemon for your device.

sudo apt replace

sudo apt set up -y snapd

Then, replace snapd to the newest model.

sudo snap set up core && sudo snap refresh core

Finally, set up the Certbot shopper the use of the beneath command.

sudo snap set up --classic certbot

sudo ln -s /snap/bin/certbot /usr/bin/certbot

Install SSL Certificate

Use the beneath command to generate and set up the Let’s Encrypt SSL certificates for the Nginx internet server.

sudo certbot --nginx

1. Enter e-mail deal with to obtain notification on pressing renewal and safety notices
2. Type Y and press Enter to sign up with the ACME server
3. Type Y or N to obtain emails about EFF information, campaigns, and publication.
4. Certbot will mechanically come across the WordPress area and ask you permission to turn on HTTPS in your WordPress web content. Type 1 or suitable numbers separated through a comma in case you have a couple of internet sites.

Which names do you want to turn on HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: holhol24.web
2: www.holhol24.web
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the best numbers separated through commas and/or areas, or go away enter
clean to make a choice all choices proven (Enter 'c' to cancel): 1,2

Wait for the SSL set up to finish. You will now be capable of get right of entry to the web content with HTTPS.

Note: If you get right of entry to the web content now, you are going to get a 403 forbidden error since you are but to position WordPress recordsdata.

Redirect non-www HTTP requests to www HTTPS with Nginx

You might love to configure area redirection to redirect the visitors from the non-www HTTP web page to the WWW HTTPS web page, I.e., http://holhol24.web >> https://www.holhol24.web.

Auto-Renew SSL Certificate

The Certbot shopper has an auto-renewal serve as for renewing SSL certificate in the course of the systemd. So, you are going to no longer must renew the certificate manually.

Install WordPress with Nginx on Ubuntu 22.04

Create WordPress Database

First, login into MariaDB/MySQL database server.

sudo mysql -u root -p

Then, create the database for WordPress set up and the database consumer and password.


CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'wppassword';

GRANT ALL PRIVILEGES ON wpdatabase.* TO 'wpuser'@'localhost';


Download WordPress

First, obtain the newest model of the WordPress installer through the use of the next command.

curl -O

Then, extract the downloaded report.

tar -zxvf newest.tar.gz

And then, transfer the recordsdata on your web content report root listing.

sudo mv wordpress/* /usr/percentage/nginx/www.holhol24.web/html/

Next, replace the possession and a bunch of the WordPress listing.

sudo chown -R www-data:www-data /usr/percentage/nginx/www.holhol24.web/

Install WordPress

Open your browser and discuss with your WordPress web content area to accomplish the WordPress set up.


1. Choose the Installation Language and click on Continue

2. Click Let’s pass!

3. Enter the WordPress database main points after which click on Submit

4. Click Run the set up

5. Enter the WordPress web content data after which click on Install WordPress

6. Click Log In to get right of entry to the WordPress admin backend to regulate WordPress set up. Alternatively, you’ll be able to get right of entry to the WordPress backend through going to https://your-wordpress-website/wp-admin

Access WordPress Website

Now, it is possible for you to to get right of entry to the web page together with your area identify.


WordPress Website on Nginx
WordPress Website on Nginx


That’s All. I am hoping you’ve got discovered the best way to set up WordPress with Nginx on Ubuntu 22.04.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More