Where to find pre-installed virtual machines for local WordPress testing under Virtualbox?

Hello friends,

If you remember our post about virtual machines running under Virtualbox then you are probably wondering if it is possible to find pre-installed solutions that you can import and start using for local WordPress tests.

The great news is that this is possible. In this post I will show you where you can find pre-installed virtual machines for local WordPress testing under Virtualbox.

If such solutions exist, should I use them instead of configuring an Ubuntu (or other) server under Virtualbox by myself?

In terms of local testing – yes. But if you are aiming to use them for other purposes, I’d advise to either start installing or configuring the server by yourself or at least to check the configuration of the pre-installed solution and improve it if necessary. For production servers, based on virtual machines, I’d advise to seek for assistance from an experienced system administrator. Let’s not forget to mention that there are far more advanced solutions than Virtualbox for this purpose (for example Open Stack).

The reason that I am giving you this advice is because the pre-installed solutions are meant to save you time and effort. This may be enough for local testing in most cases, however for other purposes these virtual machines might lack in security. Also even for local WordPress testing you may need to configure them additionally in order to make all of your plugins function correctly.

OK, where can I find these pre-installed virtual machines?

Some of the machines contain only a Linux distribution without any additional configuration. These machines are meant to remove the need to make a new installation and basic configuration. Once you download them and import them in Virtualbox you can install and configure LAMP so that you can run WordPress locally.

Such machines can be found from OSBoxes (click to visit). There you can find images for both Virtualbox and VMware. Select the distribution that you desire to use and then follow the instructions provided on the website. You will find out the username and the password that were created for the virtual machine.

Here is what you need to do in order to use the machine: Add a new virtual machine in Virtualbox. Select the appropriate distribution and then follow the wizard until you reach the section that asks you to either create a new virtual disk or to use an existing one. Simply point the VDI or VMDK file that you have downloaded from OSBoxes and complete the virtual machine configuration. Once you run it you will get a pre-installed Linux with graphical interface. For additional configurations you need to update the distribution and also install VirtualBox Guest Add-Ons. Then you need to install and configure LAMP.

Other solutions provide LAMP Stack in a pre-installed virtual machine. Once you import/add them in Virtualbox you need to follow additional steps and apply a few settings and then you will be able to configure your databases and run WordPress locally. Turnkey Linux provides such machine. You can download it from here.

Finally there are solutions that even contain WordPress within them and you can start adjusting the sample local site right away. Turnkey Linux has such a machine which can be downloaded from here.

Another option is to use a Bitnami virtual machine. You can grab one from here.

From this website you can download another pre-installed WordPress virtual machine.

So there you have it friends. Will you use pre-installed virtual machines or will you try to configure your own one? Share any thoughts on this topic in the comment section below. If you have any questions – we will be happy to assist you.

See you soon, friends!

How to quickly restore Facebook comments to your WordPress website after migration to SSL

Hello friends,

In today’s post I will share with you one quick and easy to apply fix for your “lost” Facebook comments after you’ve managed to move your website to SSL.

Before we begin – let’s define when this tutorial will be useful for you.

First of all you have to be using Facebook comments for your WordPress website. As you know from our previous posts on the topic, this is a great way to allow more people to get involved with your content without the need of additional registrations. Also each Facebook comment increases the popularity of your website within the social media.

For the purpose of this tutorial you may need to use the plugin “Facebook Comments”. Read more about it here: Facebook Comments for WordPress.

Second – this tutorial will be useful if you have just migrated from non-SSL to a SSL version of your WordPress website by using the “Really Simple SSL” plugin. Read how to achieve this from our post: Really Simple SSL – the proper way to secure WordPress.

Now let’s assume that you have been using Facebook Comments for a while before the migration to SSL. You have set up the plugin correctly and your visitors have commented on your website at least once and you are sure that the comments have been displayed correctly. Then you have decided to migrate to SSL and the comments are gone.

This is where our tutorial begins. Prepare to learn how to quickly restore Facebook comments to your WordPress website after migration to SSL!

