How To Troubleshoot and Fix WordPress 404 Errors (Plus an Essential Tip on Redirects)

Had a problem on a client´s Ubuntu 14.04 wordpress server. I used THIS site to fix the problem:

How To Troubleshoot and Fix WordPress 404 Errors (Plus an Essential Tip on Redirects)

A 404 error is generated by your server when a requested URL is not found.
This post will help you decide if action needs to be taken and what action you should take.

When to redirect

Most people’s first instinct upon seeing a 404 error is to consider a redirect. Hold on!
Redirecting any and all 404 errors can actually be bad for your search engine results. Via Google Webmaster Tools:
Returning a code other than 404 or 410 for a non-existent page (or redirecting users to another page, such as the homepage, instead of returning a 404) can be problematic. Firstly, a page like this (called a “soft” 404) tells search engines that there’s a real page at that URL. As a result, that URL may be crawled and its content indexed. Because of the time Googlebot spends on non-existent pages, your unique URLs may not be discovered as quickly or visited as frequently and your site’s crawl coverage may be impacted (also, you probably don’t want your site to rank well for the search query [File not found]).
The first thing to ask yourself is: did this content ever exist?
If it did, and you have changed your domain or URL structure, you will want to implement redirect(s) to send users and search engines to the right place.
If it never existed, don’t sweat it. As mentioned above “Redirecting any and all 404 errors can actually be bad for your search engine results.”

Troubleshooting

WordPress sites can complicate the 404 troubleshooting process. Why? WordPress is a content management system that processes its own internal rewrite array as a part of its permalinks feature.
The first step to troubleshooting 404s is to figure out whether the 404 is being caused by the web server or by WordPress.

Static file

If your file is static (e.g. a jpg image) open your FTP client and verify that the file exists.
As an example, let’s say that the URL http://mydomain.com/wp-content/uploads/picture.jpg is producing a 404 error. You will want to:
  • Open FTP Client and connect to your server (if you don’t know how to do so,read this.)
  • Navigate to the file’s location
  • Verify that the file exists
  • If it is does not exist, you have found the source of your 404.
However, it it does exist, yet pulling the URL up in a browser results in a 404 error, continue on to find out whether the issue is web server-based or WordPress-based.
In FTP create two files at the root  [/var/www/yourdomain.com/] for testing purposes.
First: Create an html file named test.html that has the words “It worked” in it. (Download this file here.)
After uploading it, head over to: http://yourdomain.com/test.html
If you see “It worked,” the server is processing static files correctly, so your issue is likely in WordPress.
Second: Create a PHP file named test.php (or download here) that includes the following:
<?php echo 'It works in PHP'; ?>
After uploading, head over to http://yourdomain.com/test.php. If it says “It works in PHP,” then PHP is functioning properly as well, so again your problem is likely in WordPress.
(Quick side note: make your mama proud by removing these files when you are done testing!)

Fixing 404s in WordPress

WordPress creates a rewrite array that is responsible for managing permalinks, or “pretty URLs.”
Improperly coded plugins, custom post types, and taxonomy alterations can break or corrupt the permalink array, thus causing 404s.

Quick fix: re-save permalinks

You can reset the permalink array by going to the permalinks tab in wp-admin and simply re-saving the permalink structure.
  • Navigate to: WordPress Dashboard → Settings → Permalinks: Click “Save Changes”
Test your URL. If the 404 goes away, something caused an issue with your permalink structure and this fixed it.
Often the quick fix is enough to correct your 404 issues. However, should they come back, go on to the next troubleshooting step.

Find the cause

If the quick fix did not work or you are seeing 404s again, try disabling plugins that handle redirection or create customized permalinks. Did that solve it?
Next, use a debugger to view the rewrite array and confirm that the rewrite rule responsible for processing your URL is not in place. To do this, install the pluginDebug This, which makes it easy to view what is actually in the WordPress rewrite array.
Once this plugin is installed and activated, go to your site. Then navigate to:
  • Homepage → Admin Bar → Debug This → Query → Rewrites.
You should end up on a screen that contains rewrite rules on the left hand side and the actual PHP string being rewritten on the right hand side. So what do you do with this information?
Let’s say we have a broken author feed (example: https://www.copyblogger.com/author/jerodmorris/feed/). To troubleshoot the broken feed, look for the word “author.” Eventually this rule is found: author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$
If you don’t find the rule, this is the source of your issue. WordPress will not process the request unless it knows what it is doing.
The actual PHP URL string that WordPress uses for this author feed is: http://copyblogger.com/index.php?author_name=jerodmorris&feed=rss. If this long PHP URL does not work, you have another problem with your site.
You will now want to start by deactivating plugins one by one to see if you can find the conflicting PHP responsible for the issue.
***
And, of course, if you go through all of these steps are still unable to fix the issue, submit a Help Desk ticket.
If you have to submit a ticket, take note: it is very important that you let us know the exact URLs that are giving unwanted or unexpected 404 errors, and that you walk us through the troubleshooting steps you have already completed. Then we can add some next-level troubleshooting and insight to get your problem solved.

How to Solve WordPress Could Not Create Directory

Had a problem with a clients wordpress ubuntu 14.04 server and fixed the problem using THIS site:

How to Solve WordPress Could Not Create Directory

/08 Useful Tips /How to Solve WordPress Could Not Create Directory
If you’re trying to upgrade WordPress or install a plugin and getting the “could not create directory” error, there are two levels required to solving it.
Here’s an example of the error sequence:
Downloading update from http://downloads.wordpress.org/plugin/your-plugin.0.9.3.1.zip…
Unpacking the update…
Could not create directory. /wp-content/upgrade/yourplugin.tmp
Return to Plugins page
1. Web Server Ownership
The first level is actually to make sure that your web server has ownership over the directories:
chown -R www-data:www-data your-wordpress-directory
2. Directory Permissions
The second level is also required – you must make sure that the directory permissions are properly set:
sudo find /var/www/wordpress/ -type d -exec chmod 755 {} ;
sudo find /var/www/wordpress/ -type f -exec chmod 644 {} ;
I’ve found that most solutions posted on the web show part two but skip the first part.



Source: http://publishingwithwordpress.com/how-to-solve-wordpress-could-not-create-directory/#ixzz3sPmvucJQ 
Follow us: @pubwp on Twitter

Installing osTicket on Ubuntu 14.04

I had to install osTicket on a clients Ubuntu server this moring. The install was really simple and I was up an running within 10 minutes. I used THIS site for instalation instructions.

Install osTicket on Ubuntu 14.04 64 VPS

 Posted to: InstructionsVideosUbuntu by HostingInstructions
Support Your clients by Web or Email with osTicket.
If your business has a need to automate support or customer interaction and track service levels, osTicket is a free, open source tool, that meets and exceeds expectations.
Businesses at every level of growth can benefit from osTicket’s system. Best of all, it’s the client that benefits the most from service imporovements.


For the instructions to work, you will need to have LAMP (Linux, Apache, MySQL or MariaDB and PHP) already installed on your VPS. Our instructions for installing LAMP on Ubunutu 14.04 can be found here.
The instructions are tried and true, and were verified on InterServer`s OpenVZ VPS Hostingservice, utilizing Ubuntu 14.04 64 minimal.
You should be able to copy and paste into SSH as you go along.
Requirements:
  • LAMP installed. See our instructions.
  • Setup was conducted on InterServer’s OpenVZ VPS Hostingwith Ubuntu 14.4 64-bit (instructions are for minimal distribution, but should work for regular distribution as well).
  • Putty or similar SSH client
  • root login and password or an account capable of sudo
Installation
Start by updating package sources:
  • sudo apt-get update
Now will install unzip, since our file is in zip format:
  • sudo apt-get install zip unzip
Create a database for osTicket in mySQL:
  • sudo mysql -u root -p
You will need to copy and paste each line. Change the highlightedvalues to values you want (most important are user and password).
  • CREATE DATABASEostdb;
  • CREATE USERosticket_user@localhost IDENTIFIED BY 'password';
  • GRANT ALL PRIVILEGES ONostdb.* TOosticket_user@localhost;
  • FLUSH PRIVILEGES;
  • exit
Write down the values you entered, because we will need to use the to configure osTicket later.
First will go to our home directory:
  • cd ~
Make a directory and move to it:
  • sudo mkdir osticket
  • cd osticket
Now, download osTicket:
  • sudo wget http://osticket.com/sites/default/files/download/osTicket-v1.9.11.zip
Unzip it:
  • sudo unzip osTicket-v1.9.11.zip -d ~/osticket
The zip file will extract two directories. Scripts and Upload. Make a directory on /var/www/html where our installation will reside:
  • sudo mkdir /var/www/html/support/
Move the upload to our newly created web directory:
  • sudo cp -rv ~/osticket/upload/* /var/www/html/support/
Copy the configuration file:
  • cp /var/www/html/support/include/ost-sampleconfig.php /var/www/html/support/include/ost-config.php
Give Apache ownership of this new directory:
  • sudo chown -R www-data:www-data /var/www/html/support/
PHP
(Optional) osTicket has the ability to fetch emails and turn them into tickets. If this is not one of your requirements, you may skip this step. Otherwise, in order to use the email feature, we need to install a PHP module, php5-imap:
  • sudo apt-get install php5-imap
Now link the module:
  • sudo php5enmod imap
Restart Apache:
  • sudo service apache2 restart
Side Note: The three commands above are the way to correct the “IMAP doesn’t exist. PHP must be compiled with IMAP enabled.” error on the osTicket installer, after you have installed php5-imap.
Install and Configure from Browser
Open your browser and visit (replace with domain name or ip):
  • yourdomain.com/support/
Remember to populate the database fields with the variables you used when you created the database. Leave the table prefix and the server name with the defaults, unless you know you want to specify something else.
Your osTicket system is now available on:
Support Center:
yourdomain.com/support/
Staff control panel:
yourdomain.com/support/scp
Clean up
Change permissions on ost-config.php:
  • chmod 0644 /var/www/html/support/include/ost-config.php
Delete the setup directory:
  • rm -rf /var/www/html/support/setup
Remove our installation files:
  • rm -rf ~/osticket
Customizing osTicket
osTicket can be configured to suit just about any support center need. Please visit the wiki for documentation.

Windows Server AD: Using Group Policy Preferences to Map Drives Based on Group Membership

Had to create a GPO today to map drives on users desktops, I used THIS site.

Public drive mappings typically do not require membership to a particular group. However, sometimes public drive mappings do not provide enough granularity. Most organizations have data specific to business units such as accounting, marketing, or human resources.. Inclusive Group Drive mappings solve this problem by allowing a configuration that maps a specific drive letter to a specific network share based on the user being a member of a particular group. This ensures members of the accounting unit receive drive letters mapped for accounting and members of human resources map their respective drives. Exclusive drive mappings are not very common; however, they do provide the flexibility to prevent a user from mapping a particular drive letter to a network share if they are not a member of a specific group. A good example of exclusive drive mappings is to prevent the CIO or other executives members from mapping a drive letter in which they are likely to never use. Let us take a closer look at these scenarios

Public drive mappings

Producing a Group Policy Preference item to create public drive mappings is simple. The GPO containing the preference item is typically linked to higher containers in Active Directory, such as a the domain or a parent organizational unit.

Configuring the drive map preference item.

image
Figure 1 Configuring mapped drive preference item
Newly created Group Policy objects apply to all authenticated users. The drive map preference items contained in the GPO inherits the scope of the GPO; leaving us to simply configure the preference item and link the GPO. We start by configuring the drive map preference item by choosing the Action of the item. Drive map actions include CreateReplaceUpdate, andDelete. These are the actions commonly found in most preference items. Create and Delete actions are self-explanatory. The compelling difference between Replace and Update is that Replace deletes the mapped drive and then creates a new mapped drive with the configured settings. Update does NOT delete the mapped drive– it only modifies the mapped drive with the new settings. Group Policy Drive Maps use the drive letter to determine if a specific drive exists. The preceding image shows a Drive Map preference item configure with the Replace action. The configured location is a network share named data; hosted by a computer named hq-con-srv-01. The configured drive letter is the G drive. All other options are left at their defaults. This GPO is linked at the contoso.com domain.
The results of this configuration are seen when using Windows Explorer on the client computer. The following picture shows a user’s view of Windows Explorer. We see there is one network location listed here, which is the G drive that is mapped to \hq-con-srv-01data.
image
Figure 2 Public drive map client view
Later, we’ll see how to use exclusive drive mappings with public drive mappings as a way to exclude public drive mappings from a subset of users.

Inclusive drive mapping

Inclusive drive mappings are drives mapped to a user who is a member of (or included) in a specific security group. The most common use for inclusive drive maps is to map remote data shares in common with a specific sub set of users, such as accounting, marketing , or human resources. Configuring an inclusively mapped drive is the same as a public drive mappings, but includes one additional step. The following image shows us configuring the first part of an inclusive drive mapping preference item.
image
Figure 3 Inclusive drive mapping
Configuring the first part of an inclusive drive mapping preference item does not make it inclusive; it does the work of mapping the drive. We must take advantage of item-level targeting to ensure the drive mapping items works only for users who are members of the group. We can configure item level targeting by clicking the Targeting button, which is located on the Common tab of the drive mapping item. The targeting editor provides over 20 different types of targeting items. We’re specifically using the Security Group targeting item.
image
Figure 4 Security group targeting item
Using the Browse button allows us to pick a specific group in which to target the drive mapping preference item. Security Group targeting items accomplishes its targeting by comparing security identifiers of the specified group against the list of security identifiers with the security principal’s (user or computer) token. Therefore, always use the Browse button when selecting a group; typing the group name does not resolve the name to a security identifier.
image
Figure 5 Configured inclusive security group targeting item
The preceding screen shows a properly configured, inclusive targeting item. A properly configured security group targeting item shows both Group and SID fields. The Group field is strictly for administrative use (we humans recognize names better than numbers). The SID field is used by the client side extension to determine group membership. We can determine this is an inclusive targeting item because of the text that represents the item within the list. The word is in the text “the user is a member of the security group CONTOSOManagement.” Our new drive map item and the associated inclusive targeting item are now configured. We can now link the hosting Group Policy object to the domain with confidence that only members of the Management security group receive the drive mapping. We can see the result on a client. The following image shows manager Mike Nash’s desktop from a Windows Vista computer. We can see that Mike receives two drive mappings: the public drive mapping (G: drive) and the management drive mapping (M: drive).
image
Figure 6 Client view of inclusive drive mapping

Exclusive drive mapping

The last scenario discussed is exclusive drive mapping. Exclusive drive mappings produce the opposite results of an inclusive drive mapping; that is, the drive map does NOT occur if the user is a member of the specified group. This becomes usefully when you need to make exceptions to prevent specific drives from mapping. Let’s add an exclusive drive mapping to our public drive mapping to prevent specific members of management from receiving the public drive mapping.
image
Figure 7 Configured exclusive drive mapping
The preceding image shows the changes we made to the public drive mapping (from the first scenario). We’ve added a Security Group targeting item to the existing public drive mapping preference item. However, the targeting item applies only if the user IS NOT a member of the ExcludePublicDrives group. We change this option using the Items Options list. The client view of manager Monica Brink shows the results of applying Group Policy.
image
Figure 8 Client view of exclusive drive mapping
This client applies two Group Policy objects; each containing a drive mapping preference item. One item contains our public drive mapping with an exclusive security group targeting item. The other GPO contains the management drive mapping with an inclusive security group targeting item. The client processes the public drive mapping GPO; however, the exclusive targeting item verifies that Monica is a member of the ExcludePublicDrives group. Monica is also a member of theManagement group. Therefore, Monica’s group memberships prevent her from receiving the public drive mapping and include her in receiving the management drive mapping.

Summary

Drive mapping preference items do not require any scripting knowledge and are easy to use. Leveraging targeting items with drive mapping items increases the power in which to manage drive mapping to users and computers. Public drive mappings are typically linked at higher levels in the domain and generally apply to a large subset (if not all) users. Inclusive drive mappings associate as specific subset of data with a specific group of people, often times mapping to logical divisions within an organization such as accounting, marketing, or human resources. Exclusive drive mappings invert the principals of inclusive drive mappings. The user must not be a member of the specified group for the drive mapping to occur.

Best practices

Be sure to link GPOs high enough in Active Directory so the scope of the drive mapping effects the largest group of user accounts. Obviously, not every GPO should be linked at the domain; however, if there is an accounting organizational unit with three child OUs– then linking at the Accounting OU effects that largest amount of users. Allow your inclusive and exclusive targeting item to do the bulk of your work. GPOs hosting inclusive drive mappings are best used when the number of user needing the drive mapping are fewer than the number who do not. Exclusive drive mappings are best used when the number of user not requiring the drive mapping are fewer than the number that do. These rules help prevent users from becoming members of too many groups and increasing the cost of managing drive mappings within the organization.

Windows Server AD: Using Group Policy to configure Desktop Wallpaper

Had to configure a GPO at a client this morning that added a custom wallpaper to the users desktop. I used THIS site to do it.

Group Policy is of course one of the best ways you can lockdown and configure your windows systems in your environment and one of the most commonly configured setting in Group Policy is the ability to configured the Desktop Wallpaper (a.k.a. Background) image. Now most of you might just say is all you need to do is set the  group policy setting however there are some common traps that you might fall into if you don’t use this setting correctly.

Method #1: Administrative Template “Desktop Wallpaper” Setting

The “Desktop Wallpaper” method is of course the most commonly used way for configuring the Wallpaper on a computer however as it seems with all things Group Policy using this setting comes with its own pro’s and con’s.
Pro’s
  • Change is Restricted for the users
  • Works on all versions of Windows
Con’s
  • Limited targeting only based on standard Group Policy Object’s (OU,Security Filter,Site,WMI & Domain)
This setting can be found under User Configuration > Administrative Templates > Desktop > Desktop and is straight forward to configure as all you have to do is specify the explicit local path or a UNC to the image you want displayed as the desktop wallpaper (see below).
image
Behind the scenes all this setting is doing is configuring the REG_SZ “Wallpaper” and the REG_SZ “WallpaperStyle”  registry keys under the HKCUSoftwareMicrosoftWindowsCurrentVersionPoliciesSystem  path.
TIP #1: If you are running Windows 7/Server 2008 R2 pre-Service Pack 1 you will need to install hotfixhttp://support.microsoft.com/kb/977944 for this setting to work.
TIP #2: If you are configuring this setting I recommend that you use the “Fill” Wallpaper Style as this will work best with most screen resolutions (especially on Windows 7).
TIP #3: If you configure this setting you will need to wait for the user to logoff the computer before the background is updated.

Method #2: Group Policy Preferences Registry Key Wallpaper Configuration

As I mention in Method #1 all the Administrative Template “Desktop Wallpaper” does is configure the HKCUSoftwareMicrosoftWindowsCurrentVersionPoliciesSystem REG_SZ “Wallpaper” key. Therefore you can also use the Group Policy Preference Registry Extension option to also set the same key to give you some added benefits.
Pro’s
Con’s
  • Must run Windows XP (or greater)
  • Must have the Group Policy Client Side Extensions installed.
To configured the Desktop Wallpaper the same as the “Desktop Wallpaper” administrative template simply create two registry keys User Configuration > Preferences > Windows Settings > Registry (see below). Now depending on the registry key that you configure for this setting you can either have this as a restricted (a.k.a. locked) setting or an unrestricted setting that allows the users to make their own changes.
Restricted: HKCUSoftwareMicrosoftWindowsCurrentVersionPoliciesSystemWallpaper
Unrestricted: HKCUControl PanelDesktopWallpaper
image
Restricted: HKCUSoftwareMicrosoftWindowsCurrentVersionPoliciesSystemWallpaperStyle
Unrestricted: HKCUControl PanelDesktopWallpaperStyle
image
Tip #4: If you don’t configured the “WallpaperStyle” registry key then users will still be able to choose their own Wallpaper Style.
If you chose the restricted registry keys to configured the wallpaper then ensure you also select the “Replace” action and “Remove this item when it is no longer applied” common option is selected (see below). If you don’t do this you will find that your users will not be able to change their wallpaper even after the policy is removed as the policy registry key will not be removed.
image
image
If you chose to use the unrestricted registry key values then also make sure you chose the “Apply once and do not reapply” option. If you don’t do this the users wallpaper will be reset ever time they log off their computer as the key will be set back to the original value during each policy refresh.
image

Configuring the Desktop Wallpaper Storage Location

Now that you know the many options for configuring the Desktop Wallpaper via Group Policy the next thing you should consider is where is the wallpaper being stored. As you can seen in the screen shots of the administrative template Desktop Wallpaper that they use the example of a UNC path. But…
image
TIP #5: DONT EVER USE A UNC PATH FOR A DESKTOP WALLPAPER… EVER!!
Simple put using a UNC path puts a lot of stress on network as it has to download file every time the wallpaper is loaded. It also means that if the network path cannot be contacted when the user logs on all they will get is a black background wallpaper. This is particularly obvious when someone logs on with a laptop not connected LAN.
So the obviously question is how do you make sure that file that the desktop wallpaper uses is always available and easily accessible? Use a script and copy the file to the local hard drive. Sure… buthttp://ihatelogonscripts.com and the issue with using a script is that it will only run when the computer starts up or when the user logs on. Generally this would not be a problem and if you are smart enough to use a copy program like robocopy or other such program it wont stress your LAN as it will only copy the file once. But on the day that you change the desktop wallpaper ever computer and/or user will try to download the new wallpaper all at once.
The Answer? Use Group Policy Preferences File Extension and copy the file down to the local computer.

Using the Group Policy Preferences File Extension

Using the File Extension to copy the file to the local hard drive means the file will be copied to the local hard drive making obviously available at all times. However the File Extensions options also has the advantage of being able to updated the file during each group policy refresh. This way the computer gets the updated wallpaper without having to logoff or reboot the computer and you avoid slamming the network in the morning when all the computers turn on.
image
TIP #6: Setup the file copy as a computer setting so that it will update the files even when there is no user logged on.
TIP #7: If you follow Tip #6 then you need to make sure that the desktop wallpaper file has got “Domain Computers” Read permissions so the local system account has access to copy the file from the network.
So by now, hopefully you know how to set the desktop wallpaper and so you can ensure that the images you use for the wallpaper are always available that way you  can ensure that your users are always subjected to your corporate desktop wallpaper.

Installing WordPress on Ubuntu 14.04 server

I had to install a wordpress server for a client today. I used the instructions from THIS site.

How To Install WordPress on Ubuntu 14.04

Apr 24, 2014 WordPress Ubuntu

Introduction

At this time, WordPress is the most popular CMS (content management system) on the internet. It allows you to easily set up flexible blogs and websites on top of a MySQL backend with PHP processing. WordPress has seen incredible adoption and is a great choice for getting a website up and running quickly.
In this guide, we’ll focus on getting a WordPress instance set up with an Apache web server on Ubuntu 14.04.

Prerequisites

Before you begin this guide, there are some important steps that you need to complete on your server.
We will be proceeding through these steps as a non-root user with sudo privileges, so you will need to have one available. You can find out how to create a user with sudo privileges by following steps 1-4 in our Ubuntu 14.04 initial server setup guide.
Additionally, you’ll need to have a LAMP (Linux, Apache, MySQL, and PHP) stack installed on your VPS instance. If you don’t have these components already installed and configured, you can use this guide to learn how to install LAMP on Ubuntu 14.04.
When you are finished with these steps, you can continue with this guide.

Step One — Create a MySQL Database and User for WordPress

The first step that we will take is a preparatory one. WordPress uses a relational database to manage and store site and user information.
We have MySQL installed, which can provide this functionality, but we need to make a database and a user for WordPress to work with.
To get started, log into the MySQL root (administrative) account by issuing this command:

mysql -u root -p

You will be prompted for the password you set for the MySQL root account when you installed the software. You will then be given a MySQL command prompt.
First, we can create a separate database that WordPress can control. You can call this whatever you would like, but I will be calling it wordpress because it is descriptive and simple. Enter this command to create the database:

CREATE DATABASE wordpress;

Every MySQL statement must end in a semi-colon (;), so check to make sure this is present if you are running into any issues.
Next, we are going to create a separate MySQL user account that we will use exclusively to operate on our new database. Creating one-function databases and accounts is a good idea from a management and security standpoint.
I am going to call the new account that I’m making wordpressuser and will assign it a password of password. You should definitely change the password for your installation and can name the user whatever you’d like. This is the command you need to create the user:

CREATE USER wordpressuser@localhost IDENTIFIED BY 'password';

At this point, you have a database and a user account, each made specifically for WordPress. However, these two components have no relationship yet. The user has no access to the database.
Let’s fix that by granting our user account access to our database with this command:

GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost;

Now the user has access to the database. We need to flush the privileges so that the current instance of MySQL knows about the recent privilege changes we’ve made:

FLUSH PRIVILEGES;

We’re all set now. We can exit out of the MySQL prompt by typing:

exit

You should now be back to your regular command prompt.

Step Two — Download WordPress

Next, we will download the actual WordPress files from the project’s website.
Luckily, the WordPress team always links the most recent stable version of their software to the same URL, so we can get the most up-to-date version of WordPress by typing this:

cd ~
wget http://wordpress.org/latest.tar.gz

This will download a compressed file that contains the archived directory contents of the WordPress files to our home directory.
We can extract the files to rebuild the WordPress directory we need by typing:

tar xzvf latest.tar.gz

This will create a directory called wordpress in your home directory.
While we are downloading things, we should also get a few more packages that we need. We can get these directly from Ubuntu’s default repositories after we update our local package index:

sudo apt-get update
sudo apt-get install php5-gd libssh2-php

This will allow you to work with images and will also allow you to install plugins and update portions of your site using your SSH login credentials.

Step Three — Configure WordPress

Most of the configuration that we will be doing will be through a web interface later on. However, we do need to do some work from the command line before we can get this up and running.
Begin by moving into the WordPress directory that you just unpacked:

cd ~/wordpress

A sample configuration file that mostly matches the configuration we need is included by default. However, we need to copy it to the default configuration file location to get WordPress to recognize the file. Do that now by typing:

cp wp-config-sample.php wp-config.php

Now that we have a configuration file to work with, let’s open it in a text editor:

nano wp-config.php

As I said before, this file is almost entirely suitable for our needs already. The only modifications we need to make are to the parameters that hold our database information.
We will need to find the settings for DB_NAME, DB_USER, and DB_PASSWORD in order for WordPress to correctly connect and authenticate to the database we created.
Fill in the values of these parameters with the information for the database you created. It should look like this:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

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

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

These are the only values that you need to change.
When you are finished, save and close the file.

Step Four — Copy Files to the Document Root

Now that we have our application configured, we need to copy it into Apache’s document root, where it can be served to visitors of our website.
One of the easiest and most reliable way of transferring files from directory to directory is with the rsync command. This preserves permissions and has good data integrity features.
The location of the document root in the Ubuntu 14.04 LAMP guide is /var/www/html/. We can transfer our WordPress files there by typing:

sudo rsync -avP ~/wordpress/ /var/www/html/

This will safely copy all of the contents from the directory you unpacked to the document root.
We should now move into the document root to make some final permissions changes

cd /var/www/html

You will need to change the ownership of our files for increased security.
We want to give user ownership to the regular, non-root user (with sudo privileges) that you plan on using to interact with your site. This can be your regular user if you wish, but some may suggest that you create an additional user for this process. It is up to you which you choose.
For this guide, we will use the same account that we set up during the initial server setup guide, which we called demo. This is the account I am performing all of the actions of this guide as.
The group ownership we will give to our web server process, which is www-data. This will allow Apache to interact with the content as necessary.
We can quickly assign these ownership values by typing:

sudo chown -R demo:www-data *

This will set up the ownership properties that we are looking for.
While we are dealing with ownership and permissions, we should also look into assigning correct ownership on our uploads directory. This will allow us to upload images and other content to our site. Currently, the permissions are too restrictive.
First, let’s manually create the uploads directory beneath the wp-content directory at our document root. This will be the parent directory of our content:

mkdir /var/www/html/wp-content/uploads

We have a directory now to house uploaded files, however the permissions are still too restrictive. We need to allow the web server itself to write to this directory. We can do this by assigning group ownership of this directory to our web server, like this:

sudo chown -R :www-data /var/www/html/wp-content/uploads

This will allow the web server to create files and directories under this directory, which will permit us to upload content to the server.

Step Five — Complete Installation through the Web Interface

Now that you have your files in place and your software is configured, you can complete the installation through the web interface.
In your web browser, navigate to your server’s domain name or public IP address:

http://server_domain_name_or_IP

You will see the WordPress initial configuration page, where you will create an initial administrator account:
Wordpress initial config
Fill out the information for the site and the administrative account you wish to make. When you are finished, click on the install button at the bottom.
WordPress will confirm the installation, and then ask you to log in with the account you just created:
WordPress confirm install
Hit the button at the bottom and then fill out your account information:
WordPress login
You will be presented with the WordPress interface:
WordPress admin interface

Step Six (Optional) — Configure Pretty Permalinks for WordPress

By default, WordPress creates URLs dynamically that look something like this:

http://server_domain_name_or_IP/?p=1

This isn’t exactly the most useful interface for visitors or search engines, so most users want to modify this. WordPress has the ability to create “pretty” permalinks which will clean up the URL into a more human-friendly format.
There are a few things we need to do to get this to work with Apache on Ubuntu 14.04.

Modifying Apache to Allow URL Rewrites

First, we need to modify the Apache virtual host file for WordPress to allow for .htaccess overrides. You can do this by editing the virtual host file.
By default, this is 000-default.conf, but your file might be different if you created another configuration file:

sudo nano /etc/apache2/sites-available/000-default.conf

Inside of this file, we want to set up a few things. We should set the ServerName and create a directory section where we allow overrides. This should look something like this:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ServerName server_domain_name_or_IP
    <Directory /var/www/html/>
        AllowOverride All
    </Directory>
    . . .

When you are finished, save and close the file.
Next, we need to enable the rewrite module, which allows you to modify URLs. You can do this by typing:

sudo a2enmod rewrite

After you have made these changes, restart Apache:

sudo service apache2 restart

Create an .htaccess File

Now that Apache is configured to allow rewrites through .htaccess files, we need to create an actual file.
You need to place this file in your document root. Type this to create an empty file:

touch /var/www/html/.htaccess

This will be created with your username and user group. We need the web server to be the group owner though, so we should adjust the ownership by typing:

sudo chown :www-data /var/www/html/.htaccess

We now have the correct ownership of this file.
We may need to adjust the permissions however. This depends on how you prefer to work. WordPress will generate the necessary rewrite rules for you. If it has write permissions to this file, it can implement the rules automatically. If it does not, you will have to manually edit this file to add the correct rules.
Which configuration you choose depends on how much you value convenience over security. Allowing the web server write access to this file will definitely be more convenient, but some say that it is an unnecessary security risk.
If you want WordPress to automatically update this file with rewrite rules, you can ensure that it has the correct permissions to do so by typing:

chmod 664 /var/www/html/.htaccess

If you want to update this file manually for the sake of a small security gain, you can allow the web server only read privileges by typing:

chmod 644 /var/www/html/.htaccess

Change the Permalink Settings in WordPress

When you are finished doing the server-side changes, you can easily adjust the permalink settings through the WordPress administration interface.
On the left-hand side, under the Settings menu, you can select Permalinks:
WordPress permalinks
You can choose any of the preconfigured settings to organize URLs, or you can create your own.
WordPress perma options
When you have made your selection, click “Save Changes” to generate the rewrite rules.
If you allowed the web server write access to your .htaccess file, you should see a message like this:
WordPress perma update
If you did not allow the web server write access to your .htaccess file, you will be provided with the rewrite rules you need to add to the file manually.
Copy the lines that WordPress gives you and then edit file on your server:

nano /var/www/html/.htaccess

This should give you the same functionality.

Conclusion

You should now have a WordPress instance up and running on your Ubuntu 14.04 VPS. There are many avenues you can take from here. Below we’ve listed some options: