Tuesday, 02 December 2008
HughesJR.com
  Home arrow Guides arrow Guides arrow Installing a LAMP (Linux Apache Mysql Php) Server on RHEL Clones
Powered by CentOS
 
Main Menu
Home
Forum
Articles
Guides
News Feeds
Links
Search
Contact Us
Login Form





Lost Password?
No account yet? Register
Latest News
Popular
DS-Syndicate
feed image
Installing a LAMP (Linux Apache Mysql Php) Server on RHEL Clones PDF Print E-mail
User Rating: / 20
PoorBest 
Written by Johnny Hughes   
Sunday, 01 October 2006
This is a guide to install a LAMP (Linux Apache Mysql Php) Web Server on CentOS. You can also use WBEL, Scientific Linux, or Tao Linux. Below is the full text for this guide. If you have any questions concerning this article, please ask on the LAMP Guide board at the HughesJR.com Forums.
This is going to be a LAMP (Linux Apache MySQL PHP) Web server install on CentOS. The first step is going to be to do a minimal install of CentOS. This is accomplishished by selecting a custom install and unchecking everything. This will give you an install with about 540mb of packages. It is the minumum recommended install by RedHat of their Enterprise product.

This install is as lean as possible, and does not contain a GUI. You will need to know how to use an editor in console mode. There are several, I use vi ... nano is also in this install. Either can be used ... please become familiar with a console editor before attempting this install. You will see steps that say edit file /xxx/xxxx ... you should use your perferred editor to do these steps.

All commands are done at the command prompt as root.

Here is the procedure.

1. Install a minimum CentOS (or WBEL, RHEL, Tao Linux, Scientific Linux) install (see this guide). Since this is going to be a server, you want to manually assign an ipaddress on your network, and manually assign a domain name. In my test domain, I assigned the address 192.168.0.30 and a name of lamp.home.local. (I use the 192.168.0.x network inside my firewall, and I have a DNS server setup to put names in for the home.local domain, which I use internally for testing).

After the first boot, edit the file /etc/sysconfig/network to verify the domain name is setup... mine says this:
CODE
NETWORKING=yes
HOSTNAME=lamp.home.local

Also look in /etc/hosts and make sure the name is setup ... mine looks like this:
CODE
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.0.30 lamp.home.local


2-4 Deleted (included in the above minimal install guide).

 

5. Reboot the machine on the new kernel...

6. Now we are ready to install all the packages required to have a LAMP server.

yum install perl-DBD-MySQL mysql-server mysql php-mysql mod_auth_mysql openssl mod_ssl
php httpd perl-CPAN

7. After the install, we will want to make the all the programs start for future reboots and start them right now ... to do that, use the following commands:

chkconfig httpd on
chkconfig mysqld on


Here is how to start them now ....

/etc/init.d/mysqld start
/etc/init.d/httpd start


8. Now I like to add a page called info.php to the root directory of my site to make sure everything is working. Edit a file named /var/www/html/info.php and paste the following into it and then save it:

 

CODE
<HTML>
<HEAD>
 <TITLE>PHP via Enterprise Linux</TITLE>
</HEAD>
<BODY>
 <?php phpinfo(); ?>
</BODY>
</HTML>



Now open a webbrowser and go to your website via either it's name or ip address, so in my case it is this:

http://lamp.home.local/info.php

or

http://192.168.0.30/info.php

9. The configuration files are:

For apache - /etc/httpd/conf/httpd.conf (and all items in the directory /etc/httpd/conf.d). (How to configure apache).

For PHP - /etc/php.ini (how to configure php).

For MySQL - How to Configure

10. There are many new php-* files in CentOS-4.  You may need some of these files (depending on the application(s) you are going to run on the LAMP server.  Here is the current list on CentOS-4:

php
php-devel
php-domxml
php-gd
php-imap
php-ldap
php-mbstring
php-mysql
php-ncurses
php-odbc
php-pear
php-pgsql
php-snmp
php-xmlrpc

If you want information about a specifc package you can get it with yum, for example to get info on php-odbc use this command:

yum info php-odbc

11. Beginning in CentOS-4, there is also a new security enhancement called SELinux .   See this guide for using SELinux on CentOS.  If you keep all your executable web content in /var/www then the default SELinux rules included in CentOS should work OK.  SELinux is very good at minimizing things like root shells from apache exploits, etc.

If you want to use SElinux, edit the file /etc/sysconfig/selinux and set the following variables:

SELINUX=enforcing
SELINUXTYPE=targeted

I do use SELinux on my web servers whenever possible. 

 

Last Updated ( Sunday, 05 August 2007 )
 

© 2008 HughesJR.com
Powered by CentOS