Select Page

A prior model of this instructional was once written via Justin Ellingwood


WordPress is the preferred CMS (content material control gadget) on the net. It permits you to simply arrange versatile blogs and internet sites on most sensible of a MySQL backend with PHP processing. WordPress has noticed fantastic adoption and is a brilliant selection for buying a website online up and working temporarily. After setup, virtually all management can also be finished during the cyber web frontend.

On this information, we’re going to focal point on getting a WordPress example arrange on a LAMP stack (Linux, Apache, MySQL, and PHP) on an Ubuntu 18.04 server.

Must haves

As a way to whole this instructional, you are going to want get entry to to an Ubuntu 18.04 server.

It is very important carry out the next duties ahead of you’ll get started this information:

  • Create a sudo consumer for your server: We will be able to be finishing the stairs on this information the use of a non-root consumer with sudo privileges. You’ll create a consumer with sudo privileges via following our Ubuntu 18.04 initial server setup guide.
  • Set up a LAMP stack: WordPress will want a cyber web server, a database, and PHP with the intention to appropriately operate. Putting in a LAMP stack (Linux, Apache, MySQL, and PHP) fulfills all of those necessities. Apply this guide to put in and configure this device.
  • Protected your web page with SSL: WordPress serves dynamic content material and handles consumer authentication and authorization. TLS/SSL is the generation that lets you encrypt the visitors out of your web page in order that your connection is safe. The way in which you place up SSL is determined by whether or not you’ve gotten a website identify on your web page.
    _ When you’ve got a website identify… one of the best ways to safe your web page is with Let’s Encrypt, which gives loose, relied on certificate. Apply our Let’s Encrypt guide for Apache to set this up.
    _ For those who shouldn’t have a website… and you’re simply the use of this configuration for checking out or non-public use, you’ll use a self-signed certificates as a substitute. This offers the similar form of encryption, however with out the area validation. Apply our self-signed SSL guide for Apache to get arrange.

When you’re completed with the setup steps, log into your server as your sudo consumer and proceed beneath.

Step 1 – Making a MySQL Database and Consumer for WordPress

Step one that we can take is a preparatory one. WordPress makes use of MySQL to regulate and retailer web page and consumer knowledge. Now we have MySQL put in already, however we wish to make a database and a consumer for WordPress to make use of.

To get began, log into the MySQL root (administrative) account via issuing this command:

You’re going to be brought about for the password you place for the MySQL root account while you put in the device.

First, we will be able to create a separate database that WordPress will regulate. You’ll name this no matter you want to, however we can be the use of wordpress on this information to stay it easy. Create the database for WordPress via typing:

  • CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Be aware: Each and every MySQL remark should result in a semi-colon (;). Take a look at to verify that is provide in case you are working into any problems.

Subsequent, we’re going to create a separate MySQL consumer account that we can use solely to function on our new database. Growing one-function databases and accounts is a good suggestion from a control and safety point of view. We will be able to use the identify wordpressuser on this information. Be happy to modify this if you want.

We’re going to create this account, set a password, and grant get entry to to the database we created. We will do that via typing the next command. Take note to select a robust password right here on your database consumer:

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

You presently have a database and consumer account, each and every made in particular for WordPress. We wish to flush the privileges in order that the present example of MySQL is aware of in regards to the fresh adjustments now we have made:

Go out out of MySQL via typing:

Step 2 – Putting in Further PHP Extensions

When putting in our LAMP stack, we best required an excessively minimum set of extensions with the intention to get PHP to keep up a correspondence with MySQL. WordPress and plenty of of its plugins leverage further PHP extensions.

We will obtain and set up one of the vital hottest PHP extensions to be used with WordPress via typing:

  • sudo apt replace
  • sudo apt set up php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip

Be aware: Every WordPress plugin has its personal set of necessities. Some would possibly require further PHP programs to be put in. Take a look at your plugin documentation to find its PHP necessities. If they’re obtainable, they may be able to be put in with apt as demonstrated above.

We will be able to restart Apache to load those new extensions within the subsequent segment. In case you are returning right here to put in further plugins, you’ll restart Apache now via typing:

  • sudo systemctl restart apache2

Step 3 – Adjusting Apache’s Configuration to Permit for .htaccess Overrides and Rewrites

