in

LinuxLinux

How To Install WordPress With LAMP Stack on Ubuntu 18.04 DigitalOcean Server!

Easy installation of WordPress Latest version on Ubuntu 18.04 with LAMP Stack.

Install WordPress on Ubuntu 18.04

W

ordPress on Ubuntu 18.04 with LAMP Stack: Ubuntu is one of the most used server-side operating systems. This is due to the ease interface and it has many features that can be implemented on the server side too. “WordPress” is the most commonly using CMS ( Content Management System ) for managing the websites. WordPress allows you to create a website, blogs and helps us to share some valuable information on the internet. WordPress is the most powerful CMS, mainly designed with PHP background with MySQL Database. In this article, we added the information about installing WordPress on Ubuntu 18.04 DigitalOcean Server with LAMP Stack.

This article is suitable only for Ubuntu 18.04 with LAMP Stack version. 

Main Index:

Prerequisites:

In order to successfully complete this article, you just need to follow the below steps:

You need to create a DigitalOcean Account now!! DigitalOcean offering 100$ for every signup currently (expire soon). Follow the below link to Create a New DigitalOcean Account.

Then you need to create the Ubuntu Server with LAMP Stack on DigitalOcean. We recommend you follow the below article to create and install the LAMP Stack on Ubuntu 18.04 DigitalOcean Server.

When you are finished with the setup steps, log into your server as your sudo user and continue below.

Install WordPress on Ubuntu 18.04 With LAMP Stack- Step by Step Method:

There are some minor steps you need to do just before installing WordPress on your Ubuntu 18.04 server and they are.

STEP 1- Create MySQL Database & User for WordPress:

This is the most important step that you need to do before installing WordPress on Ubuntu Server. WordPress requires MySQL Database to define their user and for saving the content created using the WordPress editor. LAMP stack already contains MySQL database and so we need to configure the Database to WordPress by creating a user for WordPress and to use.

To do this, You need to login to your MySQL DB by pasting the below command in your Server console or Putty.

$mysql -u root -p

Now, a popup will appear on your screen and it will be prompted for the password you set for the MySQL root account when you installed the software.

We need to create a new Database for WordPress by the following command:

mysql>CREATE DATABASE wordpress DEFAULT CHARACTER SET
utf8 COLLATE utf8_unicode_ci;

Note: You must end the statement with Semicolon;“. If you are not using the semi colon and it will throw you the error.

WordPress database has been created, Now it is the time to create the WordPress user account essentially made for WordPress DB. Here we are going to create a New user account to manage WordPress Database. We use the name ” wordpressadmin ” for WordPress user account and you can change this name to your own.

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

or

GRANT ALL ON wordpress.* TO ‘wordpressadmin‘@’localhost’ IDENTIFIED BY ‘password‘;

Copy the above command and paste in your console and hit enter button. The Password can be replaced by your own. The above command will create a Database user account for WordPress database with custom password credentials. You just need to provide a strong password to this account.

Check this too  How To Install LAMP Stack On Debian 9 Distro {Detailed Steps}

Now it is the time to purge the privileges and so the MySQL DB will know the current changes have done.

mysql>FLUSH PRIVILEGES;

The above command will flush all the privileges and now it is the time to exit the database.

mysql>EXIT;

Step 1- Installing PHP & its Extensions:

With LAMP stack, The latest version of PHP will be installed to your server automatically and we need to install some essential extensions for installing WordPress. WordPress and many of its plugins leverage additional PHP extensions.

The below command will help you install the latest and essential of php for WordPress.

$sudo apt update
$sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip

The above command will install the latest and essential PHP extension for WordPress.

After installing all the PHP extensions and it is the time to restart your web server.

$sudo systemctl restart apache2

Step 3- Configuration Apache to Allow for .htaccess Overrides and Rewrites:

Before changing the Apache files, you should have a configuration file for your site in the /etc/apache2/sites-available/. Here we using the /etc/apache2/sites-available/wordpress.conf as the example and you need to replace the file path for your own.

To install WordPress, we use /var/www/wordpress as the root directory.

Enabling the .htaccess file Override:

Currently, the .htaccess file is disabled. WordPress and its plugin use these files for extensive working.

Now open the Apache Config File:

$sudo nano /etc/apache2/sites-available/wordpress.conf

To grant the access to override the .htaccess file, you need to set the AllowOverride directive to the Directory block pointing to your WordPress directory. Add the piece of code in the VirtualHost in your configuration file.

/etc/apache2/sites-available/wordpress.conf

