Wednesday, November 30, 2011

LAMP Server Configuration

-->
Introduction:-
LAMP stand Linux (operating system) Apache (HTTP server) MySQL (database software) and PHP ( or Perl or Python). LAMP Server is Linux web development environment. It allowes you to create web applications with Apache, PHP and MySQL database. It also come with PHPMyAdmin and SQLiteManager to easily manage your database.

Per quest on server:-
  • Configure IP = 192.168.1.1
  • Hostname = server.anup.co.in
1] Install Apache
[root@server ~]# yum install httpd  -y

2] Start apache service
[root@server ~]# service httpd start
[root@server ~]# chkconfig httpd on

3] Install MySQL Database Server
[ MySQL is a widely used open source database server on most linux server and can very well integrate tp PHP and Apache server on RHEL5 ]
[root@server ~]# yum install mysql mysql-server -y
[root@server ~]# service mysqld start

4] Change MySQL root password [ By default the root password is empty for mysql database. ]
[root@server ~]# mysql
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql> FLUSH PRIVILEGES;

5] Once done check by loging in:
[root@server ~]# mysql -u root -p
Enter password: <your new password>

6] Create a new mysql user
[root@server ~]# mysql -u root -p
mysql> create database lamp
mysql> GRANT ALL PRIVILEGES ON lamp.* TO 'anup'@'localhost' IDENTIFIED BY 'anup' WITH GRANT OPTION;
mysql> UPDATE user SET Password=PASSWORD('anup') WHERE user='anup';
mysql> quit

7] Install PHP language
[root@server ~]# yum install php php-gd -y

8] To load PHP restart apache
[root@server ~]# service httpd restart

9] To test PHP working or not
[root@server ~]# vim /var/www/htm/demo.php
// demo.php
<?php
phpinfo();
?>
:wq

10] Open the browser and type following URL
Syntax = http://<ip address>/demo.php
  • Observe the installed configuration on server
    • PHP paths
    • Apache paths and loaded module
    • PHP gd library
    • MySQL path
11] Download and Install PHPMyAdmin
[ PHPMyAdmin is web based MySQL database administration tool ]

12] Edit phpmyadmin configuration file
[root@server ~]# vi /etc/httpd/conf.d/phpmyadmin.conf (Remove the hash from Deny from all)
<Directory "/usr/share/phpmyadmin">
  Order Deny,Allow
  # Deny from all
  Allow from 127.0.0.1
  </Directory>
13] Open conf.inc.php file and make following changes
[root@server ~]# vi /usr/share/phpmyadmin/conf.inc.php
$cfg[ 'blowfish_secret' ] = 'password'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
:wq

14] Restart all service once again
[root@server ~]# service httpd restart
[root@server ~]# service mysqld restart
[root@server ~]# chkconfig httpd on
[root@server~]# chkconfig mysqld on

15] Ponit your browser to following URL:
Syntax = http://<ip address>/phpmyadmin

[ Note = If you encounter of error to open phpmyadmin then paste extracted directory of phpmyadmin to /var/www/html/ and rename it as phpmyadmin ]

No comments: