Cloud Server Hosting is gain popularity because of its reliability, performance and price. If properly configured the cloud servers are very secure and have high performance/price ratio. These days you can get a good cloud hosting in about $5/month. Along with the storage space, you get a dedicated I.P address and full root access. It means you can customize your server like you want. Another great advantage of using a cloud hosting is you are billed for the resources you use. You can easily scale your server according to your need. While shared hosting cost more than $10/month, you can deploy a cloud server in less than $5/month which is way more powerful than any shared hosting.
Table of Contents
- Initial server setup
- Installing LAMP Stack
- Installing WordPress
The problem people face during deploying a server is to set up the server correctly for their use. So in this guide we will setup a cloud server to host multiple WordPress (or other) sites.
1 Initial Cloud Server Setup for WordPress installation
1.1 Logging in
So the first step is initial server setup. For that you need to log in to your server using SSH.
Log in using Mac
- To log in on a Mac computer, open the terminal program (in the utilities folder) and type in the following command, logging in with the IP address of your server:
ssh [email protected]_ip_address
- Type “yes” when the prompt asks if you want to connect to the host. When prompted, type in the root password that was emailed to you and press enter. Although the password is entered when you type, it does not show up on the screen for security reasons.
- You will then be connected to your Server.
Log in using Windows
- To log into your server on windows, you will need to have PuTTY, an SSH client, installed on your computer.
- You can download the program here. Choose the windows installer.
- Once PuTTY is downloaded and installed, starting the program will take you to the configuration screen.
- Fill in the “Host Name (or IP address)” field with the IP address of your server, make sure the port number is 22, and the connection type is SSH.
- Additionally, click on the sidebar entry, SSH, and select “2 only” as the preferred SSH protocol version.
- Once everything is configured, you can name and save these preferences for the future by clicking on Session in the side bar and typing a title into the Saved Sessions field. Then click save.
- Double click on the session name to connect, and accept the subsequent pop up that asks if you want to connect to the host. After PuTTY starts up, type in the root password that was emailed to you.
- You will then be connected to your Server.
Now if you have logged in successfully then go ahead and follow the next step.
1.2 Changing the root password
In this step we will change the root password for that type:
After you change the password you need to log in again with the new password.
1.3 Creating a new user with root privileges
The advantage of creating a new user is it prevent the user from destroying the system.
To add a new user, type:
Where “demo” is the name of the new user. You can use your name in place of demo.
Now you have successfully created a new user. Please note that you need to use the phase ‘sudo’ before any command.
To give the new user root privileges type:
Find the section called user privileges specification. It look like this:
# User privilege specification root ALL=(ALL:ALL) ALL
Under that add this line, to grant root privilege to the new user.
demo ALL=(ALL:ALL) ALL
Replace ‘demo’ with the username you created earlier.
Type ‘Ctrl+x’ and press Y and then press ENTER to save the file.
To make the changes take effect, type this command.
1.4 Logging in as new user
To log in as the new user type:
Use the new user to do any task with ssh as it will prevent your server from destroying-mistakes.
You have now completed the initial server setup.
2 Installing LAMP Stack
LAMP stack is a group of software that are required for web server to run applications which uses PHP and MySQL.
2.1 Installing Apache
First we will install Apache server software. To do this type the following commands
sudo apt-get update sudo apt-get install apache2
Now you have successfully installed the apache web server software.
2.2 Installing MySQL
The next is to install mysql server, to do this type the following command.
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
if the command written above gives error then try this command, both the commands are same the but in the new version of Ubuntu OS (13.0+) you need to use the command written below:
sudo apt-get install mysql-server php5-mysql
To activate the mysql software type the following command
Now we will setup the mysql, for that type:
Now the prompt will ask you for the current root password.
Type it and press ENTER.
Then the prompt will ask you if you want to change the root password. Go ahead and choose N and move on to the next steps.
It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.
By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up...
Now you have installed apache and mysql software on you server. Lets move on and install php on the server.
2.3 Installing PHP
Now run the following command to install php:
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
Now we will install the essential php modules required to run WordPress and other apps. Type the following command:
sudo apt-get install php5-cgi php5-cli php5-curl php5-dbg php5-dev php5-gd php5-mysqlphp5-odbc php5-pgsql php5-snmp php5-xmlrpc php5-xsl
Restart apache, so that all the changes take effect. Type this command:
sudo service apache2 restart
Congratulations you have installed LAMP stack on your server.
3 Installing WordPress
Now its come to the easiest part of this tutorial i.e. Installing WordPress on your server.
3.1 Downloading Latest WordPress on the Server
To install WordPress on the server you will need to download it on the server. To do this type this command.
cd wget http://wordpress.org/latest.tar.gz
Basically what is exactly does it when you type cd and press Enter button it changes you current directory to the users /home directory. And wget command download the latest version of WordPress on your server.
Now lets move to the next thing i.e. Unzip the WordPress installer. To do this type this command.
tar xzvf latest.tar.gz
3.2 Creating Site Database and Users
Every WordPress site need a database to store posts, comments and settings. So in this step we will create a MySQL database for our WordPress site.
To do MySQL related stuff first we need to log in into the mysql administrator account. To do this type.
mysql -u root -p
You will be prompted to enter the MySQL root password. Type the password and press enter.
Now if you have entered the correct password you will be dropped in to MySQL prompt.
To create a new database type the following command.
CREATE DATABASE FirstDatabase;
Change the “FirstDatabase” with the database name you want to use.
Now the database is created. Now we will add a new user to this database. To do this type.
CREATE USER FirstUser@localhost;
Replace the “FirstUser” with the user name you want and press enter.
It is very important to protect the new user account with a password. To do this type.
SET PASSWORD FOR FirstUser@localhost= PASSWORD("FirstPassword");
Be sure to replace the “FirstUser” with your user name you created in the above step and “FirstPassword” with a strong password. And press enter.
Now last step of creating database is to provide the new user all the privileges. To do this type:
GRANT ALL PRIVILEGES ON FirstDatabase.* TO FirstUser@localhost IDENTIFIED BY 'FirstPassword';
and press enter.
Refresh the MySQL privilege information by this command.
and exit the MySQL to the shell session by typing:
and press enter.
3.3 Creating site root directory
We will need to create separate directories for different sites, so that we can host multiple sites on one server.
In this step we will create a directory for the site in the “/var/www”.
Change the directory to “/var/www”:
Create a directory for the site in “/var/www” with mkdir command:
sudo mkdir siteName
Activate the WordPress sample configuration file by renaming it:
cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php
Copy all the files and folder of “/wordpress” directory to the site root:
sudo rsync -avP ~/wordpress/ /var/www/siteName/
Make sure to replace the text in red with your respective directory name.
Giving ownership of the “/var/www” directory to the user.
sudo chown -R www-data:linux_username /var/www
Replace the “linux_username” with the username you created in first step ( 1.3) .
3.4 Configuring Virtual Host
As we have installed WordPress in “/var/www/siteName” directory, we will need to set up the virtual host file. So when the visitors type the site URLs they directed to the right directory.
To create a virtual host file in Apache, first we need to go to the “/etc/apache2/sites-available” directory.
Now create new virtual host file for you site located in “/var/www/siteName”.
sudo cp default siteName
After new virtual host file is created. We need to add the information into it.
For editing we have a default CLI text editor in Ubuntu and Debian called “nano”. We will edit the virtual host configuration file with nano. To do this type:
sudo nano siteName
Now substitute the information in the virtual host configuration file which a marked in red with you site information.
<VirtualHost *:80> ServerAdmin your_email_address ServerName yoursite.com ServerAlias www.yoursite.com DocumentRoot /var/www/siteName <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/siteName> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> :::: :::: ::::
Add the two-line ServerName and ServerAlias below the ServerAdmin line.
If you have www in the default URL then add www in the ServerName and remove www from ServerAlias , So that the first 4 lines look like this.
<VirtualHost *:80> ServerAdmin your_email_address ServerName www.yoursite.com ServerAlias yoursite.com ::: :::
Also make sure you have changed the “AllowOverride None” in the “” block to “AllowOverride All”. This will enable pretty permalinks.
Save the file by pressing ctrl+x then type Y and hit enter.
Now type this command to enable mod_rewrite for the pretty permalinks to work:
sudo a2enmod rewrite
Enable the virtual host file by this command:
sudo a2ensite siteName
Replace the “siteName” with the site name you have created in step 3.3
Now restart the Apache to make the changes take effect.
sudo service apache2 reload
3.5 WordPress five-minutes Install
Now visit your site and finish the installation with WordPress 5 minutes install wizard.
If you have not made changes to your domain nameservers then visit the IP address of the server on which you have installed WordPress.
for example: 184.108.40.206/wp-admin/install.php
Congratulations, Now you have successfully installed WordPress on your server. Are you planning to move your WordPress blog to cloud server? Do let me know if you have any questions or issues while installing WordPress on your cloud server. Don’t forget to share this tutorial with your geek friends on Facebook and Google plus.
This is a guest post by Rajiv from RealGeekTips. If you would like to write for ShoutMeLoud, check our guest submission guidelines.
Subscribe on Youtube
Check your domain ranking