Are you ready to launch your own WordPress site with the power of LEMP at your fingertips? Ubuntu 24.04 is your playground, and this guide will walk you through setting it all up. Whether you’re a newbie web developer or a seasoned pro, getting a solid WordPress setup is crucial for smooth and speedy website performance.
The LEMP stack—comprising Linux, Nginx, MySQL, and PHP—is a robust and efficient choice for hosting WordPress. It’s the backbone many have turned to for its speed and light footprint. With this setup, your site will be ready to handle traffic like a pro from day one.
This tutorial offers clear, step-by-step instructions to get your WordPress site up and running. In no time, you’ll move from just reading about awesome sites to creating one yourself. So, roll up your sleeves, fire up Ubuntu 24.04, and let’s dive into the world of LEMP-powered WordPress wonders!
Installing LEMP Stack on Ubuntu 24.04
Getting the LEMP stack up and running on your Ubuntu 24.04 server is your first mission. Let’s break it down.
First, update your package manager to ensure you have the latest resources. Open your terminal and run:
sudo apt update && sudo apt upgrade -yNext, let’s install Nginx. This web server will handle HTTP requests like a champ. Type:
sudo apt install nginx -yMake sure it’s running by checking its status:
sudo systemctl status nginxNow, we need to get MySQL, the database system where your WordPress data will reside. Download and install it using:
sudo apt install mysql-server -ySecure your MySQL installation with:
sudo mysql_secure_installationWith your database set up, it’s time to install PHP, the server-side scripting language WordPress loves. Execute:
sudo apt install php-fpm php-mysql -yNow Nginx, MySQL, and PHP are in place, collaborate to deliver website magic. But we’re not done yet; configuring your LEMP stack comes next to ensure they work seamlessly together!
Downloading and Configuring WordPress
First, head over to the WordPress website and grab the latest version. You can download it directly to your server with this command:
wget https://wordpress.org/latest.tar.gzUnpack the tar file to extract the WordPress directory:
tar -xvzf latest.tar.gzThen, move the extracted files to your web server’s root directory. This is typically /var/www/html:
sudo mv wordpress/ /var/www/html/Make sure that Nginx can access the WordPress directory. Set the right permissions:
sudo chown -R www-data:www-data /var/www/html/wordpressNow, let’s prepare for site customization by creating a configuration file. Copy the sample config file:
cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.phpSecuring Database for WordPress
Log into your MySQL shell:
sudo mysql -u root -pCreate a new database for WordPress and a user with appropriate privileges. Type in:
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;Replace 'password' with a strong, unique password to secure your database.
Open wp-config.php in your favorite text editor and update the database details under the MySQL settings section:
define('DB_NAME', 'wordpress');
define('DB_USER', 'wp_user');
define('DB_PASSWORD', 'your_password');
define('DB_HOST', 'localhost');Configuring Virtual Host for WordPress
Time to tell Nginx where to find your WordPress files. Open a new configuration file:
sudo nano /etc/nginx/sites-available/wordpressPaste in the following template, adjusting the server name with your domain or server IP:
server {
listen 80;
server_name example.com;
root /var/www/html/wordpress;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php-fpm.sock;
}
location ~ /.ht {
deny all;
}
}Link this site configuration into the sites-enabled directory to enable it:
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/Test for syntax errors:
sudo nginx -tIf all goes well, reload Nginx to apply the changes:
sudo systemctl reload nginxYour configuration is now ready to power your brand-new WordPress site!
Adjusting Firewall Settings for WordPress
Before visitors can access your WordPress site, you’ll need to ensure that your firewall rules are good to go. First, check if the Uncomplicated Firewall (UFW) is active on your Ubuntu system:
sudo ufw statusIf it’s not running, enable it:
sudo ufw enableNext, you’ll need to allow HTTP and HTTPS traffic through the firewall. These protocols let users securely browse and interact with your site:
sudo ufw allow 'Nginx Full'This command will allow both ports 80 (HTTP) and 443 (HTTPS), enabling secure and non-secure traffic to reach your server.
Double-check to make sure these rules are in place and working properly:
sudo ufw statusYour firewall should now list both ports as allowable traffic options.
With these settings adjusted, your WordPress site is protected from most external threats, yet available for the world to see. Continue managing your firewall settings for added security as your site grows or changes. You’re all set to move forward!

Conclusion
And there you have it—a complete guide to setting up WordPress with the LEMP stack on Ubuntu 24.04! By following these steps, you’ve created a solid foundation for your website, combining speed, security, and efficiency.
While the installation might seem detailed, each step is a crucial piece of the puzzle. You now have the tools to host a dynamic website and the knowledge to manage it effectively.
Remember, maintaining your WordPress site is just as important as setting it up. Keep an eye on updates, back up your data regularly, and continually optimize for performance.
Congratulations on embarking on this exciting journey. Your WordPress site is ready to shine! Keep exploring and customizing to unlock its full potential. Happy blogging!




