Configure VPS | Install LAMP on Centos VPS Part 1

Few days before when I had a VPS and needed to install wordpress, I found it very difficult because very few resources were available on google
So I am here now with my new post, On HOW TO INSTALL LAMP ON CENTOS
First buy an unmanaged VPS, and get ssh access
Then install Putty software in your computer, and start it
Then Follow the further steps

Start Putty software and then enter your IP for eg. 255.255.255.254
it will ask for username
generally its root and then enter the password
after that start typing the following code

IMPORTANT: IF YOU ARE NOT FAMILIAR WITH SSH COMMAND THEN BE CAREFUL. JUST COPY PASTE THE CODES.

First we will install yum
code:

yum install -y yum-priorities

After this we need to download updated repositories for php and mysql packages
code:
wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

Then we will extract that by following command
code:
rpm -Uvh epel-release-5-4.noarch.rpm

rpm -Uvh remi-release-5.rpm

After This we give priorities to repo and exclude php mysql and phpmyadmin from repository
code:

vi /etc/yum.repos.d/CentOS-Base.repo

After this a file will be opened, press I from the keyboard to edit it, and after editing press esc button and type :x to save it
code:
priority=1
exclude=*php* *mysql* *phpmyadmin*

Copy paste this above code five times before the following lines

#released updates
#packages used/produced in the build but not released
#additional packages that may be useful
#additional packages that extend functionality of existing packages
Copy paste the next lines before this line #contrib - packages by Centos Users

Code:
priority=2
exclude=*php* *mysql* *phpmyadmin*
Just one line above priority=2 their will be a line enabled=0 just make that to 1

After this press esc and type :x to save the file
Now same thing for epel and remi repository
code:

vi /etc/yum.repos.d/epel.repo

Just Above this line [epel-debuginfo] insert this code(inserting and saving is been explained on top)
Code:

priority=3

Now after saving that, we will now edit the same code with just different filename

Code:
vi /etc/yum.repos.d/remi.repo

And now in this, just above [remi-test] line, change the value of enable=0 to 1
and paste this code exactly above the [remi-test] line

Code:

priority=3

Save it and now we will install apache web server,

Code:

yum install -y httpd

After this we will install php,

Code:

yum install php

During the installation it will prompt you for importing GPG key for the new repositories, just type y and press enter, this will be come for two times

Now we will start the Apache server

Code:
/etc/init.d/httpd start

Just to test our Apache and php, we will create a phpinfo file

Code:
vi /var/www/html/info.php

A new file will be created, insert this code into it, and then save it

Code:
<?
phpinfo();
?>

Now in your browser, enter this URL, http://your IP or localhost/info.php
Now a PHP INFO file should open, where it will display php and servers information
if not then restart the apache server,
To restart the server,

Code:

/etc/init.d/httpd restart

Now we will install MySql

Code:

yum install -y mysql-server mysql php-mysql

Now the next code is used to configure Apache , to start MySql when server is rebooted.

Code:
chkconfig httpd on
chkconfig mysqld on

Fire up MySql Server

Code:

/etc/init.d/mysqld start

Now we will set the root password of mysql

Code:
mysql -u root password password

Here the second password is the actual root password, you can change it with your's own.

Now its time to do last job, thats installing phpmyadmin

Code:

yum install -y phpmyadmin

Now we have to edit phpMyAdmin config file to avoid the Forbidden Access Error

Code:

vi /etc/httpd/conf.d/phpMyAdmin.conf

Search for a line,

deny from all
Comment the above line just by inserting # before the line, so after that, it should look like the following,

# deny from all

Save it and restart the Apache server

Code:

/etc/init.d/httpd restart

Done
Now goto the browser and type this URL
http://IP or localhost/phpmyadmin
Now the page will appear, just enter username as root and password as password

Feel free to give suggestions.

1 comments:

N said...

Really interesting and I appreciate your hard work,
Good Job

About Me

My Photo
NiRaJ (asp or php)!!!!!!
I am basically a software engineer and Website designer & developer (final year student)
View my complete profile

Woooo

WooThemes - Made by Designers