PHP on Ubuntu,The Linux, Apache, MySQL and PHP (LAMP) stack is used to host websites.
In this tutorial, I will display you how to setup an Amazon EC2 instance with the LAMP stack. As a end result of completing this tutorial, you will be capable of deploy your Content Management Software (CMS) and begin building your internet site on your very personal Virtual Private Server (VPS).
From revel in, I have observed that most LAMP stack tutorials are not complete. They will explain the way to installation the software and you’re for your personal from there. As a end result of completing this tutorial you will have an knowledge of:
- setup an Amazon EC2 instance
- connect to your Amazon EC2 instance via Secure Shell (SSH)
- install the LAMP stack
- configure Apache, ready for a website
There are many website hosting companies that provide a pre-configured solution at a reasonably affordable charge.
Shared web hosting way your internet site is at the identical server as loads, if not lots of different websites
These web sites will regularly proportion the equal IP deal with and this can be disadvantageous in terms of search engine optimization. The other primary gain is fee.
Amazon is simply one of many VPS providers. By searching at their pricing desk, you may start to understand how you could shop money on hosting. The third and regularly forgotten benefit to hosting your website on an Amazon EC2 example is scaling.
The capacity to shutdown the example and reboot a larger example, in a depend of minutes is priceless. This method, you do now not need to begin deciding to buy a bigger server earlier than you want it. It also method that when it’s time to upgrade, your internet site will not need to be moved. These are just a few benefits of the use of a VPS service which include EC2.
PHP on Ubuntu,What you will need
- Amazon Web Services (AWS) account, or get admission to to a VPS
- PuTTY
- PuTTYgen
I recommend you examine that publish and skip to step 3.
Step 1: PHP on Ubuntu,Setup your EC2 Instance
PHP on Ubuntu,Login in your AWS account and click on EC2 inside the very top left nook. In the left menu you may see a link that reads ‘Instances’, click it. This is a listing of the instances in your account. Click Launch instance and click ‘Select’ subsequent to Ubuntu Server 14.04, or the modern model of Ubuntu. Click ‘Next: Tag Instance’ and pick a tag in your instance. You ought to be on ‘Step 6: Configure Security Group’ where you may choose ‘Create a new safety organization’.
For now, we are able to handiest want SSH and HTTP. The ports for those two protocols will already be decided on, you’ll no longer be able to exchange them. Click ‘Review and Launch’ after which click ‘Launch’. A communicate will seem telling you that you need to pick an current key par or create a brand new key pair. From the drop down, select ‘Create a brand new key pair’ and name the key. Save that record to a at ease location. Click ‘Launch Instance’ and your example will start to release.
Step 2: PHP on Ubuntu,Creating a private key
PHP on Ubuntu,Open PuTTYgen and click ‘Load’. Find the important thing which you saved from Amazon and pick it. Click the ‘Save private key’ button and store the important thing to a safe region.
Step 3: SSH into your EC2 instance
By now your EC2 example need to be jogging. If you choose it, you may be capable of see a description of your example down the bottom of the page. In this description can be a public IP address. Copy this deal with and paste it into PuTTY wherein it says ‘Host Name or IP cope with’.
In PuTTY, enlarge ‘SSH’ and pick out ‘Auth’. At the lowest of this tab there could be a browse button, click on it and select your non-public key that you generated.
Note: Your private key can have the extension .Pem and you will now not be able to see the key. Click display all documents and select the key.
Login in your server with the username: ubuntu
We at the moment are related with the person ‘Ubuntu’ which is right. However, this can get pretty disturbing because we can need to jot down facet in the front of the instructions. To change to root person type: sudo su
Step 4: Installing the LAMP stack
To get started type these two commands
sudo apt-get update
sudo apt-get install apache2
Navigate to your IP address and make sure Apache is installed effectively. The image underneath depicts what your website will look like with Apache mounted correctly.
Step 5: Install MySQL
We now have the LA components of the LAMP stack and its time for the M. We will again use the apt-get
command to acquire and install the software. Run the following command to install MySQL:
apt-get install mysql-server php5-mysql
When promoted to maintain, type Y and press input. The installer will ask you for a password, make sure you pick out some thing very sturdy. Type the password twice while prompted and press input after every time. MySQL should finish putting in quickly after.
Step 6: Install PHP
We now have the LAM and its time for the P. PHP is a language that is used by most CMS, including WordPress. Type the following command to put in PHP:
apt-get install php5 libapache2-mod-php5 php5-mcrypt
Step 7: Simple Apache configuration
We are nearly finished! In this step we will configure Apache, equipped to begin strolling our website documents. To try this, we are able to make an Apache configuration record after which permit the website.
Move in your websites-available listing with the command:
cd /etc/apache2/sites-available/
Make a new configuration document along with your website cope with and add.Conf on the give up. For example, in case your website is techcress.Com, you will make a brand new report known as techcress.Com.Conf with the command:
nano techcress.com.conf
Inside this document we can want to place a few configuration. Copy the subsequent code and replace www.Techcress.Com along with your internet site cope with. Make certain you omit any http:// or trailing slashes.
ServerName www.techcress.com
ServerAlias techcress.com *.techcress.com
DocumentRoot /var/www/www.techcress.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !=www.techcress.com [NC]
RewriteRule ^/(.*)$ http://www.techcress.com/$1 [R=301,L]
ErrorLog /var/log/apache2/www.techcress.com-error.log
LogLevel warn
CustomLog /var/log/apache2/www.techcress.com-access.log combined
Press Ctrl + x to go out and whilst precipitated kind y and hit enter to store the document.
The DocumentRoot /var/www/www.Techcress.Com issue tells Apache wherein your documents are positioned. This folder will no longer exist so we will need to make it. To make the folder www.Techcress.Com you will type:
mkdir /var/www/www.techcress.com
Note: You will need to modify the folder name to be your website address.
Enable your new website by typing:
a2ensite www.techcress.com.conf
You can now put the WordPress files, or any CMS files inside the folder located at /var/www/your folder and navigate to your website