<Directory /var/www/wordpress/>
AllowOverride All
</Directory>

now save the file and exit the file.

Enabling the Rewrite Module:

Next, we need to rewrite the module by using the mod_rewrite. This feature will enable the WordPress permalink feature.

$sudo a2enmod rewrite

The above command will enable the rewrite module. We implement the changes we’ve made, check to make sure we haven’t made any syntax errors.

$sudo apache2ctl configtest

The above command will provide the output.

Output
AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message Syntax OK

To minimize the error, you just simply add the ServerName to your global directory configuration file at /etc/apache2/apache2.conf. The ServerName can be your Server’s domain or your IP Address. Now save the configuration file and exit the config file. Restart your server and now the above error will get removed. Now re run the configtest, it will shows you the output as Syntax OK and continue the below steps.

Restart the Apache Server:

$sudo systemctl restart apache2

Yes, you completed the 75% process. Now it is the time to download WordPress to your server.

Step4- Download WordPress into your Server:

WordPress is one of the best ever CMS for your web server. To install WordPress, we suggest the latest version of the WordPress package to your server.

First, create a temporary directory to download the zip file of the latest WordPress.

$cd /tmp
$curl -O https://wordpress.org/latest.tar.gz
Now the extract the downloaded file.
$tar xzvf latest.tar.gz

You need to add the dummy .htaccess file and later that we will move the whole directory inside the main root directory.

$touch /tmp/wordpress/.htaccess

You need copy over the sample configuration file to the filename that WordPress actually reads:

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

Now it is the time to move all the content including the .htaccess file to the main WordPress directory folder.

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

Step 5- Configuring the WordPress:

You are in the final process of launching the WordPress with LAMP stack server. Before that, you still need to make some configuration on WordPress Directory.

Check this too  View Saved WiFi Passwords in Ubuntu 18.04 & Ubuntu 19.04 Linux

One of the essential configurations is Adjusting the Ownership & Permissions. Now you need to start providing the ownership of all the files to the www-data user and group. You can update the ownership using the chown command.

$sudo chown -R www-data:www-data /var/www/wordpress

after this, you need to run the below two commands:

$sudo find /var/www/wordpress/ -type d -exec chmod 750 {} \;
$sudo find /var/www/wordpress/ -type f -exec chmod 640 {} \;

Now, the WordPress themes and plugin have the full permissions to access the WordPress directory.

Finalizing the WordPress Configuration:

Now, you need to config the main WordPress Configuration file “WP-Config.php

WordPress provides a secure generator for these values so that you do not have to try to come up with good values on your own. These are only used internally, so it won’t hurt usability to have complex, secure values here:

You can generate secure values from the WordPress secret key generator by using the following command:

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

The above command will generate the below output:

