Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Install Wordpress on Ubuntu 16.04

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.26k
    Comment on it

    Hello friends, I am writing this blog which will let you know how to install and set up WordPress on Ubuntu. Follow the steps below to install WordPress

     

    Step 1: Create MySQL database

    Login to MySQL using this command:

    mysql -u root -p

     

    Now you will be prompted for password, please enter your password to proceed further.

    After logging into MySQL, create new database for wordpress by writing following command:

    mysql> CREATE DATABASE wordpress;

     

    I am creating MySQL user account separately to operate new database. Enter the following command to create account, grant access to database and set password:

    mysql> GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

     

    In order to make MySQL recognize changes that have been made, we need to flush privileges by writing following command:

    FLUSH PRIVILEGES;

     

    Now type the command to exit from MySQL:

    EXIT;

     

    Step 2: Apache Configuration for .htaccess

    Firstly open the file apache2.conf by typing the command:

    sudo nano /etc/apache2/apache2.conf 

    Next, we are going to enable .htaccess overrides by setting "AllowOverride All".

    . . .
    
    <Directory /var/www/html/>
        AllowOverride All
    </Directory>
    
    . . .
    

     

    When done, save the file and close it. Next we are going to enable Rewrite Module to utilize Wordpress permalink:

    sudo a2enmod rewrite

     Now restart apache to enable the changes that we have made by typing:

    sudo systemctl restart apache2 

     

    Step 3: Download WordPress

    Download the latest version of WordPress into the tmp directory by typing:

    $ cd /tmp
    $ curl -O https://wordpress.org/latest.tar.gz 
    Next, extract files by following command: 
    
    tar xzvf latest.tar.gz 

     

    Now lets create file and set permissions by following command:

    touch /tmp/wordpress/.htaccess
    chmod 660 /tmp/wordpress/.htaccess 

     

    Next we will copy wp-config-sample.php and rename it to wp-config.php 

    cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php

     

    Now copy all the contents of the directory by using dot at the end of source directory:

    $ sudo cp -a /tmp/wordpress/. /var/www/html 

     

    Step 4: Configure Wordpress

    Now our next task is to give ownership to www-data and permissions to the files.

    sudo chown -R amuk:www-data /var/www/html 
    sudo find /var/www/html -type d -exec chmod g+s {} \; 

    In order to make themes and plugin changes we need to give another permissions. So first of all we are going to give write access to wp-content directory by typing:

    sudo chmod g+w /var/www/html/wp-content

     

    Next give write permission to wp-content directories

    sudo chmod -R g+w /var/www/html/wp-content/themes
    sudo chmod -R g+w /var/www/html/wp-content/plugins 

     

    Lets generate secret keys by typing the following command:

    curl -s https://api.wordpress.org/secret-key/1.1/salt/

     

    The Output of the above command will be like this:

    define('AUTH_KEY', '1jl/vqfs<XhdXoAPz9 DO NOT COPY THESE VALUES c_j{iwqD^<+c9.k<J@4H'); define('SECURE_AUTH_KEY', 'E2N-h2]Dcvp+aS/p7X DO NOT COPY THESE VALUES {Ka(f;rv?Pxf})CgLi-3'); define('LOGGED_IN_KEY', 'W(50,{W^,OPB%PB<JF DO NOT COPY THESE VALUES 2;y&,2m%3]R6DUth[;88'); define('NONCE_KEY', 'll,4UC)7ua+8<!4VM+ DO NOT COPY THESE VALUES #`DXF+[$atzM7 o^-C7g'); define('AUTH_SALT', 'koMrurzOA+|L_lG}kf DO NOT COPY THESE VALUES 07VC*Lj*lD&?3w!BT#-'); define('SECURE_AUTH_SALT', 'p32*p,]z%LZ+pAu:VY DO NOT COPY THESE VALUES C-?y+K0DK_+F|0h{!_xY'); define('LOGGED_IN_SALT', 'i^/G2W7!-1H2OQ+t$3 DO NOT COPY THESE VALUES t6**bRVFSD[Hi])-qS`|'); define('NONCE_SALT', 'Q6]U:K?j4L%Z]}h^q7 DO NOT COPY THESE VALUES 1% ^qUswWgn+6&xqHN&%');

     

    Just copy these lines and paste then in your configuration file, so open wp-config file

    nano /var/www/html/wp-config.php 

     

    Now replace the dummy values that are shown on wp-config.php like this:
    

    /var/www/html/wp-config.php

    . . .
    
    define('AUTH_KEY',         'put your unique phrase here');
    define('SECURE_AUTH_KEY',  'put your unique phrase here');
    define('LOGGED_IN_KEY',    'put your unique phrase here');
    define('NONCE_KEY',        'put your unique phrase here');
    define('AUTH_SALT',        'put your unique phrase here');
    define('SECURE_AUTH_SALT', 'put your unique phrase here');
    define('LOGGED_IN_SALT',   'put your unique phrase here');
    define('NONCE_SALT',       'put your unique phrase here');
    
    . . .
    

     

    Delete those lines and paste in the values you copied from the command line:

    /var/www/html/wp-config.php

    . . .
    
    define('AUTH_KEY',         'VALUES COPIED FROM THE COMMAND LINE');
    define('SECURE_AUTH_KEY',  'VALUES COPIED FROM THE COMMAND LINE');
    define('LOGGED_IN_KEY',    'VALUES COPIED FROM THE COMMAND LINE');
    define('NONCE_KEY',        'VALUES COPIED FROM THE COMMAND LINE');
    define('AUTH_SALT',        'VALUES COPIED FROM THE COMMAND LINE');
    define('SECURE_AUTH_SALT', 'VALUES COPIED FROM THE COMMAND LINE');
    define('LOGGED_IN_SALT',   'VALUES COPIED FROM THE COMMAND LINE');
    define('NONCE_SALT',       'VALUES COPIED FROM THE COMMAND LINE');
    
    . . .
    

     

    Finally we need to set up database connection settings. DB_NAME is the name of the database, we have database name "wordpress" here. DB_USER is the username of the database, we have wordpressuser as username of database "wordpress". DB_PASSWORD is the password of the database, we have set password to 'password' . Open this file and modify the changes:

     

    /var/www/html/wp-config.php

    . . .
    
    define('DB_NAME', 'wordpress');
    
    /** MySQL database username */
    define('DB_USER', 'wordpressuser');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'password');
    
    . . .
    
    define('FS_METHOD', 'direct');
    

    Save and close the file when you are finished.

    Now navigate to browser and type IP address or domain name to access wordpress site:

    http://server_domain_or_IP

    You will enter the page where you will be asked to select the language you would like to use.
    Next, you will come to the main setup page. Select Site title of WordPress site and choose username, auto generate password and enter your email address. WordPress site has been installed successfully now. When you will login, you will be redirected to WordPress admin dashboard page.

     

    Thanks for reading the blog

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: