This tutorial is to install a Lamp stack (Httpd/Apache Web Server, PHP and MySQL) on Centos 6/RHEL and prepare it for use. If you haven't yet installed it the Centos 6 minimal Desktop is a pretty capable and stable Linux disribution to use.
First open a terminal and type
$ sudo su
# yum -y install httpd
To install the httpd server, and then start it with
# /etc/init.d/httpd start
Browse to http://localhost to view the Apache2 test page.
Also you should do
# chkconfig --levels 235 httpd on
To ensure it starts when you boot up your computer.
# yum -y install mysql mysql-server
To start it
# /etc/init.d/mysqld start
You should see the output
"Initializing MySQL database: Installing MySQL system tables...
Filling help tables...
Now to set it up properly do
# mysql_secure_installation (with underscrolls)
This will open up a dialogue so you can complete the following
Set (Change) root password
Remove anonymous users
Disallow root login remotely
Remove test database and access to it
Reload privilege tables
After which you should get the message
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Test it by logging on with
# mysql -u root -p or
# sql -h localhost -u root -p
# yum -y install php php-mysql
Which will install the needed packages
Create a phpinfo page
|Install PHP Centos 6|
# gedit /var/www/html/info.php (or use vi) and type
?> save the file
# /etc/init.d/httpd restart
To restart the server and have it read the new php install
Now browse to http://localhost/info.php
|Phpinfo Centos 6|
To view your php info file which gives you all kinds of info on the installation. There are a variety of extensions included in the standard php installation and you can find more by typing
$ sudo yum search all php
Which will bring up a list of available php related packages.
Write a new index php page.
$ vi /var/www/html/index.php
Enter some test lines
<center><h1>This is the new index php page</h1></center>
Now when you go to localhost in the browser
|Httpd Localhost Php Centos 6|
The new page should be served by default instead of the html one
The basic Lamp stack is now set up and ready to be used.
Labels: Centos 6, HTTPD (Apache), Lamp, MYSQL, PHP, RHEL