Pages

Install LAMP ( Linux Apache Mysql Php ) Server on CentOS 5.2

1. Install apache as web server. type command below on your teminal :

[root:~]# yum -y install httpd httpd-devel

configuration file is located at /etc/httpd/conf/httpd.conf

start service httpd :

[root:~]# /etc/init.d/httpd start

or type this :

[root:~]# service httpd start

to make sure apache installation is work properly, open your browser
and goto url :

http://your_ip_address





2. Install mysql as database server on your machine.

[root:~]# yum -y install mysql mysql-server mysql-devel

start service mysql :

[root:~]# /etc/init.d/mysqld start
open database mysql :

[root:~]# mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 4 to server version: 5.0.51a-log
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql>

type quit to exit from mysql.

set user and password for mysql

[root:~]# mysqladmin -u root password your_password

try login into mysql

[root:~]# mysql -u root -p
Enter password: <=== password that you set before.


set user and password above is to secure your mysql installation, but if not secure enough try to follow each step below by typing :

[root:~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MYSQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into mysql to secure it, we'll need the current
password for the root user. If you've just installed mysql, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): {just return}
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the mysql
root user without the proper authorisation.
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] y
New password: {passwordmysqlroot}
Re-enter new password: {passwordmysqlroot}
Password updated successfully!
Reloading privilege tables..
... Success!
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. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, mysql comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your mysql
installation should now be secure.
Thanks for using mysql!


3. Install php

[root:~]# yum -y install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml

edit file httpd.conf

[root:~]# vi /etc/httpd/conf/httpd.conf

and add this line below on DIrectoryIndex:

DirectoryIndex index.html index.html.var index.htm index.shtml index.cgi index.php index.php5 index.php4
index.php3 index.pl index.aspx default.aspx

now, create file test.php on /var/www/html/ to check php installation

[root:~]# touch /var/www/html/test.php
[root:~]# vi /var/www/html/test.php

put this on test.php :

phpinfo();
?>

save and restart service httpd

[root:~]# /etc/init.d/httpd restart

use your browser to open url : http://your_ip_address/test.php



Congrats! LAMP Server installed on your machine.


No comments:

Post a Comment