Your Facebook comments are not lost! You can check them out in your moderation tool. They may have been disabled or hidden, but they are still there. Re-enable them if needed and then return to your WordPress website.

Create a child theme if you haven’t done this already. This will ensure that your Facebook comments won’t get lost again during your theme’s update. If you have set up your child theme successfully simply create a new functions.php file for it. This can be a blank file (i.e. without any content in it). Save it and then edit it.

Add the following code:

function rsssl_exclude_http_url($html) { 
//replace the https url back to http 
$html = str_replace('data-href="https://www.domain.com', 'data-href="http://www.domain.com', $html); 
return $html; 
} 
add_filter("rsssl_fixer_output","rsssl_exclude_http_url");

Change domain.com to your website’s domain name (with or without www). Do this for both entries (http and https) in the code above. Save the file and clear your cache.

Reload the post or page where you were certain that you had Facebook comments before the migration to SSL. They should be back once again.

In case you are not using a child theme you can add this code to your main functions.php file and save it. However when your theme gets updated this code will be lost and you will need to re-enter it once again.

That’s all friends! For more information and other solutions for the “lost” Facebook comments after migrating to SSL for your WordPress website, please read this post: How to recover Facebook likes after moving to https/ssl.

If you have any questions or other feedback, please share them in the comment section below. See you soon, friends!

What should you use for your local WordPress tests and development? XAMPP or Virtualbox? Find out now from this post:

Hello friends,

In this post I will present to you two of the most popular solutions for local WordPress tests and development. They are suitable for beginners and medium-skilled users.

The solutions that I am about to review in details are called XAMPP and Virtualbox.

But first things first! Why would you even consider using a solution for your local WordPress tests and development?

Because this may save you valuable time and effort as well as it may prevent some potential problems when creating a WordPress website directly on the production server with the real domain name.

Let’s imagine that you can build a simple WordPress website for a couple of days or a week at most. If you begin this process directly on your production server this means that you will have to purchase it in advance. This is also related to the purchase of a new domain name if you do not have an older one for test purposes that you can use to the production server.  So in most situations you will have to spend money and then start building your website from scratch.

If you are a complete beginner you may allow search engines to index your website when it is under development. In some cases this might cause potential problems with re-indexation later on. And if you are preventing the bots from indexing your project then you are wasting a week with a paid domain and hosting without getting any initial SEO results. And if something goes wrong you will have to start from scratch once again (in case you do not have backups) or start from a backup. But this will slow things even more.

Now imagine if you need to build an advanced website using WordPress. You can guess that you will need more time and the risks of breaking something are increased as well.

While the time and effort might still be the same when developing locally, you are saving time, effort and money for yourselves or for your clients for the SEO and digital marketing for the website. Why? Because it is better to upload and set up a complete WordPress installation that may launch immediately and start getting visits.

All of the above reasons were related to the creation of new websites. But what about your existing one when you need to try a new plugin? Doing this directly on the production server comes with a risk of breaking the theme or the functionality of the website due to incompatibilities. The latter might be PHP related, plugin related, theme related and etc.

Once again it is better to do tests locally and when the results are as expected to apply the changes on the production server.

OK, I am convinced! What is the difference between XAMPP and Virtualbox and what do I need to start developing or testing WordPress locally with them?

XAMPP for local WordPress tests and development

XAMPP is a project that provides you with a local server powerful enough to launch your WordPress website and easy enough to be the most suitable solution for beginners. All you need to do is download it from apachefriends.com and install it. You will find builds for Windows, Linux and OS X. After you are done installing you need to create a new directory under htdocs. In this directory place your WordPress installation. Lets assume that you call it localwp.

Start the XAMPP control panel and launch PHP and MySQL.

Then create a database using the built-in PHPMyadmin and edit wp-config.php with the needed information. After this you can access your local website in your browser by typing localhost/localwp (the name of the directory that you created).

Now you may begin developing a new website or testing your current one by transferring a backup copy to the local website.

In some situations you will need to adjust some settings but there are lots of tutorials online on how to achieve this. Also XAMPP makes it super easy to do this.

For more information, please view the following video:

Virtualbox can be used for Ubuntu server installation in order to develop and test WordPress locally

Virtualbox is an open source solution that will allow you to run virtual machines on your computer. Download it from here: www.virtualbox.org

In our case you might want to install Ubuntu server (or similar) and configure it locally. In this virtual server you can begin developing or testing your WordPress website.

Virtualbox can be useful for your local WordPress website creation and testing.

VirtualBox 5.0 for Windows. Within VirtualBox Ubuntu 14.04 is running. The image is embedded from the official Virtualbox’s website.

There are many guides on how to achieve this and it is not that hard. However I’d recommend this for medium and advanced users as beginners might face some problems and difficulties.

What are the advantages and disadvantages of each of these solutions?

I will make the comparison based on the following criteria:

  1. Speed and resource usage – in my opinion a virtual machine using Virtualbox and Ubuntu server is running faster and is saving more resources than XAMPP. However this might be different for you as it depends on your hardware configuration.
  2. Ease of usage – XAMPP is easier for beginners.
  3. Flexibility – XAMPP is limited to the PHP and MySQL versions that come with the current build. On the other hand the virtual server under Virtualbox will provide you with enough flexibility to choose exactly the tools that you need for your website.
  4. Possibility to add control panels – this is not a problem for the virtual server running under Virtualbox. A control panel provides more options and makes you feel like you are working on the real production server.
  5. Access from clients and other users – both solutions can do this. For XAMPP you will need to add your IP address as WordPress address in the admin panel of your website and save the permalink structure. Then instead of using localhost you can use your IP address and thus the local site can be accessed.
    Virtualbox however makes this easier and the website can be accessed by IP by default. You do not need to make changes to your WordPress admin panel. But what is more important is that Virtualbox and Ubuntu server can allow you to create multiple virtual hosts. For each of them you can have a stand-alone website that can be access by your clients and other users. All you need to do is to set the local domain names under your hosts file and by pointing your IP to each of them. Then you need to instruct your clients and users to do the same and the local websites can be accessed. For these cases I like to use .loc domain names. They are not real but for the purpose of local tests they are great. You can use whatever domain names you want. For example – .dev, .test and so on. When the website is completed and transferred to the production server the only change in the database for the domain name will be the end part. For example from .loc to .com.

So these are my criteria for comparing the two solutions. What do you think friends? Which one is the most suitable for you?

Before I end this post, I’d like to share some useful links with you:

See you soon, friends!

Breadcrumbs in WordPress – what are they and how to enable them

Hello friends,

In this post I will present to you the idea behind one popular and important link navigation for any website. This structure is called breadcrumbs.

What are breadcrumbs?

Have you ever read Hansel and Gretel? If so you are familiar with the trail of breadcrumbs that they leave behind in order to find their way back to their house. Well, the idea is similar when we are viewing breadcrumbs as a navigation structure for WordPress and any other website in general.

Of course your visitors won’t get lost when they reach one page or another and they can always find a way back to the homepage. However the idea here is to make it as easy and convenient as possible for them to go back to any previous page in the trail with just one click.

Imagine the following situation: You have a blog post called “blog-post1” under the category “category-1”. This category has a page that any user can access and see all blog posts under it. Your WordPress website is set to have the following URL structure:

domain-name/category-1/blog-post1

Then a good idea for a breadcrumb navigation will be the possibility to provide a trail for all of these pages that displays their names instead of URL strings.

For example:

Home Page > Category 1 > Blog Post 1

Then any user that is currently on Blog Post 1 can with one click return to the category page or to the home page if needed. Now imagine this situation in a more complex environment where under one main page there are several sub-pages and each of them have their own sub-pages. In this case a breadcrumb navigation is not only convenient but in my opinion also needed.

Why breadcrumbs are also extremely useful for SEO?

