LAMP Install (Apache, MySQL, PHP)

  • Few things about LAMP

LAMP is is a group of open source software used for web servers. LAMP stands for Linux, Apache, MySQL, and PHP.

If you are planning to run a web server for personal website, forum, chat etc. LAMP is the best solution for you

As you can see from above, there are four things you’ll need for a web server:

1. Linux

  • Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution.

2. Apache

  • The role of LAMP’s web server has been traditionally supplied by Apache. The Apache HTTP Server has been the most popular web server on the public Internet.

3. MySQL

  • MySQL’s original role as the LAMP’s relational database management system (RDBMS). MySQL is a multithreaded, multi-user, SQL database management system (DBMS),

4. PHP

  • PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language. PHP code is interpreted by a web server via a PHP processor module, which generates the resulting web page.

So, lets begin!

I assume that you have Linux installed on your computer

First thing to do is to check if our repositories are up to date:

apt-get update

This will install all new updates if there are any.

1. Install Apache

Note: You’ll need a root Terminal for this

apt-get install apache2

You are probably wondering whats next but this is it! Your apache should be installed. To check if everything went fine, go to web browser and type:

http://localhost

To find whats your IP address you can type:

ifconfig

This will show you your network information. Look for inet addr, this is your internal IP address which can be used to access a web server locally.

2. Install MySQL

Run the following command:

apt-get install mysql-server

During the installation, MySQL will ask you to set a root password. If you miss the chance to set the password, it is very easy to set the password later from within the MySQL shell.

When it’s all done, run:

mysql_secure_installation

You’ll see something like this:

Enter current password for root (enter for none):

Enter your root password.

OK, successfully used password, moving on...

Then the prompt will ask you if you want to change the root password. Type N if you set it before or Y to set a new password.

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.  You should remove it. Type Y:

Remove anonymous users? [Y/n] Y
... Success!

To ensure that root can only connect from localhost type Y:

Disallow root login remotely? [Y/n] Y
... Success!

By default, MySQL comes with a database named ‘test’ that anyone can access.  This is intended only for testing, and should be removed. Type Y:

Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privileges tables will ensure that all changes made so far will take effect immediately. Type Y:

Reload privilege tables now? [Y/n] Y
... Success!

Cleaning up...

Now you can proceed to PHP installation.

3. Install PHP

Run the following command:

apt-get install php5 php-pear php5-mysql

You’ll need to type Y two times. After that PHP will finish installation.

Restart apache server:

service apache2 restart

4. Test your configuration

To test if PHP is working type:

nano /var/www/phpinfo.php

Enter following:

<?php

phpinfo();

?>

Save file and exit.

Type this address in web browser:

http://localhost/phpinfo.php

If you see informations on that page, you’ve successfully completed LAMP installation.

If you see blank page, you need to enable mod_php5 on apache. To do that, open Terminal and enter:

a2enmod php5

After that you’ll need to restart apache to apply changes:

service apache2 restart

Now reload page phpinfo.php in your web browser and you should see PHP information page.


 

Thats it!

Your web server is ready to go, put some cool stuff on it and have fun!

Leave a Reply

Your email address will not be published.