Ubuntu Logo

Easiest Way to Install Lamp on Ubuntu

LAMP(Linux, Apache, MySQL, PHP or Perl) is one of the most essential servers needed by the web developers or web entrepreneurs around the globe. This tutorial explains one of the easiest ways to install LAMP on Ubuntu. Because Ubuntu uses Linux as it’s kernel we are done with the Linux part 😉 .

Install tasksel on your system:

$ sudo apt-get update && sudo apt-get install tasksel

Tasksel is a Debian/Ubuntu tool that installs multiple related packages as a co-ordinated “task” onto your system.

Start tasksel from the command line:

$ sudo tasksel

tasksel

A terminal dialog is opened as shown above. Select “lamp-server”(use the Tab key to move around and hit Space to select). Finally navigate to <ok> using the Tab key again and press Enter.

tasksel2

Download and configuration process will be started for the lamp-server.  And then Follow the steps to create your Mysql password.  Wait to complete installation.

Finally, start apache2 server:

$ sudo service apache2 restart

Congratulations you have successfully installed LAMP server on your system. To test just visit your web browser and type in the following url,

http://localhost/

localhost

To test the php installation,

$ sudo nano /var/www/phptest.php

type in,

<?php phpinfo(); ?>

and open the following url in your browser,

http://localhost/phptest.php

localhostphp

Thank you.

Apache

Install and Configure Apache Web Server on GNU/Linux

This is a tutorial that explains how we can install and configure an Apache Web Server on a computer that is either connected to a local network or the Internet. Apache is a free software(HTTP Server) that powers more than 50% of the worlds websites.

Required Packages:

httpd

NOTE: Distributions may pack ‘httpd’ with a different name, like for instance ‘apache‘ or ‘apache2‘. Use your native package manager(apt-get, yum, pacman, emerge) to install httpd.

Connect to the Desired Network:

Get connected to your desired network, either a local network or the Internet. Once you are connected it’s time to note your ip address.

# ifconfig connection_port

Example,

# ifconfig eth0

One more example that can be used in RedHat/CentOS or Gentoo,

# ifconfig eth0 | grep inet | awk '{ print $2 }'

The ip address should be noted as the server address.

Starting Service:

On RedHat/CentOS:

# service httpd start

On Gentoo:

# /etc/init.d/apache2 start

ArchLinux/Fedora users should use systemctl and Ubuntu users should use the service utility to start the httpd/apache2 service.

Test the Apache Installation:

The directory “/var/www/html” is the document root for RedHat based systems. On Gentoo it is “/var/www/localhost/htdocs/”. On ArchLinux it is “/srv/http”. A document root is where you should put your web pages.

Create a sample web page, name it “index.html” and copy this page to the document root. The sample page should contain something like,

<html>
<title>Home</title>
This is the home page for the local server.
</html>

Now, open a web browser and type in http://your_server_ip , replacing your_server_ip with the ip address we obtained before.

You can also edit the “/etc/hosts” file and setup an FQDN so that you can use it on your browser.

The setup should look like this,

# /etc/hosts: Local Host Database
# IPv4 and IPv6 localhost aliases
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost

Now type in localhost on your browser to view the sample web page we created.

NOTE: You can also use the netstat utility to check the status of the apache service.

Access the server pages from any computer on the network:

Just put the server ip address on the browser. That is it. But if you are running a firewall on the server you have to add some rules. Like if you use iptables on the server and if it is running then add the following rule,

# iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

That would setup Apache.

Thank you.