TL;DR: Install and configure WordPress on Ubuntu 22.04 by first setting up a LAMP stack (Linux, Apache, MySQL, PHP), then downloading WordPress, creating a database, and completing the web-based installation wizard.
Prerequisites and Server Preparation
Before diving into the installation, ensure you have a fresh installation of Ubuntu 22.04 with sudo privileges. You must update your package manager to ensure all software is current. Run sudo apt update followed by sudo apt upgrade to apply the latest security patches and software improvements. This step is crucial for maintaining a secure and stable environment for your new website.
Installing the LAMP Stack
WordPress requires a web server, a database management system, and a server-side scripting language. The LAMP stack provides this foundation. First, install Apache by running sudo apt install apache2. Start the service and enable it to start on boot using sudo systemctl start apache2 and sudo systemctl enable apache2. Next, install MySQL with sudo apt install mysql-server. Run the security script sudo mysql_secure_installation to set a root password and remove anonymous users. Finally, install PHP and necessary modules with sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-intl php-mbstring php-xmlrpc php-zip. Restart Apache to apply changes using sudo systemctl restart apache2.
Configuring the Database
Access the MySQL shell by typing sudo mysql. Create a new database for WordPress, for example, named wordpress, using the command CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;. Create a dedicated user and assign privileges with CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'strong_password'; and GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost';. Flush privileges and exit with FLUSH PRIVILEGES; and EXIT;.
Downloading and Setting Up WordPress
Download the latest WordPress package using sudo wget http://wordpress.org/latest.tar.gz. Extract the archive with sudo tar xzvf latest.tar.gz. Move the files to the web root directory: sudo mv wordpress/* /var/www/html/. Set proper ownership and permissions by running sudo chown -R www-data:www-data /var/www/html and sudo chmod -R 755 /var/www/html. Navigate to your server’s IP address in a web browser to complete the final configuration steps, entering your database details when prompted.
FAQ
Q: How do I secure my WordPress installation?
A: Install a security plugin like Wordfence, keep WordPress and plugins updated, and use strong passwords for all user accounts.
If you want to dig deeper, check out our guide on 10 Proven Business Strategies to Boost Your Growth in 2024.
Q: What should I do if I forget my MySQL root password?
A> Reset the MySQL root password by restarting the service with sudo systemctl stop mysql, starting it in safe mode, and resetting the password via the command line.
Q: Can I use Nginx instead of Apache?
A> Yes, you can use Nginx by installing the LEMP stack instead of LAMP, but you will need to configure Nginx specifically for WordPress rewriting rules.

Leave a Reply