This guide shows howto install Apache HTTP Server (httpd) with PHP 5.3.3 and following modules:
· PEAR
· PDO
· MySQL
· PostgreSQL
· Memcache
· GD
· XML
· MBString
· MCrypt
on Fedora 14/13/12/11/10/9/8/7/6, CentOS 5.4/5.5 and Red Hat (RHEL) 5.4/5.5/6systems.
Install Apache HTTP Server (httpd) and PHP 5.3.3
1. Change root user
su -
## OR ##
sudo -i
2. Install Remi repository
CentOS and Red Hat (RHEL)
## Remi Dependency on CentOS and Red Hat (RHEL)
!! Down Load epel-release-5-4.noarch.rpm, remi-release-5.rpm
rpm -Uvh epel-release-5-4.noarch.rpm
rpm -Uvh remi-release-5.rpm
3. Install Apache (httpd) Web server and PHP 5.3.3
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.3 modules
Select what you need: PEAR, PDO, MySQL, PostgreSQL, Memcache, GD, MBString, MCrypt, XML
Fedora 13 (12, 11, 10, 9, 8, 7), 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
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
· To remove a previous PHP version:
# yum list php
# yum remove php
· Apache root directory is: /var/www/html
Permanently redirect users to access the site WITH or WITHOUT the 'www.' prefix
1. Create/Open a .htaccess file in the document root folder and add the following text replacing variables with appropriate values where necessary
# mod_rewrite
<IfModule mod_rewrite.c>
# Enable mod_rewrite engine
RewriteEngine on
# WITH 'www.'
RewriteCond %{HTTP_HOST} ^$uri\.$tld$ [NC]
RewriteRule ^(.*)$ http://www.$domain$1 [L,R=301]
# WITOUT 'www.'
RewriteCond %{HTTP_HOST} ^www\.$uri\.$tld$ [NC]
RewriteRule ^(.*)$ http://$domain/$1 [L,R=301]
</IfModule>
Done
Inas
# mod_rewrite
<IfModule mod_rewrite.c>
# Enable mod_rewrite engine
RewriteEngine on
# WITH 'www.'
RewriteCond %{HTTP_HOST} ^$uri\.$tld$ [NC]
RewriteRule ^(.*)$ http://www.$domain$1 [L,R=301]
# WITOUT 'www.'
RewriteCond %{HTTP_HOST} ^www\.$uri\.$tld$ [NC]
RewriteRule ^(.*)$ http://$domain/$1 [L,R=301]
</IfModule>
Done
Inas
No comments:
Post a Comment