Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Install WordPress on Ubuntu 18.04

In this post we will Install Wordpress on Ubuntu 18.04. WordPress content management system is the leading platform for deploying websites today.

Over 31% of all web sites use WordPress today.

WordPress is awesome because it lets you update you web site using a WYSIWYG interface.

It is highly customizable through WordPress Themes and WordPress Plugins.

WordPress can be used for any type of website including:

  • Blogs
  • eCommerce
  • Professional Portfolios
  • More

In this post we will Install Wordpress on Ubuntu Server 18.04.

Getting Started

We will begin with a fresh install of Ubuntu Server 18.04.

First, install all the updates and reboot.

apt update && apt upgrade -y
reboot

After the servers comes back up we need to install a LAMP stack.

WordPress is a PHP based application.

apt install apache2 mysql-server php -y

In order to install WordPress we need to install a few PHP modules.

apt install php-curl php-gd php-intl php-mbstring php-mysql php-soap php-xml php-xmlrpc php-zip

Next, we need to secure MySQL server.

mysql_secure_installation

This script will ask you several questions.

The first question will ask you to install the Validate Password Plugin.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: N

I typically answer No to this question because I know my password is secure.  You can answer Yes if you like here.

Next, the script will ask you to set a new password for the root MySQL user.

New password:

Re-enter new password:

The script will now ask you to remove anonymous users.  Answer yes.

By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y

Next, it will ask you if you want to disallow root login remotely.  We should always answer yes to this.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y

It will ask you to remove the test database and access to it.  Answer yes.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y

Next, it will ask you to reload the privilege tables.  Answer yes.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y

Finally, the script completes.

We are now ready to install WordPress.

Install WordPress on Ubuntu 18.04

To install WordPress we need to create a database for WordPress, configure Apache2 and download the WordPress PHP application.

Create the Database

Now we need to create the database that WordPress will use.

First, login to MySQL using the password we created earlier.

mysql -u root -p

Then, create the WordPress database with this command.

CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Next, we need to create the WordPress user.

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

Make sure to replace the password above with a more secure option.

Run the next command to make our changes take effect.

flush privileges;

Finally, exit.

exit;

Next, we will setup Apache to run WordPress.

Configure Apache2

First we need to allow the use of a .htaccess file.

Open your favorite editor and load the /etc/apache2/sites-available/000-Default file.

Add the following snippet in between the VirtualHost tags.


        AllowOverride All

Save and exit.

Next, enable the rewrite module.

a2enmod rewite

Next we need to tell Apache to serve PHP pages first.

Open /etc/apache2/mods-enabled/dir.conf file and change it to have index.php listed first.


        DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm

Restart Apache.

systemctl restart apache2

Downloading WordPress

Make sure you are in roots home directory.

cd ~

Run the following command to download the latest version of WordPress.

curl -O https://wordpress.org/latest.tar.gz

Untar the tarball.

tar -xzvf latest.tar.gz

Create an empty .htaccess file.

touch wordpress/.htaccess

Create a directory for WordPress to use for upgrades.

mkdir wordpress/upgrade

Copy everything to Apaches HTML directory.

cp -a wordpress/. /var/www/html

Next, we need to change the ownership of the WordPress files to the Apache service.

chown -R www-data:www-data /var/www/html

Now we need to fix the permissions.

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

Next we need to configure WordPress

Configuring WordPress

Copy the configuration file with this command.

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

Run the following command.

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

This will give us several define lines.

Copy these lines and open the /var/www/html/wp-config.php file.

Scroll down where the sample defines are:

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');

And change them to the defines you copied.

Next, scroll up to the database settings.

define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

Change the settings to match the database information from earlier.

define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpress');

/** MySQL database password */
define('DB_PASSWORD', 'password');

Save and exit.

Completing the Installation

Browse to the following URL to finish installing WordPress.

http://{your_server}

You should see the language selection screen.

Select your language and click on the Continue button.

Next fill in your web site’s details.

After you enter all your information click on the Install WordPress button.

You can now login and start using your new WordPress site.

Conclusion

In this article we learned how to install WordPress on Ubuntu 18.04.

If you enjoyed this article then please share it and comment below.

Also be sure to sign up for the AdminTome Blog Newsletter.

The post Install WordPress on Ubuntu 18.04 appeared first on AdminTome Blog.



This post first appeared on AdminTome, please read the originial post: here

Share the post

Install WordPress on Ubuntu 18.04

×

Subscribe to Admintome

Get updates delivered right to your inbox!

Thank you for your subscription

×