Subsequent, we can be making a couple of minor changes to our Apache configuration. In accordance with the prerequisite tutorials, you will have a configuration report on your web page within the /and many others/apache2/sites-available/ listing. We will use /and many others/apache2/sites-available/wordpress.conf for example right here, however you must replace the trail in your configuration report the place suitable.

Moreover, we can use /var/www/wordpress as the foundation listing of our WordPress set up. You need to use the cyber web root specified to your personal configuration.

Be aware: It is conceivable you’re the use of the 000-default.conf default configuration (with /var/www/html as your cyber web root). That is superb to make use of in case you are best going to host one website online in this server. If no longer, it is best to separate the vital configuration into logical chunks, one report according to web page.

Enabling .htaccess Overrides

Lately, the usage of .htaccess recordsdata is disabled. WordPress and plenty of WordPress plugins use those recordsdata broadly for in-directory tweaks to the cyber web server’s habits.

Open the Apache configuration report on your website online:

  • sudo nano /and many others/apache2/sites-available/wordpress.conf

To permit .htaccess recordsdata, we wish to set the AllowOverride directive inside of a Listing block pointing to our file root. Upload the next block of textual content throughout the VirtualHost block to your configuration report, being positive to make use of the proper cyber web root listing:

/and many others/apache2/sites-available/wordpress.conf

    AllowOverride All

When you’re completed, save and shut the report.

Enabling the Rewrite Module

Subsequent, we will be able to allow mod_rewrite in order that we will be able to make the most of the WordPress permalink function:

Enabling the Adjustments

Earlier than we put into effect the adjustments now we have made, take a look at to verify we’ve not made any syntax mistakes:

  • sudo apache2ctl configtest

The output may have a message that appears like this:


AH00558: apache2: May no longer reliably resolve the server's totally certified area identify, the use of Set the 'ServerName' directive globally to suppress this message Syntax OK

If you want to suppress the highest line, simply upload a ServerName directive in your primary (international) Apache configuration report at /and many others/apache2/apache2.conf. The ServerName can also be your server’s area or IP cope with. That is only a message on the other hand and does not have an effect on the capability of our web page. So long as the output comprises Syntax OK, you are prepared to proceed.

Restart Apache to put into effect the adjustments:

  • sudo systemctl restart apache2

Subsequent, we can obtain and arrange WordPress itself.

Step 4 – Downloading WordPress

Now that our server device is configured, we will be able to obtain and arrange WordPress. For safety causes particularly, it’s at all times really helpful to get the most recent model of WordPress from their web page.

Grow to be a writable listing after which obtain the compressed unlock via typing:

  • cd /tmp
  • curl -O

Extract the compressed report to create the WordPress listing construction:

We will be able to be shifting those recordsdata into our file root momentarily. Earlier than we do, we will be able to upload a dummy .htaccess report in order that this can be obtainable for WordPress to make use of later.

Create the report via typing:

  • contact /tmp/wordpress/.htaccess

We will additionally reproduction over the pattern configuration report to the filename that WordPress in reality reads:

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

We will additionally create the improve listing, in order that WordPress would possibly not run into permissions problems when making an attempt to try this by itself following an replace to its device:

  • mkdir /tmp/wordpress/wp-content/improve

Now, we will be able to reproduction all of the contents of the listing into our file root. We’re the use of a dot on the finish of our supply listing to suggest that the entirety throughout the listing must be copied, together with hidden recordsdata (just like the .htaccess report we created):

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

Step 5 – Configuring the WordPress Listing

Earlier than we do the web-based WordPress setup, we wish to modify some pieces in our WordPress listing.

Adjusting the Possession and Permissions

One of the crucial large issues we wish to accomplish is putting in cheap report permissions and possession.

We will get started via giving possession of all of the recordsdata to the www-data consumer and team. That is the consumer that the Apache webserver runs as, and Apache will want as a way to learn and write WordPress recordsdata with the intention to serve the website online and carry out computerized updates.

Replace the possession with chown:

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

Subsequent we can run two in finding instructions to set the proper permissions at the WordPress directories and recordsdata:

  • sudo in finding /var/www/wordpress/ -type d -exec chmod 750 {} ;
  • sudo in finding /var/www/wordpress/ -type f -exec chmod 640 {} ;

