Installing WordPress on Ubuntu involves a series of steps, including setting up a web server, a database, and configuring WordPress itself. Here’s a general guide for installing WordPress on Ubuntu using Apache, MySQL, and PHP (LAMP stack). Before you start, make sure your Ubuntu system is up to date:
sudo apt update
sudo apt upgrade
Now, follow these steps:
Step 1: Install Apache
sudo apt install apache2
Step 2: Install MySQL
sudo apt install mysql-server
During the installation, you will be prompted to set a password for the MySQL root user. Make sure to remember this password.
Step 3: Install PHP and required modules
sudo apt install php libapache2-mod-php php-mysql
Step 4: Configure Apache to use PHP
sudo nano /etc/apache2/mods-enabled/dir.conf
Move index.php
to the beginning of the DirectoryIndex line, so it looks like this:
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
Save and exit.
Step 5: Restart Apache
sudo systemctl restart apache2
Step 6: Create a MySQL Database and User for WordPress
Log in to MySQL as the root user:
mysql -u root -p
Create a new database:
CREATE DATABASE wordpress;
Create a new user and set a password:
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'your_password';
Grant privileges to the user:
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
Flush privileges and exit:
FLUSH PRIVILEGES;
EXIT;
Step 7: Download and Configure WordPress
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
sudo cp -r wordpress/* /var/www/html/
sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/
Step 8: Configure WordPress
cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
sudo nano /var/www/html/wp-config.php
Edit the database connection settings with the MySQL database details you created earlier:
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpressuser');
define('DB_PASSWORD', 'your_password');
define('DB_HOST', 'localhost');
Step 9: Set Up WordPress
Open your web browser and go to http://your_server_IP_or_domain/
. Follow the WordPress installation wizard.
That’s it! You should now have WordPress installed on your Ubuntu server.