Difference between revisions of "Setup your own server for 5$ a month"

(Install Pagespeed module from Google)
(Enable Memcached)
Line 123: Line 123:
 
==Enable OPCache==
 
==Enable OPCache==
 
==Enable Memcached==
 
==Enable Memcached==
 +
Reference: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-memcache-on-ubuntu-14-04
 +
 
==Install and configure Joomla==
 
==Install and configure Joomla==

Revision as of 06:09, 15 September 2014

Alert-write.png

This page is not complete
This article is incomplete, or otherwise not finished. It could provide much more information about the topic that it tries to cover.
Are you interested in helping us making best documented Joomla! extension in the world and finish this article?
Then click here to find out how.


Warning: This article explains how to setup your own server and will focus on using Terminal to login on remote Linux machine. Although might look like it is written for experienced Linux administrators, you can follow it and setup your server even without any, linux terminal knowledge.

Overview

Starting a website usually begins with choosing your hosting provider, as a most important thing a website couldn't work without. We often look into hosting providers that offer us a various different packages ranging from very small and usually pretty limited shared servers to pricey super-machines. We care how many storage we get, how much of the monthly bandwidth we can use, how many emails we can create, does hosting comes with CPanel and WHM, but one thing that we so often get frighten about is a "self managed server". We commonly believe that self-managed servers are something universally reserved for sites that can afford dedicated administrators to maintain the server environment. For the most part, that was the case, but not anymore, and you shouldn't be afraid to try it out.

Requirements for a JomSocial based site

Before even starting a website, we need to know what exactly do we need. Specifically for JomSocial, list is as follows

  • Web server - Apache or a nginx (pronounced as ENGINE X). It is totally up to you which one to use. In this article, we will focus on Apache, as it is way easier to configure.
  • PHP Environment - Although Joomla! and hence JomSocial system requirements are very generous on PHP version, we want to use the latest one, which at the time of writing this article is PHP 5.5
  • Database Server - MySQL or recently very popular MariaDB. Whatever you use it will work the same.
  • Email Server - for sending out the emails from your site.
  • Cron Job - On every linux machine, cron jobs run as a system level process and is natively available
  • Optimization modules and handlers - We also need something to keep our website fast and ready for great performance. For this guide, we will use mod_pagespeed from Google, opcache that is built into PHP 5.5 and Memcached. APC is not supported in PHP 5.5 because opcache comes as native layer and replacement for APC.

That is everything you need to kickstart a good hosting server. You might later want to install FFMPEG for video converting or additional PHP modules and extensions, which you will be able, because server that we are going to create is going to be self-managed, meaning, you will be your own server administrator.

What with the CPanel, WHM, PhpMyAdmin?

All of these are just a Graphical Interfaces helping you to set things without having to know anything about web server administration. They are commonly given as a courtesy on the shared hosting, but for a VPS or faster you need to pay extra for it. The fact of the matter is, none of them are needed for your web server, database server, or site itself to work. These panels only add extra clutter on your server and the things can work quite happily without it.

Chip in with 5 bucks and be amazed

So, lets get straight to business. Where is that super server for $5 we are talking about?
It is located on the Digital Ocean.
Login, and pay $5 which is minimum you need to launch the most basic droplet
As you can see, for just a $5 you get 1CPU, 512MB of RAM 20GB Solid State Disk and 1TB of transfer which is off the bat the better deal than anything you can find. Ofcourse, later you can easily increase your package. With minimum downtime, DigitalOcean does provide this possibility.

Droplet-create.png

Give a name to your droplet, pick the package and the region that is closest to you,
You can leave "Available settings" unthicked

Available settings.png

On the "Select image" area, switch to "Applications" tab and select "LAMP on Ubuntu 14.04"

Select-image.png

LAMP stands for Linux, Apache, MySQL, Php and will automatically install all of these instead of you. It will save us some time installing the stack server that is available in Ubuntu.
Finally, create your droplet. Digital Ocean will immediately send you the email sending the

  • IP address - you will use this to login at your server
  • Root username - typically root
  • Root password - Random string of text and numbers. You will be prompted to change this after first login

You will see something like this once your droplet is created

Droplet-finish.png

First login on the server

You can use the "Console Access" to login to your droplet, but we strongly advise you to use Terminal window.
Lets login to the machine by typing

ssh root@IP_OF_YOUR_DROPLET
  • IP is set to you in email you got when droplet is created.

If promted, type yes and press enter
You will be asked for the password. Use the password that DigitalOcean sent you in the email.
Once logged in, the server will require you to change the password. Follow the instructions and change the password. If all went well, you will have new root password for your server

Sinisas-MacBook-Pro:~ sinisakrisan$ ssh [email protected]
[email protected]'s password: 
You are required to change your password immediately (root enforced)
-------------------------------------------------------------------------------------
Thank you for using DigitalOcean's LAMP Application.
Your web root is located at /var/www/html and can be seen from http://128.199.199.231/
The details of your PHP installation can be seen at http://128.199.199.231/info.php
Your MySQL root user's password is oti0mVK1gB
You are encouraged to run mysql_secure_installation to ready your server for production.
-------------------------------------------------------------------------------------
To delete this message of the day: rm -rf /etc/motd.tail
Last login: Tue Aug  5 15:08:41 2014 from 162.243.14.86
Changing password for root.
(current) UNIX password: 
Enter new UNIX password: 
Retype new UNIX password: 
root@JomSocial:~#


Setup MySQL

Run this command in the terminal

mysql_secure_installation

This will start a series of questions to secure your database server.
It will ask you for the password. You can find it in the "Message of the day" at the terminal window.

Motd-mysql.png

Enter the password to start the process and follow the instruction.
If you're not sure what you need to set, answer all questions with y (yes)
When you finish, login to MySQL with

mysql -u root -p

Enter the root password and type

create database jomsocial;

followed by

exit

This will create database with name jomsocial
Finally, run the

rm -rf /etc/motd.tail

to remove Message of the day

Update software and edit php.ini

Update OS

Since we installed stack version of LAMP on Ubuntu, there are two major softwares we need to update. Ubuntu itself and PHP
First, restart the server as this step is required to get new updates. Type:

reboot now

Login back to server and type:

sudo apt-get update
sudo apt-get dist-upgrade

Answer with yes and wait for your server to get updated with latest software.

Install cURL

To enhance the functionality of PHP, we can optionally install some additional modules.
cURL is one of them that is needed, but not installed with default LAMP stack
To see the available options for PHP modules and libraries, you can type this into your system:

apt-cache search php5-

To install specific module, type

sudo apt-get install module-name

Since we need cURL we type:

sudo apt-get install php5-curl

Restart the apache with

sudo service apache2 restart

Update php.ini

At this point, we have everything running, but we need to alter php.ini to comply with JomSocial requirements.
If you wan't, you can continue to be geeky and use Terminal editors such are nano or vi, but since this is a beginner tutorial, we are going to use SFTP to download files on our computer and then modify them with GUI text editors that we love
Simply login to FTP using ftp client like Filezilla using following credentials

Navigate to /etc/php5/apache2/ and grab the php.ini
Download it and edit to meet minimum system requirements and then upload it back.

Install Pagespeed module from Google

Reference: https://www.digitalocean.com/community/tutorials/how-to-get-started-with-mod_pagespeed-with-apache-on-an-ubuntu-and-debian-cloud-server

Enable OPCache

Enable Memcached

Reference: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-memcache-on-ubuntu-14-04

Install and configure Joomla