Introduction
WordPress is an open-source content management system (CMS) that allows you to easily create and manage websites and blogs. This guide will show you how to install WordPress on a LAMP server.
Prerequisites
- An Ubuntu server with LAMP stack installed.
- A user with sudo privileges.
- A domain pointed to your server (optional but recommended).
Step 1: Create a Database for WordPress
Access MySQL:
sudo mysql -u root -p
Create the database and user for WordPress:
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'your_secure_password'; GRANT ALL ON wordpress.* TO 'wp_user'@'localhost'; FLUSH PRIVILEGES; EXIT;
Step 2: Install Required PHP Extensions
Install the necessary PHP extensions:
sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc -y
Restart Apache to load the new extensions:
sudo systemctl restart apache2
Step 3: Download WordPress
Navigate to the /tmp directory and download the latest version of WordPress:
cd /tmp curl -LO https://wordpress.org/latest.tar.gz tar xzvf latest.tar.gz
Step 4: Configure WordPress
Copy the WordPress files to the web server’s root directory:
sudo cp -a /tmp/wordpress/. /var/www/html
Set the correct permissions:
sudo chown -R www-data:www-data /var/www/html sudo find /var/www/html -type d -exec chmod 755 {} \; sudo find /var/www/html -type f -exec chmod 644 {} \;
Step 5: Configure the wp-config.php File
Generate the unique security keys:
curl -s https://api.wordpress.org/secret-key/1.1/salt/
Copy the output.
Rename the configuration file:
cd /var/www/html sudo mv wp-config-sample.php wp-config.php
Edit wp-config.php:
sudo nano wp-config.php
Enter the database information and paste the security keys.
Step 6: Complete the Installation via Browser
Open your browser and navigate to http://your_domain or http://your_server_ip. Follow the on-screen instructions to complete the installation.
Conclusion
You have successfully installed WordPress on your LAMP server. You can now start customizing your site.