- AdminTCS
- 0 Comments
- 821 Views
Installing WordPress on a Linux VPS gives you full control over your website’s environment, enabling better performance and customization. Follow this step-by-step guide to install WordPress on your Linux VPS efficiently.
Prerequisites
Before starting, ensure you have:
- A VPS: Ensure your VPS meets the minimum requirements (1GB RAM, 1 CPU, 20GB storage).
- Operating System: Ubuntu 20.04 LTS or later.
- Root Access: Access to your VPS as a root user or a user with sudo privileges.
- Domain Name: A domain name pointing to your VPS IP address.
Step 1: Update Your Server
First, ensure your server’s package list and installed packages are up-to-date.
sudo apt update
sudo apt upgrade -y
Step 2: Install Apache Web Server
Apache is a popular and powerful web server. Install Apache using the following command:
sudo apt install apache2 -y
Start and enable Apache to run on boot:
sudo systemctl start apache2
sudo systemctl enable apache2
Step 3: Install MySQL
WordPress requires a database to store its data. Install MySQL server with:
sudo apt install mysql-server -y
Secure your MySQL installation:
sudo mysql_secure_installation
Step 4: Create a MySQL Database and User for WordPress
Log into MySQL and create a database and user for WordPress:
sudo mysql -u root -p
CREATE DATABASE wordpress;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 5: Install PHP
WordPress is written in PHP. Install PHP and the necessary extensions:
sudo apt install php php-mysql libapache2-mod-php php-cli php-cgi php-gd -y
Step 6: Download and Configure WordPress
Download the latest version of WordPress:
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
sudo mv wordpress /var/www/html/
Set the correct permissions for WordPress:
sudo chown -R www-data:www-data /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress
Step 7: Configure Apache for WordPress
Create an Apache configuration file for your WordPress site:
sudo nano /etc/apache2/sites-available/wordpress.conf
Add the following configuration:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/wordpress
ServerName example.com
ServerAlias www.example.com
<Directory /var/www/html/wordpress/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log
CustomLog ${APACHE_LOG_DIR}/wordpress_access.log combined
</VirtualHost>
Enable the WordPress site and the rewrite module:
sudo a2ensite wordpress.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
Step 8: Complete the WordPress Installation via Web Interface
Open your web browser and navigate to your WordPress site (e.g., http://example.com). You will be greeted by the WordPress setup page.
- Choose your language and click “Continue.”
- On the “Welcome” page, click “Let’s go!”
- Database Details: Enter the database name (
wordpress
), username (wordpressuser
), and the password you created earlier. The database host islocalhost
, and you can leave the table prefix aswp_
. - Click “Submit” and then “Run the installation.”
- Site Information: Enter your site title, username, password, and your email. Be sure to choose a strong password.
Click “Install WordPress” to complete the installation. Once done, log in with your new credentials.
Conclusion
Congratulations! You have successfully installed WordPress on your Linux VPS. You now have a powerful platform to build and manage your website. Remember to keep your server and WordPress installation updated to ensure security and performance.
For more detailed guides and the latest updates on WordPress and web hosting, subscribe to our newsletter and follow our blog. Enjoy building your WordPress site!