Sunday, April 17, 2011

Installing Apache HTTP Server and PHP 5


Install Apache HTTP Server (httpd) and PHP 5.3.6

1. Change root user

su -
## OR ##
sudo -i

2. Install Remi repository

Fedora

## Remi Dependency on Fedora
rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm 
rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
 
## Fedora 14 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-14.rpm
 
## Fedora 13 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-13.rpm
 
## Fedora 12 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-12.rpm
 
## Fedora 11 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-11.rpm
 
## Fedora 10 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-10.rpm
 
## Fedora 9 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-9.rpm
 
## Fedora 8 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-8.rpm

CentOS and Red Hat (RHEL)

## Remi Dependency on CentOS and Red Hat (RHEL)
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
 
## Red Hat (RHEL) 6 ##
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
 
## CentOS 5 and Red Hat (RHEL) 5 ##
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

3. Install Apache (httpd) Web server and PHP 5.3.6

Fedora 14

yum install httpd php php-common

Fedora 13 (12, 11, 10, 9, 8, 7), CentOS 5.5 and Red Hat (RHEL) 5.5

yum --enablerepo=remi install httpd php php-common

4. Install PHP 5.3.6 modules

Select what you need: PEAR, PDO, MySQL, PostgreSQL, Memcache, GD, MBString, MCrypt, XML

Fedora 14

yum install php-pear php-pdo php-mysql php-pgsql php-pecl-memcache php-gd php-mbstring php-mcrypt php-xml

Fedora 13 (12, 11, 10, 9, 8), CentOS 5.5 and Red Hat (RHEL) 5.5

yum --enablerepo=remi install php-pear php-pdo php-mysql php-pgsql php-pecl-memcache php-gd php-mbstring php-mcrypt php-xml

5. Start Apache HTTP server (httpd) and autostart Apache HTTP server (httpd) on boot

/etc/init.d/httpd start ## use restart after update
## OR ##
service httpd start ## use restart after update
 
chkconfig --levels 235 httpd on

6. Create test PHP page to check that Apache, PHP and PHP modules are working

Add following content to /var/www/html/test.php file.
<?php
 
    phpinfo();
 
?>

7. Check created page with browser

Access following address, with your browser. http://localhost/test.php
PHP 5.3.6 phpinfo

Enable Remote Connection to Apache HTTP Server (httpd) –> Open Web server Port (80) on Iptables Firewall (as root user again)

1. Edit /etc/sysconfig/iptables file:

nano -w /etc/sysconfig/iptables

2. Add following line before COMMIT:

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

3. Restart Iptables Firewall:

service iptables restart
## OR ##
/etc/init.d/iptables restart

4. Test remote connection

Access following address, with your browser. http://your.domain/test.php

No comments:

Post a Comment