Quantcast
Channel: Code Bucket
Viewing all articles
Browse latest Browse all 4

LAMP Installation

$
0
0

LAMP is an open source stand for Linux Apache MySql PHP. In this tutorial we will learn how to install LAMP on a server.

Requirement: Server with installed Linux OS.

To access server remotely we need SSH client preferably Putty. So Download putty and connect putty with your server.

We can divide our task into steps:
Step1:Update Linux and secure it (Firewall)
Step2: Install Apache, PHP, MYSQL and PHPMyAdmin.
Step3: Install webmin(UI) to access server.

Step1:
To update linux type command

sudo apt-get update

This command will update your Linux os installed on your server.
To secure your server we will configure Iptables, which is a firewall installed by default and allow all traffic by default.
So first of all you have to decide which type of request you want to allow to your server from outside network. In my case it is http, https and ssh.
To allow established connections to continue to function:

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

To allow SSH Traffic

iptables -A INPUT -p tcp --dport 22 -j ACCEPT

To allow HTTP traffic

iptables -A INPUT -p tcp --dport 80 -j ACCEPT

To allow HTTPS traffic

iptables -A INPUT -p tcp --dport 443 -j ACCEPT

Drop all remaining traffic

iptables -A INPUT -j DROP

Now we need to save the rules to a file

sudo iptables-save > /etc/iptables.rules

Okay, so we aren’t done yet. We need to apply the firewall rules to our network card that is configured with our public IP address (for me this started with 184.x.x.x, it definitely is not the 10.x.x.x IP which is your private IP). For me I added one line to load the iptable.rules file when the NIC is loaded in the /etc/network/interfaces file. In the terminal type:

sudo nano /etc/network/interfaces

Now that you are editing the file, go to your network card configuration with the public IP and add:

pre-up iptables-restore < /etc/iptables.rules

This should go right below the line “iface eth0 inet static” and it should be indented like the other lines.
IMPORTANT NOTE: This should be redone as well as the hostname configuration for each new server you setup from this image.
Now to ensure everything is loaded correctly from the configuration files preform a reboot (soft reboot).
You can find a more detailed document on Iptables here

Step2:
To install Apache with PHP5 type command

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

After installation restart apache using command:

sudo /etc/init.d/apache2 restart

To check whether php is installed and running properly, just create a test.php in your /var/www folder with phpinfo() function, using exactly same command as shown below.

sudo nano /var/www/test.php

an editor will get open, type the following line in the editor and save it before closing.

<?php phpinfo(); ?>

Open http://ip.address/test.php in browser, if everything goes right you will see php configuration page.

To install MYSQL type following command:

sudo apt-get install mysql-server mysql-client php5-mysql

Now we will install PHPMyAdmin to access MYSQL databases. Run the following command to install phpmyadmin

sudo apt-get install phpmyadmin

To set up PHPMyAdmin under Apache, open

sudo /etc/apache2/apache2.conf

And “Include /etc/phpmyadmin/apache.conf” in apache2.conf file, save and close it. Restart apache server

sudo /etc/init.d/apache2 restart

Open following link to access PHPMYAdmin: http://ipaddress/phpmyadmin

Step3: Webmin is an open source which give us a java based UI to access LAMP server.

To download and Install webmin run following command one by one:

wget http://prdownloads.sourceforge.net/webadmin/webmin_1.580_all.deb
sudo dpkg -i webmin_1.580_all.deb

If it gives Dependencies issue, run following command:

sudo apt-get -f install

Now to access your installed server go to url : https://ip.address:10000/


Viewing all articles
Browse latest Browse all 4

Trending Articles