In today’s digital age, having a strong online presence is essential for businesses and individuals alike. One of the most popular website-building tools available is WordPress. It provides a simple and effective way to share and build your story on the internet, even if you don’t know how to code. In this article, we will guide you through the process of installing WordPress with a LEMP (Linux, Nginx, MySQL, PHP) stack on Ubuntu 23.04.
Prerequisites
Before we dive into the installation process, there are a few prerequisites you need to have in place:
- Root access to your Ubuntu 23.04 server: Ensure that you have root access to your server or have administrative privileges.
- LEMP Stack installed and running: Make sure you have already installed and configured the LEMP stack on your Ubuntu server. If you haven’t done so, you can refer to our guide on how to set up a LEMP stack for detailed instructions.
Creating the Database
The first step in installing WordPress is to create a new database. To do this, follow these steps:
- Log into MySQL using the following command:
mysql -u root -p
. You will be prompted to enter your MySQL root password. - Once logged in, create a new database by running the command:
CREATE DATABASE wordpress_db;
. - Next, create a new MySQL user account that will be used to operate on WordPress’s new database. Use the following command, replacing ‘password’ with a secure password:
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';
. - Link the user and database together by granting the user access to the database with the following command:
GRANT ALL PRIVILEGES ON wordpress_db.* to wordpress_user@'localhost';
. - Flush the privileges so that MySQL recognizes the user permissions:
FLUSH PRIVILEGES
. - Exit the MySQL command prompt by typing
.exit
.
Downloading and Installing WordPress
Now that the database is set up, it’s time to download and install WordPress on your server. Follow these steps:
- Download the latest version of WordPress by running the command:
wget -O /tmp/wordpress.tar.gz
https://wordpress.org/latest.tar.gz
. - Unzip the downloaded WordPress file using the command:
tar -xzvf /tmp/wordpress.tar.gz -C /var/www/html
. - Change the ownership of the WordPress site directory to the appropriate user and group by running:
chown -R www-data:www-data /var/www/html/wordpress
.
Creating a Server Block or vHost
To ensure proper configuration and access to your WordPress site, you need to create a server block (also known as a vHost) for your domain. Follow these steps:
- Create a new configuration file for your domain using your preferred text editor. For example:
vi /etc/nginx/sites-available/wp.domainhere.info
. - Replace ‘wp.domainhere.info’ with the actual domain name you want to use for your WordPress site.
- Insert the following content into the configuration file:
server { listen 80; listen [::]:80; server_name wp.domainhere.info; root /var/www/html/wordpress/; index index.php index.html index.htm index.nginx-debian.html; error_log /var/log/nginx/wp.domainhere.info_error.log; access_log /var/log/nginx/wp.domainhere.info_access.log; location / { try_files $uri $uri/ /index.php; } location ~ \.php$ { fastcgi_pass unix:/run/php/php8.1-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; include snippets/fastcgi-php.conf; } location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ { access_log off; log_not_found off; expires 360d; } location ~ /\.ht { access_log off; log_not_found off; deny all; } }
- Save and exit the file.
- Create a symbolic link of the configuration file in the
sites-enabled
directory with the following command:ln -s /etc/nginx/sites-available/wp.domainhere.info /etc/nginx/sites-enabled/
. - Remove the default Nginx server blocks to prevent automatic requests routing by running the command:
rm /etc/nginx/sites-available/default
.
Setting up SSL Certificate
Securing your WordPress site with an SSL certificate is crucial for protecting sensitive information and building trust with your visitors. Follow these steps to set up an SSL certificate:
- Install Certbot specific to Nginx by running the command:
snap install --classic certbot
. - Obtain a certificate and automatically configure Nginx to serve it by running the command:
certbot --nginx -d wp.domainhere.info -d wp.domainhere.info
. Replace ‘wp.domainhere.info’ with your actual domain name. - Accept the terms of service when prompted.
- Certbot will save your certificate and key files at the respective locations.
- Verify that the SSL certificate is successfully installed by navigating to your website using
https://
and checking for the lock icon in the URL bar. - You can also use SSL Labs ‘SSL Server Test to ensure that your configuration is error-free.
Completing the Installation
With everything set up and configured, you are now ready to complete the WordPress installation process. Follow these steps:
- Open your web browser and navigate to your WordPress site using either
http://wp.domainhere.info
orhttp://IP_ADDRESS/wordpress
. Replace ‘wp.domainhere.info’ or ‘IP_ADDRESS’ with your actual domain name or server IP address. - Click on the “Run the installation” button to start the WordPress installation process.
- Provide the requested information, including your site title, username, password, and email address.
- Once you have entered the required details, click on the “Install WordPress” button.
- Congratulations! You have successfully installed WordPress with a LEMP stack on your Ubuntu 23.04 server.
Conclusion
Installing WordPress with a LEMP stack on Ubuntu 23.04 is a straightforward process that allows you to build and manage your website with ease. By following the steps outlined in this guide, you can create a powerful online presence and share your story with the world.
At Shape.host, we specialize in providing reliable and scalable cloud hosting solutions, including Linux SSD VPS. Our services empower businesses to harness the full potential of WordPress and other web applications. Contact us today to learn more about how we can help you elevate your online presence.