The bots are crawling your WordPress website. You want them to be able to reach any page or post with ease so that it can get indexed and ranked. That is why there is an imperative need of perfect menu and navigation structures so that the bots can be eased in their tasks as much as possible.

When you provide them with a breadcrumb navigation structure you are making it extremely easy for them to find out which page is the parent and which are its child pages. This will result in better indexation and also better ranking.

Also having a breadcrumb navigation structure will change the way your website is displayed in the search results. Instead of showing URL’s, visitors will be able to see the navigation path that the bots have indexed. This will result in an additional keywords that can be indexed. Also in this way there is better usability as the users will be able to read easily the names of the pages in the trail instead of their URL strings.

How to add breadcrumbs in WordPress?

If you are using Yoast SEO then you can use its features and enable great-looking breadcrubms.

Yoast SEO can be used to add breadcrumbs in WordPress

This can be done under SEO Settings → Advanced → Breadcrumbs. Choose the way you want to display your breadcrumbs in the fields below. Then visit this link (click here) and follow the guide in order to implement the breadcrumbs in the code of your WordPress theme. Bear in mind that this is not recommended to be done by beginners and you are encouraged to contact the theme developers for a permanent solution.

Another option is to use the plugin Breadcrumb NavXT. You can get it from WordPress.org or by using the plugin installer system in your WordPress admin panel.

Breadcrumb NavXT is another great solution for adding breadcrumbs in WordPress

A third option is to choose a theme that has a breadcrumb navigation support by default.

That’s all friends! If you have any questions share them in the comment section below. See you soon, friends!

Migrate, backup or clone WordPress with Duplicator

Hello friends,

Sooner or later we might have to consider moving our website to a new location. There are various reasons for this decision but the most important one is that we are somehow not happy with our current hosting provider and we have found a more suitable one.

When this happens we have to make a complete clone of our WordPress website. This applies for both directories, files and database(s). This new clone has to be placed on the new host and then additional settings have to be made in order to use the domain on the new location (DNS settings, forwarding, etc). The latter are not WordPress related so let’s assume that you have already discussed these with the new hosting provider and you have applied them according to the instructions that you have received from them.

So the main question remains – how to clone WordPress in order to transfer it to the new hosting location?

In this post I will present to you one of the suitable solutions for this purpose. This is the plugin “Duplicator”.

Duplicator - WordPress Plugin for backup, cloning and website migration

What does Duplicator do?

Its main functionality is related to everything described above – cloning a WordPress website so that it may be transferred to a new hosting or even a new domain. However this plugin is much more powerful than this. It may be used as an excellent backup tool and thus you can be sure that your data is always protected in case of a website failure or some other problem (for example hacking).

How to work with Duplicator?

Before we begin with these instructions, I need to inform you that this plugin comes in two versions. One is 100% free and you can download it right now from WordPress.org. You can also install it directly on your WordPress website by using the plugin installer to search for Duplicator. Then you have to activate it and start using it. The review will cover the free version. However there is a PRO version of Duplicator which provides you with much more options and features. You can find information about it later on in this article.

So, now that you know how to get Duplicator working on your website, let’s see how to use it.

First of all you need to head to your WordPress dashboard and click on the Duplicator menu. From there you can see two tabs. One is called “Packages” and it lists all of the cloned copies that the plugin has created.

Duplicator Package Management

You will be able to manage these packages similar to the way you manage your WordPress posts and pages. Here you can see details about each clone copy, its creation date, file size and name.

The options are:

The first option allows you to download an installer file in PHP format that you need to upload to your new location. The second contains the actual data (database and files) of your current website. You need to upload this file once again on the new location.

There are bulk options here available as well. The details view for each package provides you with the possibility to view the version number, the user that has created it, the Hash number of the package and some notes (if any are available). You can also get links for the package, its SQL file and view the log.

The second tab (Create New) allows you to create a package. This process passes through 3 steps: Setup, Scan and Build.

Duplicator - Package creation

In the first step the creation wizard will ask you to provide a name for the package and some notes (if you want). Then you can choose the file format for the Archive and apply some filters for the files. You can adjust some options regarding to the Database as well.

Then you can adjust some options about the Installer file as well and when you are done you can proceed with Step 2. Bear in mind that you may actually leave the default options (for both Archive and Installer) if you don’t want to apply any settings.

When done you need to click on the “Next” button in order to start Step 2 – Scan. You are also able to skip this step if you want. You may also reset any settings that you have made on Step 1.

Clicking on the “Next” button will initiate the scan procedure. You will be able to monitor its progress and when it’s done you will be presented with a full overview of the package. This consists of information related to the server status, archive file, database file. For the server settings you may apply diagnostics in case some problems are shown in the overview. You are also able to rescan your website or even go back to Step 1.

In case you are happy with what you see on the overview you need to click on the “Build” button. This will start Step 3 and will actually build the package and the installer file. Once again you can monitor the progress and when Duplicator is done you will see that the process is completed as well as the name of the package and the time it took to build it.

You can also download the installer  and the archive files directly from this screen.

In order to move your website to a new location, you have to upload both files and then access the installer.php file from the URL. For example let’s assume that your new domain is newdomain.com. The URL for the installer file should be:

newdomain.com/installer.php

Then you have to follow the instructions. Again you will pass through 3 steps – Deploy, Update and Test. When done your website will be transferred successfully on the new domain and/or hosting.

Duplicator - Installer for migrating the clone package to a new location

Duplicator also has some settings that you might want to check out.

For detailed explanation of how Duplicator works you may watch this video:

What is the difference between the free and PRO version of Duplicator?

Huge! The free version is quite limited to smaller file sizes and basic cloning operations. The PRO version provides you with much more power. These differences are described in details here: Versions comparison page.

So what do you think of this plugin, friends? Would you use it? Share your thoughts in the comment section below and spread the word about this post in social media as well.

See you soon!

*The images are embedded from the WordPress.org page of the plugin

UpdraftPlus – The supreme solution for WordPress backup

Hello friends,

We are back on the topic related to backup! As you know this is a very important thing related to each website or web project. And when it comes to a CMS system like WordPress where you are presented with regular updates then you should really take into consideration the best practices for creating and restoring backups.

In this post I will present another solution that can be easily marked as a supreme solution. This WordPress plugin is called UpdraftPlus.

What this plugin does?

UpdraftPlus is a solution for backup and restoration. Simple as that but in the mean time it offers a vast majority of important options that will ease your backups and increase your overall data protection in case of a failure related to your database or files.

So to summarize the main functions of UpdraftPlus – it is a supreme solution that will take care for the backups of your WordPress files and database and it will also aid you in their restoration in case of website failure and data loss.

Why I should choose UpdraftPlus instead of the many other plugins for WordPress?

This post is not a comparison between the different plugins. So in most cases you might be safe if you use any of the high-rated backup solutions that are available on WordPress.org.

However you will find that UpdraftPlus will be working extremely fast and well with your WordPress website. It is also extremely easy to use solution that will be suitable even for beginners which is another plus.

So let’s point out all of the features that you will get when you download, install and activate UpdraftPlus:

This plugin is suitable for all current PHP versions. UpdraftPlus also offers a premium version that extends the backup and restoration power by adding more backup destinations and features. UpdraftPlus can also serve as a duplicating solution for whole websites. This means that if you intend to move your WordPress from one host and/or domain to another then you can rely on this plugin to aid you in this task.

The premium version of UpdraftPlus also offers great support and you can also contract professional support for any enterprise projects that are utilizing the power of WordPress. And if you are using another backup solution then you will be glad to find out that UpdraftPlus can aid you in restoration from a backup made by it. This is very useful if you want to restore your website to an earlier version before the first backup created using UpdraftPlus. Currently you can benefit from this feature if you are a premium user and if your old backups are created from BackWPUp, BackupWordPress, Simple Backup, WordPress Backup To Dropbox.

The premium version of UpdraftPlus also provides options for encryption of the database backups in order to improve their security.

