LAMP Server (in RedHat/CentOS/Fedora): 

Introduction:

This tutorial shows a quick way of installing a LAMP server (Linux + Apache + MySQL + PHP/Perl together commonly known as LAMP Server.) on CentOS and RHEL server systems.

Related Helps:
Vim Editor
YUM

Related Topic:
Apache Web Server
Recover MySQL root password
Phpmyadmin
Webmin
Virtualmin

  • Apache - Web Server 2.0
  • MySQL - Database Server 5.0
  • PHP - Scripting Language 5.0
  • phpMyAdmin - Web based MySQL Administration Tool
  • Webmin - A free web based hosting control panel

 

Hardware Requirement:

You must have of atleast 256 MB of RAM
before you install and configure LAMP Server.

 

Goal

To set up a LAMP server on a fresh VPS/Dedicated server running CentOS 5.0 with atleast 256mb of RAM. We will also be installing Webmin, a free server control panel for linux. If you are using a Debian/Ubuntu refer to this video.

 

 

1. Install Apache:

 

yum install httpd httpd-devel
  1. Apache is the most popular Web HTTP server for a Linux servers.
  2. We might need the httpd-devel libraries to compile and install other modules from the sources, just to be on the safer side.
  3. /etc/httpd/conf/httpd.conf - Apache configuration file location.

 

2. Start httpd service:


/etc/init.d/httpd start

3. Install MySQL Database Server


yum install mysql mysql-server mysql-devel

  1. MySQL is a widely used open source database server on most Linux servers and can very well integrate to PHP and Apache server on CentOS/RHEL.


If you attempt to type mysql in command prompt, you will be getting this nasty error. ERROR 2002 (HY000): Cannot connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' This is because you are not running the mysqld daemon before launching the mysql client. The file /var/lib/mysql/mysql.sock will be automatically created upon running the first instance of mysql.



4. To fix it (Start mysqld service):

First start the mysql daemon, then type mysql:

/etc/init.d/mysqld start
mysql


Changing MySQL Root Password

By default the root password is empty for the mysql database. It is a good idea to change the mysql root password to a new one from a security point of view.
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql> FLUSH PRIVILEGES;
mysql> quit

Once done, check by logging in:
mysql -u root -p
Enter Password: <your new password>
(Note: In this case password is newpassword.)

 

Don't forget to remember the root password as we might be using it with phpmyadmin.

 

5. Install PHP5 Scripting Language

Installing PHP5 with the necessary modules is so easy and can be configured for both the Apache and mysql environment.

 

yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
Don't forget to install php-gd (gd library). It is very important if we plan to run captcha scripts on our server and so as other which are dependent on mysql and other functions.


6. Restart Apache to load php.

/etc/init.d/httpd restart

 

7. To Test If PHP Is Working Or Not:

Create a file named /var/www/html/test.php with the following phpinfo() function inside php quotes.

// test.php
  <?php
  phpinfo();
  ?>

 

8. Then point your browser to http://ip.address/test.php.

 

That's it! You should see a php configuration file displaying all kind of paths and installed modules.

 Closely observe the installed configuration on your server.
* PHP Paths (php.ini path)
* Apache paths and Loaded Modules (mod_security, mod_evasive if installed_
* PHP GD Library
* MySQL paths and other information

Connect With Us
Instant Query
Your Name :

Email Address :

Message :