Those must be an inexpensive permissions set to begin with. Some plugins and procedures may require further tweaks.

Putting in the WordPress Configuration Document

Now, we wish to make some adjustments to the principle WordPress configuration report.

Once we open the report, our first order of commercial can be to regulate some secret keys to offer some safety for our set up. WordPress supplies a safe generator for those values in order that you shouldn’t have to check out to get a hold of excellent values by yourself. Those are best used internally, so it will not hurt usability to have advanced, safe values right here.

To seize safe values from the WordPress secret key generator, form:

  • curl -s

You’re going to get again distinctive values that glance one thing like this:

Caution! It is crucial that you just request distinctive values each and every time. Do NOT reproduction the values proven beneath!


outline('AUTH_KEY', '1jl/vqfsDO NOT COPY THESE VALUES c_j{iwqD^DO NOT COPY THESE VALUES {Ka(f;rv?Pxf})CgLi-3'); outline('LOGGED_IN_KEY', 'W(50,L_lGkf DO NOT COPY THESE VALUES 07VC*Lj*lD&?3w!BT#-'); outline('SECURE_AUTH_SALT', 'p32*p,]zpercentLZ+pAu:VY DO NOT COPY THESE VALUES C-?y+K0DK_+F|0h'); outline('NONCE_SALT', 'Q6]U:Ok?j4LpercentZ]h^q7 DO NOT COPY THESE VALUES 1% ^qUswWgn+6&xqHN&%');

Those are configuration strains that we will be able to paste without delay in our configuration report to set safe keys. Reproduction the output you gained now.

Now, open the WordPress configuration report:

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

To find the segment that comprises the dummy values for the ones settings. It is going to glance one thing like this:


. . .

outline('AUTH_KEY',         'put your distinctive word right here');
outline('SECURE_AUTH_KEY',  'put your distinctive word right here');
outline('LOGGED_IN_KEY',    'put your distinctive word right here');
outline('NONCE_KEY',        'put your distinctive word right here');
outline('AUTH_SALT',        'put your distinctive word right here');
outline('SECURE_AUTH_SALT', 'put your distinctive word right here');
outline('LOGGED_IN_SALT',   'put your distinctive word right here');
outline('NONCE_SALT',       'put your distinctive word right here');

. . .

Delete the ones strains and paste within the values you copied from the command line:


. . .


. . .

Subsequent, we wish to alter one of the vital database connection settings at first of the report. You wish to have to regulate the database identify, the database consumer, and the related password that we configured inside of MySQL.

The opposite exchange we wish to make is to set the process that WordPress must use to jot down to the filesystem. Since now we have given the cyber web server permission to jot down the place it must, we will be able to explicitly set the filesystem option to “direct”. Failure to set this with our present settings would lead to WordPress prompting for FTP credentials once we carry out some movements.

This atmosphere can also be added beneath the database connection settings, or any place else within the report:


. . .

outline('DB_NAME', 'wordpress');

/** MySQL database username */
outline('DB_USER', 'wordpressuser');

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

. . .

outline('FS_METHOD', 'direct');

Save and shut the report if you find yourself completed.

Step 6 – Finishing the Set up In the course of the Internet Interface

Now that the server configuration is whole, we will be able to whole the set up during the cyber web interface.

On your cyber web browser, navigate in your server’s area identify or public IP cope with:


Choose the language you want to use:

WordPress language selection

Subsequent, you are going to come to the principle setup web page.

Choose a reputation on your WordPress web page and make a choice a username (it is strongly recommended no longer to select one thing like “admin” for safety functions). A powerful password is generated robotically. Save this password or make a choice another sturdy password.

Input your e-mail cope with and make a choice whether or not you need to deter search engines like google and yahoo from indexing your web page:

WordPress setup installation

While you click on forward, you are going to be taken to a web page that activates you to log in:

WordPress login prompt

When you log in, you are going to be taken to the WordPress management dashboard:

WordPress login prompt


WordPress must be put in and able to make use of! Some not unusual subsequent steps are to select the permalinks atmosphere on your posts (can also be present in Settings > Permalinks) or to make a choice a brand new theme (in Look > Subject matters). If that is your first time the use of WordPress, discover the interface a little to get familiar with your new CMS.