This plugin is with the highest ranking on WordPress.org. So it is safe to say that your website should be in secure hands if you are using UpdraftPlus. We are speaking for more than 700,000 active installations. I am also using this solution for several websites and I am very satisfied with its performance.

UpdraftPlus will help you ensure your investment in your website by providing you with high-quality backups that you can instantly restore in case of a problem.

More on the UpdraftPlus usage can be seen on this video:

What do you think friends? Will you give UpdraftPlus a try? Or maybe you have questions? Feel free to write them in the comment section below. Don’t forget to share this post on social media.

See you soon friends!

Installing WordPress on Ubuntu LAMP

In this tutorial we are going to install a wordpress website on a LAMP stack. WordPress is the most used CMS worldwide so it’s a great pick for testing our LAMP configuration. If you don’t have a LAMP stack installed you should check this article-Installing LAMP on Ubuntu

Create a database and a username in MySQL

First we need to create a database and a user corresponding to it in MySQL. In order to do that we need to log in to the root administrative account in MySQL. Type the following command:

mysql -u root -p

You’ll be asked for the password for the MySQL root user. Enter it.

Now you have access to MySQL. We are going to make the wordpress database. Use this command

CREATE DATABASE yourdatabasename;

We have to make a MySQL user for the database that we have just created and assign it a password.

CREATE USER yourusername@localhost IDENTIFIED BY 'yourpassword';

Now we have to assign the newly created user to our wordpress database. In order to do that just type:

GRANT ALL PRIVILEGES ON yourdatabasename.* TO yourusername@localhost;

We have to flush the privileges in order for MySQl to know that we have made changes

FLUSH PRIVILEGES;

We can exit mysql

exit
Download WordPress

In order to download the most recent and stable version of WordPress type the following:

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

This will download a compressed file containing the wordpress installation files and folders. We have to extract those files into our home directory.

tar xzvf latest.tar.gz

We have to install some additional modules in order to be able to install plugins in WordPress using our SSH login credentials.

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

Move WordPress files to Document root

In order for your website to be accessible you have to move your wordpress files to Apaches document root. The location of document root is /var/www/html/

It’s a good idea to create a separate directory for your wordpress installation. This way you can install multiple websites in your document root.

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

Now your wordpress files are moved to your document root thus making them accessible for your visitors.

After that remove the wordpress folder and latest.tar.gz  in your home directory

rm latest.tar.gz
rm -rf wordpress

Our next task in to make changes to the wordpress config file

Configure WordPress

Navigate to /var/www/html/wordpress

We have to copy  the wp-config-sample.php to wp-config.php and to remove the wp-config-sample.php

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

Let’s open the wp-config.php and change some fields.

vim wp-config.php

There are some fields which you need to change. We are changing them with the database and user in MySQL that we have made a while back.

define('DB_NAME', 'yourdatabasename'); 
define('DB_USER', 'yourusername'); 
define('DB_PASSWORD', 'yourpassword');

Save the file and exit.

Now we have to give our server access rights to our wordpress directory. If we don’t do that we won’t be able to update plugins upload images etc.In order to accomplish that we have to login as root.

su

Enter your root password

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

Return to your normal user account

su - yourusername

We have to grant read access to our general directory. In order to do that type:

sudo chmod -R 755 /var/www

Modifying Apache

In order to associate the domain we chose for our website with it’s proper location we have to make some changes

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/wordpress.conf

Now we have to edit wordpress.conf

vim wordpress.conf

We need to add the following lines

ServerName yourdomain.com ServerAlias www.yourdomain.com
Also we have to change this to your E-mail in order for you to receive E-mails

ServerAdmin [email protected]

Save and exit

We need to enable our website

sudo a2ensite wordpress.conf

In order for changes to take effect type

sudo service apache2 restart

To access your wordpress installation type the name of your domain in your browser and follow the installation instructions.

If you want to use wordpress pretty permalinks feature you have to make some changes in the host file.

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

You have to add those lines bellow DocumentRoot  /var/www/html/wordpress.

AllowOverride All