Output
define(‘AUTH_KEY’, ‘1jl/vqfs<XhdXoAPz9c_j{iwqD^<+c9.k<[email protected]’);
define(‘SECURE_AUTH_KEY’, ‘E2N-h2]Dcvp+aS/p7X{Ka(f;rv?Pxf})CgLi-3’);
define(‘LOGGED_IN_KEY’, ‘W(50,{W^,OPB%PB<JF2;y&,2m%3]R6DUth[;88’);
define(‘NONCE_KEY’, ‘ll,4UC)7ua+8<!4VM+#`DXF+[$atzM7 o^-C7g’);
define(‘AUTH_SALT’, ‘koMrurzOA+|L_lG}kf07VC*Lj*lD&?3w!BT#-‘);
define(‘SECURE_AUTH_SALT’, ‘p32*p,]z%LZ+pAu:VYC-?y+K0DK_+F|0h{!_xY’);
define(‘LOGGED_IN_SALT’, ‘i^/G2W7!-1H2OQ+t$3t6**bRVFSD[Hi])-qS`|’);
define(‘NONCE_SALT’, ‘Q6]U:K?j4L%Z]}h^q71% ^qUswWgn+6&xqHN&%’);
Note: Don’t copy the above output SALT codes. It is very important to request unique values each time.

Now open the WordPress configuration file using the following command:

$sudo nano /var/www/wordpress/wp-config.php

You can find the below command in the wp-config file. Replace the “put your unique phrase here” with the SALT code generated from your WordPress Request.

/var/www/wordpress/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’);

After replacing the file, save the file but don’t close the files and still you need to connect the WordPress Database credentials with your WordPress Conifguration file.

If you are quite expert in handling the putty continue the steps in terminal otherwise we suggest you to use the “WinSCPSSH software for connection with your server. WinSCP will provide you the GUI interface of your server files. You can access the WordPress directory as the folder by folder. Now follow the below steps:

Output

define(‘DB_NAME’, ‘wordpress’);

/** MySQL database username */
define(‘DB_USER’, ‘wordpressadmin‘);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘password‘);

define(‘FS_METHOD’, ‘direct’);

Save the file and quit the file.

Step6- Completing the Installation of WordPress in Server:

The backend installing process has been completed and it is the time to configure the front section of WordPress to your server.

Open any browser and load your server IP Address:

https://Server-IP-Address

Replace the Server IP address with your server IP address or if you assign any domain to your server and then load your domain in the browser.

WordPress Language Selection
WordPress Language Selection

The above options will appear on your screen, in that you need to provide your website language and click the continue button.

Check this too  5+ Ways To Restart Your Apache Server On Ubuntu 18.04, 18.04.2 & 19.04 Disco Dingo
Website Configuration
Website Configuration

You need to enter the details that are asked by WordPress. Once you complete the information and then click the Install WordPress button. In a few minutes, WordPress will installed in your server.

WordPress Dashboard
WordPress Dashboard

Once all the process and installation got completed, you will be redirected to your WordPress Dashboard. You can simply do anything with the WordPress CMS. You can change the permalink structure in the “Settings” options and you can change the Themes in the “Appearance” options.

That’s it, This is one of the ways to install WordPress on Ubuntu 18.04 with LAMP Stack DigitalOcean Server.

Install WordPress on Ubuntu 18.04 With LAMP[One Click App]

This is the easiest way to install WordPress on Ubuntu 18.04 with LAMP stack on DigitalOcean Server using their marketplace option. To do this kindly follow the below steps:

Create a Droplet
Create a Droplet
  • Now, go to the Marketplace Tab
  • This Marketplace tab is once called as the One-click apps
  • Here, you will able to see the list apps that are available as the pre-installed apps

Marketplace Tab

    Marketplace Tab
  • Scroll down and select the WordPress 18.04 package.
Wordpress 18.04 LAMP Stack
WordPress 18.04 LAMP Stack

 

  • Choose the plan of your web server
  • For small dynamic websites, we suggest you go with “Standard” plans.

Droplet plan

    Droplet plan
  • Select the location of your server and scroll down

Server Location

    Server Location
  • Enter the name of the droplet, select the number of droplets that you want to create at this instance & finally click the Green colored button named as “Create” will deploy the server with the pre-installed WordPress on Ubuntu 18.04 with LAMP stack.
Creating a Droplet
Creating a Droplet

Once the creation of the droplet got finished, you will receive an email from DO containing the IP address of your server with username and password. Load the IP Address and configure your WordPress.

If you don’t know to configure the WordPress. Click here to see the steps to configure WordPress.

Frequently Asked Questions:

How do you use WordPress on Ubuntu?
Step 1: Install Apache Web Server. To install Apache web server, issue the command below: $ sudo apt-get install apache2 apache2-utils.

Step 2: Install MySQL Database Server.

Step 3: Install PHP and Modules.

Step 4: Install WordPress CMS.

Step 5: Create a WordPress Database.

How do you setup a WordPress server?
  1. Download the latest version of WordPress from WordPress.org.
  2. Upload those files to your web server, using FTP.
  3. Create a MySQL database and user for WordPress.
  4. Configure WordPress to connect to the newly-created database.
  5. Complete the installation and setup your new website!
What is WordPress configuration?
WordPress comes with a powerful configuration file called wp-config.php. It is located in the root folder of every WordPress site and contains important configuration settings.

Verdict:

In this article, we provided the information about installing WordPress on Ubuntu 18.04 With LAMP Stack on DigitalOcean and Other Servers. The One-click app method will work only on DigitalOcean servers. For other servers, you can follow the conventional methods that we explained above to install WordPress on your Ubuntu Server. If you still have any queries, drop you doubt in the comment box.

 

  • Article Explanation
  • Images Explanation
  • Command Working
  • Content Clarity
  • Alternate Methods
4.7

Summary

For more articles, Kindly visit our Homepage

Sending
User Rating ( votes)

Leave a Reply

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

Written by Jim Moriarty

Hello, Am Jim from Arizona, Big Fan of Holmes. Server-side handler, Network Engineer & currently working for Tec Robust. I write a server-based article.

Contact me:
tecrobust [@] gmail.com
Sub: Message to Jim.

url decoder online

URL Decoder Online- Best URL Decoder[Instant]

Base64 Encode

Base 64 Encoder Online Tool to Encode Strings into Base64 Code