Installing WordPress on Ubuntu 14.04 Apache 2.4 on AWS

Published on Author craigzearfossLeave a comment
  • Create a database.
    mysql -h localhost -u root -p
    CREATE DATABASE WORDPRESS_DATABASE;
    CREATE USER WORDPRESS_USER@localhost IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON WORDPRESS_DATABASE.* TO WORDPRESS_USER@localhost;
    FLUSH PRIVILEGES;
    exit;
    
  • Download WordPress and copy it to the document root.
    cd ~
    wget http://wordpress.org/latest.tar.gz
    tar xzvf latest.tar.gz
    sudo mv wordpress/ /var/www/WORDPRESS_DIRECTORY/
    
  • Download some additional PHP modules WordPress will need.
    sudo apt-get update
    sudo apt-get install php5-gd libssh2-php
    
  • Configure WordPress.
    cd /var/www/WORDPRESS_DIRECTORY/
    cp wp-config-sample.php wp-config.php
    

    Edit wp-config.php.

    sudo nano wp-config.php
    

    SET the DB_NAME, DB_USER and DB_PASSWORD.
    Update the secret keys by replacing the values in the file with the values from the url https://api.wordpress.org/secret-key/1.1/salt/.

  • Set directory permissions and make uploads directory.
    sudo chown -R ubuntu:www-data /var/www/WORDPRESS_DIRECTORY/*
    mkdir wp-content/uploads
    sudo chown -R www-data:www-data /var/www/WORDPRESS_DIRECTORY/wp-content/uploads
    
  • Update directory owner on plugins and themes directories.
    chown -R www-data:www-data wp-content/plugins/
    chown -R www-data:www-data wp-content/themes/
    
  • Create the Apache server configuration file /etc/apache2/sites-available/wordpress.conf.
    <VirtualHost *:80>
    
        ServerAdmin webmaster@WORDPRESS_DOMAIN
    
        DocumentRoot /var/www/WORDPRESS_DIRECTORY/
        ServerName WORDPRESS_DOMAIN
    
        <Directory />
            Options FollowSymLinks
            AllowOverride All
        </Directory>
        <Directory /var/www/WORDPRESS_DIRECTORY/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Require all granted
            Allow from all
        </Directory>
    
        #ErrorDocument 404 /
        ErrorLog ${APACHE_LOG_DIR}/WORDPRESS_DOMAIN_error.log
    
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
    
        CustomLog ${APACHE_LOG_DIR}/WORDPRESS_DOMAIN_access.log combined
    
    </VirtualHost>
    
  • Restart the server.
    sudo service apache restart
    
  • If this is on your local server then add the following entry to you /etc/hosts file.
    127.0.0.1     WORDPRESS_DOMAIN
    
  • In your browser go the http://WORDPRESS_DOMAIN and set your Site Title, Username, Password and Email.
  • Instructions for setting up backups are here http://notes.craigzearfoss.com/2016/02/03/wordpress-automatic-backups-on-aws/

Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *