Installing WordPress on a LAMP Stack in Ubuntu 24.04

WordPress, the most popular content management system (CMS), offers flexibility and ease of use for website creation and management. Installing WordPress on a Linux, Apache, MySQL, and PHP (LAMP) stack in Ubuntu 24.04 requires a series of steps to ensure a successful setup. This tutorial guides you through installing a LAMP stack, configuring Apache for WordPress, setting up a MySQL database, and finally, installing WordPress itself.

In this tutorial you will learn:

  • How to install a LAMP stack on Ubuntu 24.04
  • How to configure Apache for a new WordPress site
  • How to create a MySQL database for WordPress
  • How to download and configure WordPress
Installing WordPress on a LAMP Stack in Ubuntu 24.04
Installing WordPress on a LAMP Stack in Ubuntu 24.04
CategoryRequirements, Conventions or Software Version Used
SystemUbuntu 24.04 LTS
SoftwareApache, MySQL, PHP (LAMP stack)
OtherInternet connection for downloading packages and WordPress
Conventions# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Step-by-Step WordPress Installation on Ubuntu 24.04

  1. Install LAMP Stack: Start by installing the LAMP stack on your Ubuntu 24.04 server. Follow the detailed tutorial available at linuxconfig.org for instructions on how to accomplish this.
  2. Configure Apache for WordPress: To prepare Apache for WordPress, create a new site configuration.$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/wordpress.conf $ sudo nano /etc/apache2/sites-available/wordpress.confModify the DocumentRoot to /var/www/wordpress and set ServerName to your domain or localhost for local setups. Add a directory block to enable .htaccess overrides, then enable the site and disable the default site in Apache. Don’t forget to enable mod_rewrite to support permalink settings in WordPress.Configure Apache for WordPressConfigure Apache for WordPress$ sudo a2ensite wordpress.conf $ sudo a2dissite 000-default.conf $ sudo a2enmod rewrite $ sudo systemctl reload apache2
  3. Download and Prepare WordPress: Download the latest version of WordPress and extract it to your web directory. Adjust the ownership to ensure Apache can write to the directory.$ wget -O- https://wordpress.org/latest.tar.gz | sudo tar -xz -C /var/www $ sudo chown -R www-data:www-data /var/www/wordpressDownload and Prepare WordPressDownload and Prepare WordPress
  4. Create a MySQL Database for WordPress: Set up a dedicated MySQL database and user for WordPress.$ sudo mysql mysql> CREATE DATABASE wordpress; mysql> CREATE USER `admin`@`localhost` IDENTIFIED WITH mysql_native_password BY ‘yourpass’; mysql> GRANT ALL ON wordpress.* TO `admin`@`localhost`; mysql> FLUSH PRIVILEGES; mysql> exitIn this step, we initiated the MySQL command line as the root user to perform database operations. A new database named ‘wordpress’ was created to store the site’s data. We then created a new user named ‘admin‘ and granted this user full access to the ‘wordpress‘ database, ensuring WordPress can interact with its database securely. Setting the user’s authentication method to ‘mysql_native_password’ and defining a password ‘ yourpass‘ ensures that the connection is secure. The ‘FLUSH PRIVILEGES’ command applies these changes immediately, allowing the new user to access the database as specified. This setup is crucial for WordPress to function correctly, as it needs a database to store all website content, including posts, pages, comments, and settings.https://59141d7ba71b6c2e83474e269d7ce5fa.safeframe.googlesyndication.com/safeframe/1-0-40/html/container.html
  5. Install WordPress: Navigate to your domain (e.g., http://wp.linuxconfig.org) and follow the WordPress installation wizard. Use the database credentials created in the previous step to set up WordPress.WordPress Ready - Front EndWordPress Ready – Front EndWordPress Back EndWordPress Back End

Conclusion

By following these steps, you will have successfully installed WordPress on a LAMP stack in Ubuntu 24.04. This setup provides a robust platform for hosting your WordPress site, offering flexibility, performance, and control over your web environment.

LEAVE A RESPONSE