Install WordPress using LAMP Stack

This post is to show the steps I followed to install LAMP(Linux, Apache, MySQL, PHP) Stack in the server and how I installed WordPress and fixing the permalink for pages.

Requirements : A dedicated Ubuntu/Linux server
  1. Install Apache Web Server :
    apt install apache2
    Now check socket status (cmd: ss) or ensure apache server is running, by entering the IP address of your server in any browser address bar
  2. Install and Configure Certbot [SSL]
    1. Search and install certbot and required packages
      1. apt install certbot
      2. apt install python3-certbot-apache
    2. Run Certbot for configuration
      1. certbot --apache
      2. Need to provide email id for communication and our domain name when required
  3. Validate SSL Certificate by reloading the website
  4. Install php-mysql
    1. apt install php-mysql
      1. And required packages libapache2-mod-php7.4 [If needed]
    2. Run the following commands to enable
      1. a2enmod php7.4 
      2. a2enmod rewrite
  5. Install MariaDB (mariadb-server and mariadb-client)
    1. apt install mariadb-server 
    2. apt install mariadb-client
    3. mysql -u root -p (to config our db)
      ref – https://wordpress.org/support/article/creating-database-for-wordpress/#using-the-mysql-client
      Create WordPress Database:
      1. CREATE DATABASE databasename;
      2. GRANT ALL PRIVILEGES ON databasename.* TO wordpressusername"@"hostname" IDENTIFIED BY "password";
      3. FLUSH PRIVILEGES;
      4. EXIT
  6. Download and Extract WordPress
    ref – https://wordpress.org/support/article/how-to-install-wordpress/#detailed-instructions
    1. Download
      wget https://wordpress.org/latest.tar.gz
    2. Extract
      tar -xzvf latest.tar.gz
    3. Move this extracted folder
      mv -f wordpress /var/www/html/
    4. Update the defualt document root path in apache2 config file  (use nano)
      Path – /etc/apache2/sites-enabled/000-default-le-ssl.conf 
      1. Update DocumentRoot to /var/www/html/wordpress
    5. Give access to WordPress Folder
      chown www-data: wordpress -R
    6. Reload apache2 server
      systemctl reload apache2
  7. Now Reload site to start WordPress setup
  8. WordPress 
    1. Note down the Database name, username, password, host, Table details for reference
    2. Provide user name, password and website title and complete the setup
    3. Login to Wordress, so we can access wp-admin (Dashboard)
      1. If login page closed / missed during the setup flow
      2. We can add  /wp-admin or /wp-login.php at the end domain/url
    4. Navigate through setting and configure basic settings and customize the website
  9. Fixing Permalink
    1. Visit Settings – permalink from the Dashboard
    2. Change it to post name and Save
    3. Visit website and check if the default blog is opening 
    4. For Permalink changes tyo work we need to override the web directory rule to AllowOverride 
      1. Change your web directory (/var/www/) override rule in
        /etc/apache2/apache2.conf
      2. Change AllowOverride None to
        AllowOverride All
      3. Restart apache2 server
    5. Now Reload the website and visit the the default blog