Save and close. Next we need to enable the rewrite module. This enables you to rewrite URL’s

sudo a2enmod rewrite

restart the apache web server

sudo service apache2 restart

We need to create a .htaccess file in order for wordpress to write changes to it.

sudo touch /var/www/html/wordpress/.htaccess

To make the web server the group owner type

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

Our last step is to give the .htaccess file the right permissions

sudo chmod 664 /var/www/html/wordpress/.htaccess

You can enjoy your newly installed WordPress website. Cheers!

Installing LAMP on Ubuntu

LAMP is an acronym which consists of: Linux (in our case Ubuntu), Apache web server, MySQL database for storing our website data and PHP for handling the dynamic content.

Creating a non-root user with super user privileges

Before we begin with the installation of the LAMP instance we have to make sure we have a non-root user with super user privileges. This step is important because in Linux managing your system while logged in as root user is considered bad practice. The reason behind this is that the root user has very broad privileges which allow him to gain access and to execute critical commands-commands that can possibly lead to system failure.

In order for us to make a non-root user with super user privileges we need to be logged in as a root user.

Type su in your shell for logging in as root user.

su

If you don’t have a root account you have to create one.

In order to do so you need to run the following commands

sudo passwd root

You will be prompted for a password for your root account. Then you need to execute the following command in order to unlock your root account.

sudo passwd -u root

Now let’s create the user. Execute the following command:

adduser yourusername

You’ll be asked some questions. Other than the password the other fields aren’t mandatory.

In order to give your user root privileges execute the following:

gpasswd -a yourusername sudo

This will add your user to the sudo group. As a consequence every time when you run a command starting with sudo you’ll be executing it with root privileges.

In order to log in with your newly created user type this:

su – yourusername

Now let us get back to installing the LAMP instance.

Installing Apache Web Server

First we need to install the Apache web server. We’ll be using the Ubuntu repository for the task.

First we have to make sure that our repository is updated. We should run the following.

sudo apt-get update

After our repository has been updated we are ready to install the apache web server. Type this command:

sudo apt-get install apache2

Now our Apache Web Server is installed. To check if your Apache web server installation was successful type your server ip address in your browser. You have to see the Apache2 Ubuntu Default Page.

If you don’t know your server public ip address type the following:

Ip addr show

Next to inet you”ll find your ip address

Inet youripaddress/

When a directory is requested by default Apache first looks for index.html. We want to change that so as a result apache will look first for index.php. To do so type this:

sudo vim /etc/apache2/mods-enabled/dir.conf

We want to move the index.php in the first place next to the DirectoryIndex

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

Now we need to restart the Apache web server in order for our changes to take effect.

sudo service apache2 restart

Installing MySQL

MySQl is a database management system. With it you can easily store, access and organize your website information.

We need to run the following command in order to install MySQL:

sudo apt-get install mysql-server php5-mysql

During the installation you’ll be prompted for the MySQL root user password. Just generate one and enter it. After the installation we have to generate MySQL database directory structure.

sudo mysql_install_db

After that we have to run a security script in order to secure our MySQL installation.

sudo mysql_secure_installation

Remove the anonymous user, disallow the remote root login and remove the test database. After that reload the privileged tables. That’s it.

Installing PHP

PHP is going to be used in order to display our dynamically generated content. Again we are going to use the apt-get.

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

Now our php package has been installed. Php comes with optional modules you can install. In order to search them up type:

apt-cache search php5-

From the additional modules we will install php5-cli- command-line interpreter for the php5 scripting language.

sudo apt-get install php5-cli

Our last task is to test how php handles things. We have to create a test file in a specific directory (web root). on our server.

sudo vim /var/www/html/test.php

Now we want to put the following and to save the file:

<?php 
phpinfo(); 
?>

In order to test our php we need to navigate to the newly created test.php file in our browser.

http://your_server_IP_address/test.php

You have to see something like this:

php
In order to keep your server secured you should remove the test.php file

sudo rm /var/www/html/test.php

Now you have a working LAMP instance ready to host your websites.