install WordPress with Apache

How to install WordPress with Apache on Ubuntu 18.04

WordPress is by far the most popular open-source blogging and CMS platform that powers over a quarter of the world’s websites. It is based on PHP and MySQL and packs a ton of features that can be extended with free and premium plugins and themes.

Here are the step-by-step instructions on how to install WordPress with Apache on Ubuntu 18.04:

  1. Update your Ubuntu 18.04 system to the latest version:
   sudo apt update && sudo apt upgrade
  1. Install Apache web server:
   sudo apt install apache2
  1. Install MySQL server:
   sudo apt install mysql-server
  1. Install PHP and its dependencies:
   sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-json php-zip
  1. Create a MySQL database and user for WordPress:
   sudo mysql -u root -p

Enter your MySQL root password when prompted, then create a new database, user, and grant the user permissions to the database:

   CREATE DATABASE wordpress;
   GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'yourpassword';
   FLUSH PRIVILEGES;
   exit;
  1. Download the latest version of WordPress:
   cd /tmp
   wget https://wordpress.org/latest.tar.gz
   tar -xzvf latest.tar.gz
  1. Copy the WordPress files to the Apache web root directory:
   sudo cp -r /tmp/wordpress/* /var/www/html/
  1. Set the correct permissions on the WordPress files:
   sudo chown -R www-data:www-data /var/www/html/
   sudo chmod -R 755 /var/www/html/
  1. Create a new Apache virtual host configuration file for WordPress:
   sudo nano /etc/apache2/sites-available/wordpress.conf

Add the following content to the file:

   <VirtualHost *:80>
       ServerName your-domain.com
       DocumentRoot /var/www/html/
       <Directory /var/www/html/>
           AllowOverride All
           Order allow,deny
           allow from all
       </Directory>
       ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log
       CustomLog ${APACHE_LOG_DIR}/wordpress_access.log combined
   </VirtualHost>

Replace your-domain.com with your actual domain name or IP address.

  1. Enable the new virtual host and Apache rewrite module: sudo a2ensite wordpress.conf sudo a2enmod rewrite
  2. Restart the Apache web server to apply the changes: sudo systemctl restart apache2
  3. Finish the WordPress installation by accessing the WordPress web installer via a web browser: http://your-domain.com Follow the on-screen instructions to complete the WordPress installation process.

That’s it! You have successfully installed WordPress with Apache on Ubuntu 18.04.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Gadget Rumours

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top