Install Apache/PHP 5.5.14 on Fedora 20/19, CentOS/RHEL 6.5/5.10

This guide shows howto install Apache HTTP Server (httpd) with PHP 5.5.14 and following modules on Fedora 20/19/18/17, CentOS 6.5/6.4/6.3/6.2/6.1/6/5.10 and Red Hat (RHEL) 6.5/6.4/6.3/6.2/6.1/6/5.10 systems.

  • APCu (php-pecl-apcu) – APCu userland caching
  • CLI (php-cli) – Command-line interface for PHP
  • PEAR (php-pear) – PHP Extension and Application Repository framework
  • PDO (php-pdo) – A database access abstraction module for PHP applications
  • MySQL (php-mysqlnd) – A module for PHP applications that use MySQL databases
  • PostgreSQL (php-pgsql) – A PostgreSQL database module for PHP
  • MongoDB (php-pecl-mongo) – PHP MongoDB database driver
  • SQLite (php-sqlite) – Extension for the SQLite V2 Embeddable SQL Database Engine
  • Memcache (php-pecl-memcache) – Extension to work with the Memcached caching daemon
  • Memcached (php-pecl-memcached) – Extension to work with the Memcached caching daemon
  • GD (php-gd) – A module for PHP applications for using the gd graphics library
  • XML (php-xml) – A module for PHP applications which use XML
  • MBString (php-mbstring) – A module for PHP applications which need multi-byte string handling
  • MCrypt (php-mcrypt) – Standard PHP module provides mcrypt library support

Install Apache HTTP Server (httpd) and PHP 5.5.14 on Fedora 20/19/18/17, CentOS / Red Hat (RHEL) 6.5/5.10

1. Change root user

su -
## OR ##
sudo -i

2. Install Remi repository

Fedora

## Remi Dependency on Fedora 20 / 19 / 18 / 17 ##
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 20 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-20.rpm
 
## Fedora 19 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-19.rpm
 
## Fedora 18 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-18.rpm
 
## Fedora 17 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-17.rpm

CentOS and Red Hat (RHEL)

## Remi Dependency on CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
 
## CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
 
 
## Remi Dependency on CentOS 5 and Red Hat (RHEL) 5 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.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.5.14

Fedora 20/19

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

Fedora 18/17

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

CentOS 6.5/5.10 and Red Hat (RHEL) 6.5/5.10

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

4. Install PHP 5.5.14 modules

Select what you need: APCu, CLI, PEAR, PDO, MySQL, PostgreSQL, MongoDB, SQLite, Memcache, Memcached, GD, MBString, MCrypt, XML

More info about PHP APC from PHP APC Configuration and Usage Tips and Tricks.

Fedora 20/19

yum --enablerepo=remi install php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

Fedora 18/17

yum --enablerepo=remi,remi-test install php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

CentOS 6.5/5.10 and Red Hat (RHEL) 6.5/5.10

yum --enablerepo=remi,remi-php55 install php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached 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
 
## Fedora ##
systemctl enable httpd.service
 
## CentOS / RHEL ##
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
Fedora 19 Running Apache and PHP 5.5.0

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

1. CentOS/Red Hat (RHEL)

1.1 Edit /etc/sysconfig/iptables file:

nano -w /etc/sysconfig/iptables

1.2 Add following INPUT rule:

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

1.3 Restart Iptables Firewall:

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

2. Fedora

2.1 Add New Rule to Firewalld

firewall-cmd --permanent --zone=public --add-service=http
 
## OR ##
 
firewall-cmd --permanent --zone=public --add --port=80/tcp

2.2 Restart firewalld.service

systemctl restart firewalld.service

3. Test remote connection

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

More reading:

Enable Apache Userdir with SELinux on Fedora 19/18/17, CentOS 6.4/6.3/6.2/6.1/6/5.9, Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9 >>

Follow If Not True Then False Updates!

231 Comments

  1. Thanks! Works :)

    One more addition:
    If you are getting the message:
    “Starting httpd: httpd: Could not reliably determine the server’s fully qualified domain name, using ::1 for ServerName” when you try to restart httpd, you can give a name to the server in /etc/httpd/conf/httpd.conf file:
    ServerName theNAMEyouCHOOSE:80

    also you should set
    UseCanonicalName On

    Best,
    Jozsef

  2. When I tried to execute the first rpm command to access the remi repository, I got:


    [jrosen@localhost ~]$ rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
    Retrieving http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
    error: skipping http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm - transfer failed - Unknown or unexpected error

    I notice that this thread is relatively recent so I was surprised that something may have broken in the past couple of weeks.

    Thanks,

    Jon

    • And just to clarify, I have been doing other yum/rpm commands all night and they have all worked fine, so it doesn’t appear to be an Internet connectivity thing or anything (and yes, I tried doing another command after this one failed and that worked as well, and I tried this several times, always failing, including on other machines.)

      Thanks!

      • Hi Jon,

        I tested this and found the problem. Epel repository has been updated to 5-4 release and now 5-3 release is removed, so the following command should work:

        rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

        I updated this and other guides too, thank you for your attention.

  3. i keep getting the error
    No package php-pear available.
    No package php-pdo available.
    No package php-mysql available.
    No package php-pgsql available.
    No package php-pecl-memcache available.
    No package php-gd available.
    No package php-mbstring available.
    No package php-mcrypt available.
    No package php-xml available.

    • Hi Don,

      What operating system do you use?

      Did you added and enabled remi repository?

  4. When i try to create a PHP test page, I get an error message saying I do not have permission to access the html file. How can I unlock the permission? All other internet resources are not giving me a clear command. Would really appreciate it!

    • Hi mk,

      Could you post exact error message from browser and apache(httpd) error log (/var/log/httpd/error_log)?
      And could you also check, do you get any SELinux warning?

      • I get the same error on Fedora 14
        I was getting a SELinux warning but I changed the servername and Canonical as you suggested in a comment and it seems to have stopped. Now I get a 500 error.

        • Could you post full error message from /var/log/httpd/error_log file?

  5. I got the following error
    Running CentOS 5.5

    Transaction Check Error:
    file /etc/my.cnf from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/charsets/Index.xml from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/charsets/cp1250.xml from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/czech/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/danish/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/dutch/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/english/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/estonian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/french/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/german/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/greek/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/hungarian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/italian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/japanese/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/korean/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/norwegian-ny/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/norwegian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/polish/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/portuguese/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/romanian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/russian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/serbian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/slovak/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/spanish/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/swedish/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.x86_64
    file /etc/my.cnf from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/charsets/Index.xml from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/charsets/cp1250.xml from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/czech/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/danish/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/dutch/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/english/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/estonian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/french/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/german/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/greek/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/hungarian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/italian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/japanese/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/korean/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/norwegian-ny/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/norwegian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/polish/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/portuguese/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/romanian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/russian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/serbian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/slovak/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/spanish/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/swedish/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
    file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-libs-5.1.54-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386

    • Hi Hoddie54,

      Try update MySQL with following command:

      yum --enablerepo=remi update mysql\*

      And then try installation again…

  6. Trying to install MySql on RHEL 5.5, I get the following when I run “yum –enablerepo=remi install mysql mysql-server”:

    Loaded plugins: rhnplugin, security
    This system is not registered with RHN.
    RHN support will be disabled.
    Setting up Install Process
    Resolving Dependencies
    –> Running transaction check
    —> Package mysql.x86_64 0:5.1.55-1.el5.remi set to be updated
    –> Processing Dependency: mysql-libs = 5.1.55-1.el5.remi for package: mysql
    –> Processing Dependency: libmysqlclient_r.so.16(libmysqlclient_16)(64bit) for package: mysql
    –> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: mysql
    –> Processing Dependency: libmysqlclient.so.16()(64bit) for package: mysql
    –> Processing Dependency: libmysqlclient_r.so.16()(64bit) for package: mysql
    —> Package mysql-server.x86_64 0:5.1.55-1.el5.remi set to be updated
    –> Processing Dependency: perl-DBD-MySQL for package: mysql-server
    –> Running transaction check
    —> Package mysql-libs.x86_64 0:5.1.55-1.el5.remi set to be updated
    —> Package mysql-server.x86_64 0:5.1.55-1.el5.remi set to be updated
    –> Processing Dependency: perl-DBD-MySQL for package: mysql-server
    –> Finished Dependency Resolution
    mysql-server-5.1.55-1.el5.remi.x86_64 from remi has depsolving problems
    –> Missing Dependency: perl-DBD-MySQL is needed by package mysql-server-5.1.55-1.el5.remi.x86_64 (remi)
    Error: Missing Dependency: perl-DBD-MySQL is needed by package mysql-server-5.1.55-1.el5.remi.x86_64 (remi)
    You could try using –skip-broken to work around the problem
    You could try running: package-cleanup –problems
    package-cleanup –dupes
    rpm -Va –nofiles –nodigest
    The program package-cleanup is found in the yum-utils package.
    #

    Any advice or help to offer so I can get mysql running?

    • Hi sebastiang,

      Try following:

      yum --enablerepo=remi search perl-DBD-MySQL

      What is output?

  7. Hi JR,

    I get similar error to what sebastian gets when I tried to install php.
    I am using rhel 6 stable/newer version. Apache and mysql servers are installed.
    When I tried yum enablerepo remi search php
    it lists php but when I tried to install php with the command yum enablerepo remi install php
    it gives me an error.

    Any information on this?

    Shank

    • Hi shashank,

      Btw, you could update your remi repo to RHEL 6 version with following command:

      rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

      Then try again. And please post error messages what you get on installation?

      I added this Remi RHEL 6 repo also to guide.

      • Hi JR,

        Yes, I updated the remi with version 6 when I checked the figured it out and installed it from the remi repository.

        I resolved my issue by updating mysql with the version I downloaded one from remi. When I replaced the rhel 6 version mysql with remi version…My php-common libcurl.so:3 error went away and I was able to install php.

        Thank you for the tutorial. It was really helpful.

        Shank

      • Hi JR.

        I am trying to install php-imap on the remi release.

        But run against some issues, and i am not that expert. Can you help me to solve this issue.

        Thanks.

        Resolving Dependencies
        –> Running transaction check
        —> Package php-imap.x86_64 0:5.1.6-27.el5_5.3 set to be updated
        –> Processing Dependency: php-common = 5.1.6-27.el5_5.3 for package: php-imap
        –> Processing Dependency: libc-client.so.1()(64bit) for package: php-imap
        –> Running transaction check
        —> Package libc-client.x86_64 0:2004g-2.2.1 set to be updated
        —> Package php-imap.x86_64 0:5.1.6-27.el5_5.3 set to be updated
        –> Processing Dependency: php-common = 5.1.6-27.el5_5.3 for package: php-imap
        –> Finished Dependency Resolution
        php-imap-5.1.6-27.el5_5.3.x86_64 from updates has depsolving problems
        –> Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-imap-5.1.6-27.el5_5.3.x86_64 (updates)
        Error: Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-imap-5.1.6-27.el5_5.3.x86_64 (updates)
        You could try using –skip-broken to work around the problem
        You could try running: package-cleanup –problems
        package-cleanup –dupes
        rpm -Va –nofiles –nodigest

        • Hi Marco,

          Could you post output of following command:

          yum list installed |grep php
  8. I followed the instructions to add the new repositories but here’s what I get:

    # yum –enablerepo=remi install httpd php
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * addons: mirrors.versaweb.com
    * base: mirrors.usc.edu
    * epel: mirrors.solfo.com
    * extras: centos.promopeddler.com
    * remi: iut-info.univ-reims.fr
    * updates: mirror.5ninesolutions.com
    Excluding Packages in global exclude list
    Finished
    Setting up Install Process
    No package httpd available.
    No package php available.
    Nothing to do

    I’m using CentOS 5.5 — do you have any idea why this isn’t working

    • Hi Blair,

      First is good to know what is in your global exclude list?

      ...
      Excluding Packages in global exclude list
      Finished
      ...
  9. Sorry, Im a newbie in this… I’m trying to install Apache following your guide but I gotta error message after adding the instruction of

    Adding following line before COMMIT:

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

    After restart the iptables I gotta the following error message

    iptables: Flushing firewall rules: [ OK ]
    iptables: Setting chains to policy ACCEPT: filter [ OK ]
    iptables: Unloading modules: [ OK ]
    iptables: Applying firewall rules: iptables-restore: line 13 failed [FAILED]

    And I’d no access to the file test.php through the browser.
    Some ideas?
    Thanx in advance.

    • Adding the folowing line below “:OUTPUT ACCEPT [0:0]” seems to remove the error:

      :RH-Firewall-1-INPUT - [0:0]

  10. I gotta say I actually can see the test.php but the rule in the firewall launches till the error.

  11. When i try to create a PHP test page, i just got blank page??

    • Hi Ar,

      Do you get any errors on /var/log/httpd/error_log or any SELinux warnings?

  12. I am getting the following errors :

    –> Processing Dependency: php-common = 5.1.6-27.el5_5.3 for package: php-mysql
    —> Package php-pdo.i386 0:5.1.6-27.el5_5.3 set to be updated
    –> Processing Dependency: php-common = 5.1.6-27.el5_5.3 for package: php-pdo
    —> Package php-pecl-memcache.i386 0:2.2.6-1.el5 set to be updated
    –> Processing Dependency: php-zend-abi = 20050922 for package: php-pecl-memcache
    —> Package php-pgsql.i386 0:5.1.6-27.el5_5.3 set to be updated
    –> Processing Dependency: php-common = 5.1.6-27.el5_5.3 for package: php-pgsql
    —> Package php-xml.i386 0:5.1.6-27.el5_5.3 set to be updated
    –> Processing Dependency: php-common = 5.1.6-27.el5_5.3 for package: php-xml
    –> Finished Dependency Resolution
    php-xml-5.1.6-27.el5_5.3.i386 from base has depsolving problems
    –> Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-xml-5.1.6-27.el5_5.3.i386 (base)
    php-pecl-memcache-2.2.6-1.el5.i386 from epel has depsolving problems
    –> Missing Dependency: php-zend-abi = 20050922 is needed by package php-pecl-memcache-2.2.6-1.el5.i386 (epel)
    php-pdo-5.1.6-27.el5_5.3.i386 from base has depsolving problems
    –> Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-pdo-5.1.6-27.el5_5.3.i386 (base)
    php-devel-5.1.6-27.el5_5.3.i386 from base has depsolving problems
    –> Missing Dependency: php = 5.1.6-27.el5_5.3 is needed by package php-devel-5.1.6-27.el5_5.3.i386 (base)
    php-gd-5.1.6-27.el5_5.3.i386 from base has depsolving problems
    –> Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-gd-5.1.6-27.el5_5.3.i386 (base)
    php-pgsql-5.1.6-27.el5_5.3.i386 from base has depsolving problems
    –> Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-pgsql-5.1.6-27.el5_5.3.i386 (base)
    php-mysql-5.1.6-27.el5_5.3.i386 from base has depsolving problems
    –> Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-mysql-5.1.6-27.el5_5.3.i386 (base)
    php-mcrypt-5.1.6-15.el5.centos.1.i386 from extras has depsolving problems
    –> Missing Dependency: php-api = 20041225 is needed by package php-mcrypt-5.1.6-15.el5.centos.1.i386 (extras)
    php-mbstring-5.1.6-27.el5_5.3.i386 from base has depsolving problems
    –> Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-mbstring-5.1.6-27.el5_5.3.i386 (base)
    Error: Missing Dependency: php-api = 20041225 is needed by package php-mcrypt-5.1.6-15.el5.centos.1.i386 (extras)
    Error: Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-mbstring-5.1.6-27.el5_5.3.i386 (base)
    Error: Missing Dependency: php = 5.1.6-27.el5_5.3 is needed by package php-devel-5.1.6-27.el5_5.3.i386 (base)
    Error: Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-pgsql-5.1.6-27.el5_5.3.i386 (base)
    Error: Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-xml-5.1.6-27.el5_5.3.i386 (base)
    Error: Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-mysql-5.1.6-27.el5_5.3.i386 (base)
    Error: Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-gd-5.1.6-27.el5_5.3.i386 (base)
    Error: Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-pdo-5.1.6-27.el5_5.3.i386 (base)
    Error: Missing Dependency: php-zend-abi = 20050922 is needed by package php-pecl-memcache-2.2.6-1.el5.i386 (epel)
    You could try using –skip-broken to work around the problem
    You could try running: package-cleanup –problems
    package-cleanup –dupes
    rpm -Va –nofiles –nodigest

    It happens when trying to install the php-mysql (that i need a *lot*) :P

    thanks!

    • Hi tiagoh,

      Did you setup remi repository?

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

      And did you enabled it when you trying to install php-mysql?

      yum --enablerepo=remi install php-mysql
  13. who can install httpd on fedora 15, without yum

    • Hi kreshan,

      So do you want to install httpd without yum on Fedora 15?

  14. remove old version before..

    yum remove php php-common

  15. Thanks so much for this tutorial. It worked with one exception. I found the solution in the comments:

    “Sorry, Im a newbie in this… I’m trying to install Apache following your guide but I gotta error message after adding the instruction of

    Adding following line before COMMIT:

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

    After restart the iptables I gotta the following error message

    iptables: Flushing firewall rules: [ OK ]
    iptables: Setting chains to policy ACCEPT: filter [ OK ]
    iptables: Unloading modules: [ OK ]
    iptables: Applying firewall rules: iptables-restore: line 13 failed [FAILED]

    And I’d no access to the file test.php through the browser.
    Some ideas?
    Thanx in advance.

    Reply
    Diederik Veelo
    Posted May 27, 2011 at 2:02 PM
    Adding the folowing line below “:OUTPUT ACCEPT [0:0]” seems to remove the error:

    :RH-Firewall-1-INPUT – [0:0]”

    Again, keep up the good work. It really helps people like me!!

    • Hi CentOS_dude,

      Try following iptables rule instead:

      -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
      • Hye JR, thanks for the update. Your code worked without any problems.

  16. Hi, I was wondering how am I supposed to test the remote connection. Is the URL literally http://your.(mydomainnamehere)/test.php ?? or is the your not supposed to be there?? or how exactly do I go about testing the remote connection, BTW everything else worked perfect thank you for helping everyone out.

    • Hi Henry,

      You could test it easily from some other machine. Set up Apache and then create test page, open firewall port and just test it… :) URL is that what you have specified on local network server.local.lan or some real domain name, like http://www.if-not-true-then-false.com.

  17. Thanks.
    It works so nice.

  18. disculpe la pregunta lo que pasa es que quiero instalar el wordpress en centos 5.5 y me piden php5.2.4 i386 y noce donde puedo encontrar
    noce si me puedan enviar un link de los repositorios ok
    gracias

  19. thanks, somewhat i was having touble with php-mysql but this seemed to do the trick. Very to the point

  20. [root@root ~]# /etc/init.d/httpd restart
    Restarting httpd (via systemctl): Job failed. See system logs and ‘systemctl status’ for details.
    [FAILED]

    WHAT SHOULD I DO????

    • Hi Laukik,

      Please post first output of following commands:

      uname -a
       
      systemctl status httpd.service
       
      grep httpd /var/log/messages
      • [root@root ~]# uname -a
        Linux root 3.1.0-7.fc16.i686.PAE #1 SMP Tue Nov 1 20:53:45 UTC 2011 i686 i686 i386 GNU/Linux

        [root@root ~]# systemctl status httpd.service
        httpd.service – The Apache HTTP Server (prefork MPM)
        Loaded: loaded (/lib/systemd/system/httpd.service; enabled)
        Active: failed since Thu, 29 Dec 2011 21:55:48 +0530; 4min 29s ago
        Process: 2575 ExecStart=/usr/sbin/httpd $OPTIONS -k start (code=dumped, signal=SEGV)
        CGroup: name=systemd:/system/httpd.service

        • [root@root ~]# uname -a
          Linux root 3.1.0-7.fc16.i686.PAE #1 SMP Tue Nov 1 20:53:45 UTC 2011 i686 i686 i386 GNU/Linux
          [root@root ~]# systemctl status httpd.service
          httpd.service – The Apache HTTP Server (prefork MPM)
          Loaded: loaded (/lib/systemd/system/httpd.service; enabled)
          Active: failed since Thu, 29 Dec 2011 21:55:48 +0530; 4min 29s ago
          Process: 2575 ExecStart=/usr/sbin/httpd $OPTIONS -k start (code=dumped, signal=SEGV)
          CGroup: name=systemd:/system/httpd.service
          [root@root ~]# grep httpd /var/log/messages
          Dec 28 21:51:22 root httpd[2682]: httpd: Could not reliably determine the server’s fully qualified domain name, using fe80::227:eff:fe39:3127 for ServerName
          Dec 28 21:51:22 root kernel: [ 1430.410455] httpd[2682]: segfault at d ip 005e59f5 sp bf9bcc10 error 4 in mod_perl.so[5c9000+33000]

          • Do you need mod_perl?

            • whats mon_perl?

              • mod_perl is An embedded Perl interpreter for the Apache HTTP Server.

                You have mod_perl package installed, some reason? And mod_perl have bug on Fedora 16 which prevent your httpd starting and cause segfaults.

                Actually according to bug report it should be fixed if you update to latest version of mod_perl, so try following (as root):

                yum update mod_perl*

                Then try to start httpd again…please let me know if it’s still not working? :)

  21. Hello Plz help me for change port 80 to 8088
    founf below error

    Failed to start apache :
    Starting httpd: httpd: apr_sockaddr_info_get() failed for connect
    httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
    (13)Permission denied: make_sock: could not bind to address [::]:8088
    (13)Permission denied: make_sock: could not bind to address 0.0.0.0:8088
    no listening sockets available, shutting down
    Unable to open logs
    [FAILED]

    • Hi daven patel,

      Do you run httpd start command as root user?

      Please post output of following command:

      grep -i listen /etc/httpd/conf/httpd.conf |grep -v '^#'
  22. Help me…
    I’m use lampp & Install httpd. What can proceed smoothly without conflicts?

    • Hi Nurul,

      Sorry, but I didn’t understand what is problem, if you use lampp (or lamp)? So you already have httpd?

  23. I have installed RHEL 6.2 but the php packages that are available from their “@rhel-x86_64-server-6″ package does not contain mbstring.

    Mgmt says we should only user rhel packages and not anyone else’s.

    How can we install the php-mbstring then?

    Installed Packages
    php.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
    php-cli.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
    php-common.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
    php-gd.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
    php-ldap.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
    php-mysql.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
    php-odbc.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
    php-pdo.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
    php-pear.noarch 1:1.9.4-4.el6 @rhel-x86_64-server-6
    php-pecl-apc.x86_64 3.1.3p1-1.2.el6.1 @rhel-x86_64-server-6
    php-pecl-memcache.x86_64 3.0.5-3.el6 @rhel-x86_64-server-6
    php-pgsql.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
    php-soap.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
    php-xml.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
    php-xmlrpc.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6

    thanks

    Larry

    • Hi Larry,

      Could you post output of following command:

      yum repolist all
  24. HI !
    Thanks for the tutorial ! would you please tell me how to enable or install pdo_mysql driver in php 5.3.9 in linux centos 6 64bit.

    • Hi jules,

      You are welcome! :)

      To enable/install pdo_mysql following packages should be enough:

      yum install httpd php php-common php-pdo php-mysql

      Simply check it from phpinfo() or test use pdo_mysql.

      Please let me know, if you have some problems? :)

      • Hi JR !
        Thanks. I still have some problem with my php .
        When i run a script with pdo sqlite code ,
        it shows
        “ERROR: Could not connect:could not find driver”

        [root@localhost ~]# php -v
        PHP 5.3.9 (cli) (built: Jan 10 2012 19:59:29)
        Copyright (c) 1997-2012 The PHP Group
        Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

        and
        [root@localhost ~]# rpm -qa php\*php-sqlite-5.3.9-1.el6.remi.x86_64
        phpMyAdmin-3.4.9-1.el6.remi.noarch
        php-xml-5.3.9-1.el6.remi.x86_64
        php-cli-5.3.9-1.el6.remi.x86_64
        php-pecl-memcached-1.0.2-9.el6.remi.x86_64
        php-5.3.9-1.el6.remi.x86_64
        php-mcrypt-5.3.9-1.el6.remi.x86_64
        php-pdo-5.3.9-1.el6.remi.x86_64
        php-pecl-igbinary-1.1.1-2.el6.remi.x86_64
        php-pecl-mongo-1.2.7-1.el6.remi.x86_64
        php-pgsql-5.3.9-1.el6.remi.x86_64
        php-pecl-memcache-3.0.6-2.el6.remi.x86_64
        php-mysql-5.3.9-1.el6.remi.x86_64
        php-gd-5.3.9-1.el6.remi.x86_64
        php-common-5.3.9-1.el6.remi.x86_64
        php-pecl-apc-3.1.9-3.el6.remi.x86_64
        php-mbstring-5.3.9-1.el6.remi.x86_64
        php-pear-1.9.4-3.el6.remi.noarch
        php-devel-5.3.9-1.el6.remi.x86_64

        will you please help me !because i would like to do my final project with sqlite .

        • Install php-sqlite also with:

          yum --enablerepo=remi install php-sqlite

          If you have web project then restart web server and try again… :)

  25. hi JR!
    ithink php-sqlite is already installed but still asking for the driver

    it still complain
    ERROR: Could not connect:could not find driver
    what can i do ?

    • Hi jules,

      Could you post output of following command:

      rpm -qa php\* |sort

      Did you restart your web server?

      Could you check your phpinfo, is pdo_sqlite enabled?

  26. Hello JR !
    this the output of the command
    [root@aca800a0 ~]# rpm -qa php\* |sort
    php-5.3.9-1.el6.remi.x86_64
    php-cli-5.3.9-1.el6.remi.x86_64
    php-common-5.3.9-1.el6.remi.x86_64
    php-devel-5.3.9-1.el6.remi.x86_64
    php-gd-5.3.9-1.el6.remi.x86_64
    php-mbstring-5.3.9-1.el6.remi.x86_64
    php-mcrypt-5.3.9-1.el6.remi.x86_64
    phpMyAdmin-3.4.9-1.el6.remi.noarch
    php-mysql-5.3.9-1.el6.remi.x86_64
    php-pdo-5.3.9-1.el6.remi.x86_64
    php-pear-1.9.4-4.el6.noarch
    php-pecl-apc-3.1.9-3.el6.remi.x86_64
    php-pecl-igbinary-1.1.1-3.el6.x86_64
    php-pecl-memcache-3.0.6-2.el6.remi.x86_64
    php-pecl-memcached-1.0.2-9.el6.remi.x86_64
    php-pecl-mongo-1.2.7-1.el6.remi.x86_64
    php-sqlite-5.3.9-1.el6.remi.x86_64
    php-xml-5.3.9-1.el6.remi.x86_64

    in the phpinfo page, i checked pdo-sqlite is enabled this way

    pdo_sqlite
    PDO Driver for SQLite 3.x enabled
    SQLite Library 3.7.6.3

    but still complain could not find the driver . Please help me .

    • Thanks jules!

      Really strange, because everything looks ok, then next thing is check your code…and maybe even try to reproduce your error on another system…

      So could you please post some code snippet, which should work?

  27. this my code :

    Project 11-1: Validating Form Input

    div.error{
    color: red;
    font-weight: bolder;
    }
    div.success{
    color: green;
    font-weight: bolder;
    }

    Project 11-1:Validating Form Input
    Enter Book Details
    <?php
    //display input validation error
    function getInputError($key,$errArray) {
    if(in_array($key,$errArray)){
    return "ERROR: Invalid data for field ‘$key’”;
    }else {
    return false;
    }
    }
    $inputErrors=array();
    $submitted=false;
    //if form submitted
    //validate form input
    if(isset($_POST['submit'])){
    $submitted=true;
    $valid=array();

    //validate title

    if(!empty($_POST['title'])) {
    $valid['title']=htmlentities(trim($_POST['title']));
    } else {
    $inputErrors[]=’author’;
    }
    //validate author name
    if(!empty($_POST['author'])&& preg_match(“/^[a-zA-Z\s.\-]+$/”,$_POST['author'])){
    $valid['author']=htmlentities(trim($_POST['author']));
    }
    else {
    $inputError[]=’author’;
    }
    //validate ISBN

    if(!empty($_POST['isbn']) && preg_match(‘/^(97(8|9))?\d{9}(\d|X)$/’,$_POST['isbn'])){
    $valid['isbn']=htmlentities(trim($POST['isbn']));
    }
    else {
    $inputError[]=’isbn’;
    }
    //validate price
    if(!empty($_POST['price']) && is_numeric($_POST['price']) && $_POST['price'] >0){
    $valid['price']=htmlentities(trim($_POST['price']));
    }else {
    $inputErrors[]=’price’;
    }
    }
    //if form not submitted
    //or if validation errors exist
    //redisplay form

    if(($submitted==true && count($inputErrors)>0)|| $submitted==false){

    ?>

    Title :
    <input type="text" size="25" name="title" value="”/>

    Author :
    <input type="text" size="25" name="author" value="”/>

    ISBN :
    <input type="text" size="25" name="isbn" value="”/>

    Price :
    <input type="text" size="25" name="price" value="”/>

    setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    }catch(PDOException $e){
    die(“ERROR: Could not connect:”.$e->getMessage());
    }
    //create and execute INSERT query
    try{
    $title=$pdo->quote($valid['title']);
    $author=$pdo->quote($valid['author']);
    $isbn=$pdo->quote($valid['isbn']);
    $price=$pdo->quote($valid['price']);
    $sql=”INSERT INTO books(title,author,isbn,price) VALUES($title,$author,$isbn,$price)”;
    $ret=$pdo->exec($sql);
    echo’SUCCESS:Record saved !’;
    } catch(Exception $e){
    echo’ERROR:’.$e->getMessage().”;
    }
    unset($pdo);
    }
    ?>

    • Hi jules,

      Here is some code missing here:

      Price :
      <input type="text" size="25" name="price" value=""/>
      ???setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      }catch(PDOException $e){
      die("ERROR: Could not connect:".$e->getMessage());
      }
  28. Hi JR !
    the whole code is

    Project 11-1: Validating Form Input

    div.error{
    color: red;
    font-weight: bolder;
    }
    div.success{
    color: green;
    font-weight: bolder;
    }

    Project 11-1:Validating Form Input
    Enter Book Details
    <?php
    //display input validation error
    function getInputError($key,$errArray) {
    if(in_array($key,$errArray)){
    return "ERROR: Invalid data for field ‘$key’”;
    }else {
    return false;
    }
    }
    $inputErrors=array();
    $submitted=false;
    //if form submitted
    //validate form input
    if(isset($_POST['submit'])){
    $submitted=true;
    $valid=array();

    //validate title

    if(!empty($_POST['title'])) {
    $valid['title']=htmlentities(trim($_POST['title']));
    } else {
    $inputErrors[]=’author’;
    }
    //validate author name
    if(!empty($_POST['author'])&& preg_match(“/^[a-zA-Z\s.\-]+$/”,$_POST['author'])){
    $valid['author']=htmlentities(trim($_POST['author']));
    }
    else {
    $inputError[]=’author’;
    }
    //validate ISBN

    if(!empty($_POST['isbn']) && preg_match(‘/^(97(8|9))?\d{9}(\d|X)$/’,$_POST['isbn'])){
    $valid['isbn']=htmlentities(trim($POST['isbn']));
    }
    else {
    $inputError[]=’isbn’;
    }
    //validate price
    if(!empty($_POST['price']) && is_numeric($_POST['price']) && $_POST['price'] >0){
    $valid['price']=htmlentities(trim($_POST['price']));
    }else {
    $inputErrors[]=’price’;
    }
    }
    //if form not submitted
    //or if validation errors exist
    //redisplay form

    if(($submitted==true && count($inputErrors)>0)|| $submitted==false){

    ?>

    Title :
    <input type="text" size="25" name="title" value="”/>

    Author :
    <input type="text" size="25" name="author" value="”/>

    ISBN :
    <input type="text" size="25" name="isbn" value="”/>

    Price :
    <input type="text" size="25" name="price" value="”/>

    setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    }catch(PDOException $e){
    die(“ERROR: Could not connect:”.$e->getMessage());
    }
    //create and execute INSERT query
    try{
    $title=$pdo->quote($valid['title']);
    $author=$pdo->quote($valid['author']);
    $isbn=$pdo->quote($valid['isbn']);
    $price=$pdo->quote($valid['price']);
    $sql=”INSERT INTO books(title,author,isbn,price) VALUES($title,$author,$isbn,$price)”;
    $ret=$pdo->exec($sql);
    echo’SUCCESS:Record saved !’;
    } catch(Exception $e){
    echo’ERROR:’.$e->getMessage().”;
    }
    unset($pdo);
    }
    ?>

    Do you still think the code is missing ?

    • Hi jules,

      Your code is still missing end of if block, start of try-catch block and connection to SQLite3 database

      I decide to write PHP / PDO / SQLite3 example code to you… :)

      You can run it command line…it also shows howto to use prepared statements… :)

  29. i copied pasted the code on my bluefish then when i run the page , it said

    SQLSTATE[HY000] [14] unable to open database file
    Any idea on how to handle this please ! i am really tired of reinstalling php with no solution

    • Sounds permission problem. So if you save this file example with name sqlite-example.php to /tmp directory and run on command line with following command (you need php-cli package):

      cd /tmp
      php sqlite-example.php

      Is it working then?

  30. Yeah ! thanks JR ! it s working , but would u mind to help me if possible so as it can work in /var/www/html/sqlite-example.php?

    • Okay so code is working normally and your PHP / PDO / SQLite is working normally. It sounds definitely permission problem. Do php file with following content:

      <?php
        $fp = fopen('test.txt', 'w');
        fwrite($fp, 'test');
        fwrite($fp, ' test 2');
        fclose($fp);
      ?>

      Run it…do you get any errors? Or do you get test.txt file, with “test test 2″ content?

  31. yeah !
    it displays :
    Warning: fopen(test.txt): failed to open stream: Permission denied in /var/www/html/file.php on line 2 Warning: fwrite() expects parameter 1 to be resource, boolean given in /var/www/html/file.php on line 3 Warning: fwrite() expects parameter 1 to be resource, boolean given in /var/www/html/file.php on line 4 Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/html/file.php on line 5

    • So then try following as root (this is just test setup, no production use):

      mkdir /var/www/html/dbs
       
      chmod -R 775 /var/www/html/dbs
       
      chown -R apache:apache /var/www/html/dbs
       
      chcon -R -t httpd_sys_rw_content_t /var/www/html/

      Then modify your php code to following, (keep php code same location):

          // Create (connect to) SQLite database in file
          $file_db = new PDO('sqlite:dbs/messaging.sqlite3');    // Set errormode to exceptions
          $file_db->setAttribute(PDO::ATTR_ERRMODE, 
                                  PDO::ERRMODE_EXCEPTION);

      Try again…is it working then? :)

  32. Hi, thank you so much for posting this tutorial and helping people with this issue:

    I have MySQL 5.0 and I needed at least PHP 5.2, so I did this:

    $ yum –enablerepo=remi install php php-pdo php-xml php-pear php-mhash php-mcrypt php-gd

    And it all works fine with no errors. But I also need php-mysql, and it throws errors

    $ yum –enablerepo=remi install php-mysql

    So this results in errors because, I think, it depends on MySQL 5.5. So I try upgrading MySQL, like this:

    $ yum –enablerepo=remi update mysql-\*

    This is what it looks to update:

    Dependencies Resolved

    ================================================================================
    Package Arch Version Repository Size
    ================================================================================
    Updating:
    mysql x86_64 5.5.20-1.el5.remi remi 7.4 M
    mysql-devel x86_64 5.5.20-1.el5.remi remi 173 k
    mysql-server x86_64 5.5.20-1.el5.remi remi 13 M
    Installing for dependencies:
    mysql-libs x86_64 5.5.20-1.el5.remi remi 1.1 M
    mysqlclient15 x86_64 5.0.67-1.el5.remi remi 1.3 M

    Transaction Summary
    ================================================================================
    Install 2 Package(s)
    Upgrade 3 Package(s)

    Total size: 23 M

    And I get these errors:


    Transaction Check Error:
    file /usr/bin/mysql_find_rows from install of mysql-5.5.20-1.el5.remi.x86_64 c
    onflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/bin/mysqlaccess from install of mysql-5.5.20-1.el5.remi.x86_64 confl
    icts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/man/man1/my_print_defaults.1.gz from install of mysql-5.5.20-1
    .el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/man/man1/mysql.1.gz from install of mysql-5.5.20-1.el5.remi.x8
    6_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/man/man1/mysql_config.1.gz from install of mysql-5.5.20-1.el5.
    remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/man/man1/mysql_find_rows.1.gz from install of mysql-5.5.20-1.e
    l5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/man/man1/mysql_waitpid.1.gz from install of mysql-5.5.20-1.el5
    .remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/man/man1/mysqlaccess.1.gz from install of mysql-5.5.20-1.el5.r
    emi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/man/man1/mysqladmin.1.gz from install of mysql-5.5.20-1.el5.re
    mi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/man/man1/mysqldump.1.gz from install of mysql-5.5.20-1.el5.rem
    i.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/man/man1/mysqlshow.1.gz from install of mysql-5.5.20-1.el5.rem
    i.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /etc/my.cnf from install of mysql-libs-5.5.20-1.el5.remi.x86_64 conflicts
    with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/charsets/Index.xml from install of mysql-libs-5.5.20-1.e
    l5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/charsets/cp1250.xml from install of mysql-libs-5.5.20-1.
    el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/charsets/cp1251.xml from install of mysql-libs-5.5.20-1.
    el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/czech/errmsg.sys from install of mysql-libs-5.5.20-1.el5
    .remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/danish/errmsg.sys from install of mysql-libs-5.5.20-1.el
    5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/dutch/errmsg.sys from install of mysql-libs-5.5.20-1.el5
    .remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/english/errmsg.sys from install of mysql-libs-5.5.20-1.e
    l5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/estonian/errmsg.sys from install of mysql-libs-5.5.20-1.
    el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/french/errmsg.sys from install of mysql-libs-5.5.20-1.el
    5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/german/errmsg.sys from install of mysql-libs-5.5.20-1.el
    5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/greek/errmsg.sys from install of mysql-libs-5.5.20-1.el5
    .remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/hungarian/errmsg.sys from install of mysql-libs-5.5.20-1
    .el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/italian/errmsg.sys from install of mysql-libs-5.5.20-1.e
    l5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/japanese/errmsg.sys from install of mysql-libs-5.5.20-1.
    el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/korean/errmsg.sys from install of mysql-libs-5.5.20-1.el
    5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/norwegian-ny/errmsg.sys from install of mysql-libs-5.5.2
    0-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/norwegian/errmsg.sys from install of mysql-libs-5.5.20-1
    .el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/polish/errmsg.sys from install of mysql-libs-5.5.20-1.el
    5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/portuguese/errmsg.sys from install of mysql-libs-5.5.20-
    1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/romanian/errmsg.sys from install of mysql-libs-5.5.20-1.
    el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/russian/errmsg.sys from install of mysql-libs-5.5.20-1.e
    l5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/serbian/errmsg.sys from install of mysql-libs-5.5.20-1.e
    l5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/slovak/errmsg.sys from install of mysql-libs-5.5.20-1.el
    5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/spanish/errmsg.sys from install of mysql-libs-5.5.20-1.e
    l5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/swedish/errmsg.sys from install of mysql-libs-5.5.20-1.e
    l5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386
    file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-libs-5.5.20-1
    .el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_6.6.i386

    This seems to say that I have MySQL 5.0 i386 installed even though I’m on a 64-bit system, and remi wants to give me 64 bit.

    Do you have any idea what I should do?

    Thank you.

    • Hi Buttle Butkus,

      Could you post output of following commands:

      uname -a
       
      rpm -qa *mysql* |sort
  33. Hi JR ! thanks alot ! It worked
    Best Regards ,
    Jules

    • Hi jules,

      You are welcome! Nice to hear that you got it working… :)

  34. Hi, JR, thanks so much for your quick response. Perhaps you guessed what my problem is. But I fixed it before I saw your post. I thought checked this:

    $ rpm -qa | grep mysql

    But I guess I didn’t.

    Somehow, I had both the i386 and x86_64 packages for mysql installed.
    When I ran STATUS query it showed x86_64 in mysql. So I gave up and decided to remove mysql altogether and start over with remi’s install.

    When I ran:

    $ yum remove mysql\*

    All of a sudden it was asking me to confirm removal of packages that included both architectures.

    ================================================================================
    Package Arch Version Repository Size
    ================================================================================
    Removing:
    mysql i386 5.0.77-4.el5_6.6 installed 7.9 M
    mysql x86_64 5.0.77-4.el5_6.6 installed 8.1 M
    mysql-devel i386 5.0.77-4.el5_6.6 installed 5.6 M
    mysql-devel x86_64 5.0.77-4.el5_6.6 installed 6.3 M
    mysql-server x86_64 5.0.77-4.el5_6.6 installed 22 M
    Removing for dependencies:
    exim x86_64 4.63-10.el5 installed 3.4 M
    perl-DBD-MySQL x86_64 3.0007-2.el5 installed 328 k
    redhat-lsb i386 4.0-2.1.4.el5 installed 21 k
    redhat-lsb x86_64 4.0-2.1.4.el5 installed 22 k

    Then all I had to do was this:

    $ yum remove mysql.i386

    And it removed 2 packages (mysql.i386 and mysql-devel.i386). redhat-lsb.i386 is still there and I guess I should remove it too.

    After that, installation worked fine of MySQL 5.5 was fine. I just wonder if I really needed to do it in order to have PHP 5.3.9 including php-mysql. Oh well. Too late now. I am fully upgraded.

    • Yes, some reason you had both MySQL’s 32-bit and 64-bit installed, but removing wrong one is the solution… :)

      Excellent to hear that you got it working!

  35. I’m using Fedora 16, and SELinux raise a warning and block apache. What I did to solve this problem was to put SELinux y permisive mode only for http with the next line:

    sudo semanage permissive -a httpd_t

    I hope this helps somebody with the same or similar problem

    • By the way, credits to wzzrd for his comment

  36. Repositories:
    rpm -Uvh http://mirror.awanti.com/epel/5/i386/epel-release-5-4.noarch.rpm
    rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
    successfully connected.

    But then the installation comes to a standstill =(

    > yum –enablerepo=remi install mysql-server
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * atomic: www6.atomicorp.com
    * base: mirror.corbina.net
    * epel: mirror.yandex.ru
    * extras: mirror.corbina.net
    * ius: mirror.rackspace.co.uk
    * remi: remi-mirror.dedipower.com
    * updates: mirror.corbina.net
    Excluding Packages in global exclude list
    Finished
    Setting up Install Process
    No package mysql-server available.
    Nothing to do

    > yum –enablerepo=remi install httpd php php-common
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * atomic: www6.atomicorp.com
    * base: mirror.corbina.net
    * epel: mirror.yandex.ru
    * extras: mirror.corbina.net
    * ius: mirror.rackspace.co.uk
    * remi: remi-mirror.dedipower.com
    * updates: mirror.corbina.net
    Excluding Packages in global exclude list
    Finished
    Setting up Install Process
    No package httpd available.
    No package php available.
    No package php-common available.
    Nothing to do

    I would be glad of any help in solving the problem.

    The data on my system:
    CentOS Linux 5.7
    Apache version 2.2.8
    PHP 5.2.5 (cli) (built: Feb 6 2008 05:50:28)
    Zend Engine v2.2.0
    with Zend Extension Manager v1.2.0
    with Zend Optimizer v3.2.8

    • Hi Cyborg Atom,

      Could you post output of following command:

      yum repolist all
      • > yum repolist all
        Loaded plugins: fastestmirror
        Loading mirror speeds from cached hostfile
        * atomic: www6.atomicorp.com
        * base: mirror.corbina.net
        * epel: mirror.yandex.ru
        * extras: mirror.corbina.net
        * ius: mirrors.ircam.fr
        * rpmfusion-free-updates: mirror.yandex.ru
        * rpmfusion-free-updates-testing: mirror.yandex.ru
        * updates: mirror.corbina.net
        Excluding Packages in global exclude list
        Finished
        repo id repo name status
        C5.0-base CentOS-5.0 – Base disabled
        C5.0-centosplus CentOS-5.0 – Plus disabled
        C5.0-extras CentOS-5.0 – Extras disabled
        C5.0-updates CentOS-5.0 – Updates disabled
        C5.1-base CentOS-5.1 – Base disabled
        C5.1-centosplus CentOS-5.1 – Plus disabled
        C5.1-extras CentOS-5.1 – Extras disabled
        C5.1-updates CentOS-5.1 – Updates disabled
        C5.2-base CentOS-5.2 – Base disabled
        C5.2-centosplus CentOS-5.2 – Plus disabled
        C5.2-extras CentOS-5.2 – Extras disabled
        C5.2-updates CentOS-5.2 – Updates disabled
        C5.3-base CentOS-5.3 – Base disabled
        C5.3-centosplus CentOS-5.3 – Plus disabled
        C5.3-extras CentOS-5.3 – Extras disabled
        C5.3-updates CentOS-5.3 – Updates disabled
        C5.4-base CentOS-5.4 – Base disabled
        C5.4-centosplus CentOS-5.4 – Plus disabled
        C5.4-extras CentOS-5.4 – Extras disabled
        C5.4-updates CentOS-5.4 – Updates disabled
        C5.5-base CentOS-5.5 – Base disabled
        C5.5-centosplus CentOS-5.5 – Plus disabled
        C5.5-extras CentOS-5.5 – Extras disabled
        C5.5-updates CentOS-5.5 – Updates disabled
        C5.6-base CentOS-5.6 – Base disabled
        C5.6-centosplus CentOS-5.6 – Plus disabled
        C5.6-extras CentOS-5.6 – Extras disabled
        C5.6-updates CentOS-5.6 – Updates disabled
        addons CentOS-5 – Addons enabled: 0
        atomic CentOS / Red Hat Ente enabled: 730+300
        atomic-testing CentOS / Red Hat Ente disabled
        base CentOS-5 – Base enabled: 2618+87
        c5-media CentOS-5 – Media disabled
        centosplus CentOS-5 – Plus disabled
        contrib CentOS-5 – Contrib disabled
        debug CentOS-5 – Debuginfo disabled
        epel Extra Packages for En enabled: 5407+216
        epel-debuginfo Extra Packages for En disabled
        epel-source Extra Packages for En disabled
        epel-testing Extra Packages for En disabled
        epel-testing-debuginfo Extra Packages for En disabled
        epel-testing-source Extra Packages for En disabled
        extras CentOS-5 – Extras enabled: 276+23
        ius IUS Community Package enabled: 30+120
        ius-archive IUS Community Package disabled
        ius-archive-debuginfo IUS Community Package disabled
        ius-archive-source IUS Community Package disabled
        ius-debuginfo IUS Community Package disabled
        ius-dev IUS Community Package disabled
        ius-dev-debuginfo IUS Community Package disabled
        ius-dev-source IUS Community Package disabled
        ius-source IUS Community Package disabled
        ius-testing IUS Community Package disabled
        ius-testing-debuginfo IUS Community Package disabled
        ius-testing-source IUS Community Package disabled
        remi Les RPM de remi pour disabled
        remi-test Les RPM de remi en te disabled
        rpmfusion-free-updates RPM Fusion for EL 5 – enabled: 1
        rpmfusion-free-updates-debuginfo RPM Fusion for EL 5 – disabled
        rpmfusion-free-updates-source RPM Fusion for EL 5 – disabled
        rpmfusion-free-updates-testing RPM Fusion for EL 5 – enabled: 93
        rpmfusion-free-updates-testing-debuginfo RPM Fusion for EL 5 – disabled
        rpmfusion-free-updates-testing-source RPM Fusion for EL 5 – disabled
        updates CentOS-5 – Updates enabled: 452+132
        webtatic Webtatic Repository 5 disabled
        webtatic-debuginfo Webtatic Repository 5 disabled
        webtatic-source Webtatic Repository 5 disabled
        repolist: 9607

        • Could you post also output of following command:

          yum --enablerepo=remi list mysql mysql-server httpd php php-common
          • > yum –enablerepo=remi list mysql mysql-server httpd php php-common
            Loaded plugins: fastestmirror
            Loading mirror speeds from cached hostfile
            * atomic: www6.atomicorp.com
            * base: mirror.corbina.net
            * epel: mirror.xfes.ru
            * extras: mirror.corbina.net
            * ius: mirror.rackspace.co.uk
            * remi: rpms.famillecollet.com
            * rpmfusion-free-updates: mirror.yandex.ru
            * rpmfusion-free-updates-testing: mirror.yandex.ru
            * updates: mirror.corbina.net
            Excluding Packages in global exclude list
            Finished
            Installed Packages
            mysql.i386 5.0.77-4.el5_6.6 installed

            • Could you post output of following command:

              grep exclude /etc/yum.repos.d/* /etc/yum.conf
              • > grep exclude /etc/yum.repos.d/* /etc/yum.conf
                /etc/yum.conf:exclude=apache* httpd* mod_* mysql* MySQL* da_* *ftp* exim* sendmail* php* bind* bind-chroot*

                O_o The packs were not allowed to update. Is this true?

                • Yes, this exclude row exclude all updates and installs where package name match pattern, so if you remove / comment out exclude row, then you can update / install those packages. :)

                  One question, before you remove exclude row, do you know the reason why those packages are excluded on /etc/yum.conf?

                  • In general, don `t know.
                    It was a standard setup of my VPS server.

                    • Oh, I see :) If you want (are allowed) to install / update those packages then you have to remove that exclude line.

  37. Hello,
    Iam currently trying to develop and manage a website using fedora 16. However, I am very tired of not being allowed access to certain folders and drives(usually easily correctable in other OS’s). For instance, when I try to create the /var/www/html/test.php it says i dont have permission even though I am in terminal as [root@localhost root]. How do I troubleshoot this issue and make it so I am able to create the php file?

  38. Also, I just switched over from windows two days ago so I am installing all the necessary programs to develop and interact with db’s.

  39. Hi Jared77,

    Welcome to Linux user and yes, everything is relative, and fixing permissions under Linux is much easier and faster than under Windows, but of course, you need to know what to do and get used to it. :)

    If you try create file as root user, then you should be able to create file even if the permissions are wrong. So could you tell, how you try to create a file as root? What program / command you used?

    Then could you post output of following commands:

    ls -la /var/www
     
    ls -la /var/www/html
  40. Thanks for the tutorial!

    Do you have plans to include PHP 5.4?

    • Hi Ramy!

      You are welcome!

      Yes I have plans to update this guide also include PHP 5.4… :)

  41. Hi JR,
    first I like to give my congratulations to you for this helping site! Thank you very much for sharing your knowledge. (Aspecially helpfull for people like me, which are only working some hours a year on topics like this)

    I´m running CentOS-5 and have to update to php53, which worked fine using your infos above. – But as a result I´m now not able to start mysqld.
    Do have have any suggestions for me?

    Thank you very much in advance.

    Kind regards,
    GG

    • Hi GG,

      Thanks and you are welcome! :)

      What version of MySQL are you trying to run? Do you get any errors when you try to start it?

  42. Hey,

    Thanks for this lovely thread, I followed every step. works perfect, and I can view the php page we created.

    However, when I try to access my ip through another computer on the same network, it doesn’t work, I get a connection has time out error.

    any idea why this may be ?

    Thanks in advance.

  43. I think I know what the problem is, but I’m not quite sure how to solve it:

    Both the laptop ( which has the apache installed on it ) using wifi internet connection, and the desktop, which is wired to the internet, use the same ip address.
    as my internet provider gives me a static ip address.
    having said that, I suspect that I won’t be able to access the test.php from the desktop, unless I use a proxy.
    is that right ? if yes, I tried using an online proxy , but still I couldn’t view the page.

    Thanks again.

    • Hi Appaloosa,

      Did you open port 80 from firewall?

      • Hello,

        well, not sure how to do that, Im following this pdf file:

        http://www.smc.com/files/AJ/SMCD3GN-UserManual_Rogers.pdf

        I followed the port forwarding example on page 64. But that didn’t help much. Can u you look at it and tell me what else I need to do ?

        Now your question:
        I have no idea how to let the open port 80 on the firewall. ?

        Also, what should I have for my Listen directive in httpd.conf ?

        can u give me some guidance ?

        Thanks :)

        • sorry, I forgot to mention that the following fails on me

          service iptables restart
          Redirecting to /bin/systemctl restart iptables.service
          Job failed. See system logs and ‘systemctl status’ for details.

          oooppps.

          • Update :

            I fixed the iptable issue, still can’t access the local host using ip address.
            I had the port statment in iptables after COMMIT, not before :)

            now I get this :

            # service iptables restart
            Redirecting to /bin/systemctl restart iptables.service

            /etc/init.d/iptables restart
            bash: /etc/init.d/iptables: No such file or directory

            Im off for the night, I’ll come back tomorrow, crossing my fingers that tomorrow I’ll get it to work. can’t wait to be able to access it from anywehre.

            • Actually you have to have it before commit, like:

              ...
              -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
              -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited
              -A FORWARD -j REJECT --reject-with icmp-host-prohibited
              COMMIT
              • yeah I have it like that…still same problem. !?

                • Could you restart iptables without any errors?

                  • I do have errors:

                    When I run :

                    $>service iptables restart
                    Redirecting to /bin/systemctl restart iptables.service

                    When I run :

                    /etc/init.d/iptables restart
                    bash: /etc/init.d/iptables: No such file or directory

                    so , it says file does not exist :S

                    • Hi Appaloosa,

                      Could you please post output of following command:

                      iptables -L
  44. [root@localhost appaloosa]# iptables -L
    Chain INPUT (policy ACCEPT)
    target prot opt source destination
    ACCEPT all — anywhere anywhere state RELATED,ESTABLISHED
    ACCEPT icmp — anywhere anywhere
    ACCEPT all — anywhere anywhere
    ACCEPT tcp — anywhere anywhere state NEW tcp dpt:http mark match 0×64
    ACCEPT tcp — anywhere anywhere state NEW tcp dpt:ssh
    ACCEPT tcp — anywhere anywhere state NEW tcp dpt:http
    REJECT all — anywhere anywhere reject-with icmp-host-prohibited

    Chain FORWARD (policy ACCEPT)
    target prot opt source destination
    REJECT all — anywhere anywhere reject-with icmp-host-prohibited

    Chain OUTPUT (policy ACCEPT)
    target prot opt source destination
    [root@localhost appaloosa]#

    [root@localhost appaloosa]#

    • Hi Appaloosa,

      Looks like your http port is open and it should work now.

      So make sure that you have httpd server running and try to connect again to your computer ip address with web browser…what happens then?

      • which ip address ? my gateway one ? or the LAN one ?

        • Your computer ip where server is running, you can check ip(s) with ifconfig command. If you connect from local network then you can use LAN ip address and if you connect from Internet, then use public ip.

          • are you saying that if I use public ip within the LAN it won’t work ?

            Because thats what Im trying to do here, the LAN ip works, the public ip does not work within the LAN.

            In other words, 192.168.0.64 ( my LAN ip ), works..I can view the site.

            If I use my public ip, ( from the same machine apache installed on ), it does not work.

            • So do you have public ip and LAN ip on your computer? If yes then both should work.

              Are you absolutely sure that your computer / LAN is not behind NAT (or some other firewall setup) and you have real public ip directly on your computer?

              • my computer is behind a NAT ( my gateway’s firewall ).
                I did already configure that firewall to forward requests to my LAN ip.

                I give up…

                Thanks anyways JR :)

                • Okay, you are welcome!

                  I think that the problem should be on firewall configuration, because your web server is working from LAN… :)

  45. Thanks!I gave this a try on a CentOS 6.2 box. Worked flawlessly.

    Thanks!

    Bob

    • Did you need to configure anything on your router ? or iptables on your centos 6.2 box ?

      Im really considering your offer, Im downloading centos right now, can u give me some more info ?

  46. help !!!!
    i have this message when i run ‘systemctl status httpd.service’ in terminal

    httpd.service – The Apache HTTP Server (prefork MPM)
    Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
    Active: failed (Result: exit-code) since Thu, 07 Jun 2012 13:30:47 +0200; 3min 13s ago
    Process: 4165 ExecStart=/usr/sbin/httpd $OPTIONS -k start (code=exited, status=1/FAILURE)
    CGroup: name=systemd:/system/httpd.service

    Jun 07 13:30:47 localhost.localdomain httpd[4165]: [Thu Jun 07 13:30:47 2012] [crit] (2)No such …’.
    Jun 07 13:30:47 localhost.localdomain httpd[4165]: httpd: Could not reliably determine the serve…me
    Jun 07 13:30:47 localhost.localdomain httpd[4165]: (98)Address already in use: make_sock: could …43
    Jun 07 13:30:47 localhost.localdomain httpd[4165]: no listening sockets available, shutting down
    Jun 07 13:30:47 localhost.localdomain httpd[4165]: Unable to open logs

  47. Thanks for PHP 5.4!

  48. Any news about Apache 2.4 integration?

    • Hi Ramy,

      Not any significant news yet, I found some Fedora 18 builds here. Of course it is possible compile all packages manually…

  49. Kindly help me solve this problem

    # /etc/init.d/httpd start
    Starting httpd: Syntax error on line 1010 of /etc/httpd/conf/httpd.conf:
    Invalid command ‘localhost’, perhaps misspelled or defined by a module not included in the server configuration
    [FAILED]
    # service httpd start
    Starting httpd: Syntax error on line 1010 of /etc/httpd/conf/httpd.conf:
    Invalid command ‘localhost’, perhaps misspelled or defined by a module not included in the server configuration
    [FAILED]

    • Hi Venkata,

      Could you post your /etc/httpd/conf/httpd.conf file content to http://pastebin.com ?

      • Hello JR,
        I have posted the contents of the file httpd.conf.
        Please find the same here too:

        #
        # This is the main Apache server configuration file.  It contains the
        # configuration directives that give the server its instructions.
        # See  for detailed information.
        # In particular, see
        # 
        # for a discussion of each configuration directive.
        #
        #
        # Do NOT simply read the instructions in here without understanding
        # what they do.  They're here only as hints or reminders.  If you are unsure
        # consult the online docs. You have been warned.  
        #
        # The configuration directives are grouped into three basic sections:
        #  1. Directives that control the operation of the Apache server process as a
        #     whole (the 'global environment').
        #  2. Directives that define the parameters of the 'main' or 'default' server,
        #     which responds to requests that aren't handled by a virtual host.
        #     These directives also provide default values for the settings
        #     of all virtual hosts.
        #  3. Settings for virtual hosts, which allow Web requests to be sent to
        #     different IP addresses or hostnames and have them handled by the
        #     same Apache server process.
        #
        # Configuration and logfile names: If the filenames you specify for many
        # of the server's control files begin with "/" (or "drive:/" for Win32), the
        # server will use that explicit path.  If the filenames do *not* begin
        # with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
        # with ServerRoot set to "/etc/httpd" will be interpreted by the
        # server as "/etc/httpd/logs/foo.log".
        #
         
        ### Section 1: Global Environment
        #
        # The directives in this section affect the overall operation of Apache,
        # such as the number of concurrent requests it can handle or where it
        # can find its configuration files.
        #
         
        #
        # Don't give away too much information about all the subcomponents
        # we are running.  Comment out this line if you don't mind remote sites
        # finding out what major optional modules you are running
        ServerTokens OS
         
        #
        # ServerRoot: The top of the directory tree under which the server's
        # configuration, error, and log files are kept.
        #
        # NOTE!  If you intend to place this on an NFS (or otherwise network)
        # mounted filesystem then please read the LockFile documentation
        # (available at );
        # you will save yourself a lot of trouble.
        #
        # Do NOT add a slash at the end of the directory path.
        #
        ServerRoot "/etc/httpd"
         
        #
        # PidFile: The file in which the server should record its process
        # identification number when it starts.  Note the PIDFILE variable in
        # /etc/sysconfig/httpd must be set appropriately if this location is
        # changed.
        #
        PidFile run/httpd.pid
         
        #
        # Timeout: The number of seconds before receives and sends time out.
        #
        Timeout 60
         
        #
        # KeepAlive: Whether or not to allow persistent connections (more than
        # one request per connection). Set to "Off" to deactivate.
        #
        KeepAlive Off
         
        #
        # MaxKeepAliveRequests: The maximum number of requests to allow
        # during a persistent connection. Set to 0 to allow an unlimited amount.
        # We recommend you leave this number high, for maximum performance.
        #
        MaxKeepAliveRequests 100
         
        #
        # KeepAliveTimeout: Number of seconds to wait for the next request from the
        # same client on the same connection.
        #
        KeepAliveTimeout 15
         
        ##
        ## Server-Pool Size Regulation (MPM specific)
        ## 
         
        # prefork MPM
        # StartServers: number of server processes to start
        # MinSpareServers: minimum number of server processes which are kept spare
        # MaxSpareServers: maximum number of server processes which are kept spare
        # ServerLimit: maximum value for MaxClients for the lifetime of the server
        # MaxClients: maximum number of server processes allowed to start
        # MaxRequestsPerChild: maximum number of requests a server process serves
         
        StartServers       8
        MinSpareServers    5
        MaxSpareServers   20
        ServerLimit      256
        MaxClients       256
        MaxRequestsPerChild  4000
         
         
        # worker MPM
        # StartServers: initial number of server processes to start
        # MaxClients: maximum number of simultaneous client connections
        # MinSpareThreads: minimum number of worker threads which are kept spare
        # MaxSpareThreads: maximum number of worker threads which are kept spare
        # ThreadsPerChild: constant number of worker threads in each server process
        # MaxRequestsPerChild: maximum number of requests a server process serves
         
        StartServers         4
        MaxClients         300
        MinSpareThreads     25
        MaxSpareThreads     75 
        ThreadsPerChild     25
        MaxRequestsPerChild  0
         
         
        #
        # Listen: Allows you to bind Apache to specific IP addresses and/or
        # ports, in addition to the default. See also the 
        # directive.
        #
        # Change this to Listen on specific IP addresses as shown below to 
        # prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
        #
        #Listen 12.34.56.78:80
        Listen 80
         
        #
        # Dynamic Shared Object (DSO) Support
        #
        # To be able to use the functionality of a module which was built as a DSO you
        # have to place corresponding `LoadModule' lines at this location so the
        # directives contained in it are actually available _before_ they are used.
        # Statically compiled modules (those listed by `httpd -l') do not need
        # to be loaded here.
        #
        # Example:
        # LoadModule foo_module modules/mod_foo.so
        #
        LoadModule auth_basic_module modules/mod_auth_basic.so
        LoadModule auth_digest_module modules/mod_auth_digest.so
        LoadModule authn_file_module modules/mod_authn_file.so
        LoadModule authn_alias_module modules/mod_authn_alias.so
        LoadModule authn_anon_module modules/mod_authn_anon.so
        LoadModule authn_dbm_module modules/mod_authn_dbm.so
        LoadModule authn_default_module modules/mod_authn_default.so
        LoadModule authz_host_module modules/mod_authz_host.so
        LoadModule authz_user_module modules/mod_authz_user.so
        LoadModule authz_owner_module modules/mod_authz_owner.so
        LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
        LoadModule authz_dbm_module modules/mod_authz_dbm.so
        LoadModule authz_default_module modules/mod_authz_default.so
        LoadModule ldap_module modules/mod_ldap.so
        LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
        LoadModule include_module modules/mod_include.so
        LoadModule log_config_module modules/mod_log_config.so
        LoadModule logio_module modules/mod_logio.so
        LoadModule env_module modules/mod_env.so
        LoadModule ext_filter_module modules/mod_ext_filter.so
        LoadModule mime_magic_module modules/mod_mime_magic.so
        LoadModule expires_module modules/mod_expires.so
        LoadModule deflate_module modules/mod_deflate.so
        LoadModule headers_module modules/mod_headers.so
        LoadModule usertrack_module modules/mod_usertrack.so
        LoadModule setenvif_module modules/mod_setenvif.so
        LoadModule mime_module modules/mod_mime.so
        LoadModule dav_module modules/mod_dav.so
        LoadModule status_module modules/mod_status.so
        LoadModule autoindex_module modules/mod_autoindex.so
        LoadModule info_module modules/mod_info.so
        LoadModule dav_fs_module modules/mod_dav_fs.so
        LoadModule vhost_alias_module modules/mod_vhost_alias.so
        LoadModule negotiation_module modules/mod_negotiation.so
        LoadModule dir_module modules/mod_dir.so
        LoadModule actions_module modules/mod_actions.so
        LoadModule speling_module modules/mod_speling.so
        LoadModule userdir_module modules/mod_userdir.so
        LoadModule alias_module modules/mod_alias.so
        LoadModule substitute_module modules/mod_substitute.so
        LoadModule rewrite_module modules/mod_rewrite.so
        LoadModule proxy_module modules/mod_proxy.so
        LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
        LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
        LoadModule proxy_http_module modules/mod_proxy_http.so
        LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
        LoadModule proxy_connect_module modules/mod_proxy_connect.so
        LoadModule cache_module modules/mod_cache.so
        LoadModule suexec_module modules/mod_suexec.so
        LoadModule disk_cache_module modules/mod_disk_cache.so
        LoadModule cgi_module modules/mod_cgi.so
        LoadModule version_module modules/mod_version.so
         
        #
        # The following modules are not loaded by default:
        #
        #LoadModule asis_module modules/mod_asis.so
        #LoadModule authn_dbd_module modules/mod_authn_dbd.so
        #LoadModule cern_meta_module modules/mod_cern_meta.so
        #LoadModule cgid_module modules/mod_cgid.so
        #LoadModule dbd_module modules/mod_dbd.so
        #LoadModule dumpio_module modules/mod_dumpio.so
        #LoadModule filter_module modules/mod_filter.so
        #LoadModule ident_module modules/mod_ident.so
        #LoadModule log_forensic_module modules/mod_log_forensic.so
        #LoadModule unique_id_module modules/mod_unique_id.so
        #
         
        #
        # Load config files from the config directory "/etc/httpd/conf.d".
        #
        Include conf.d/*.conf
         
        #
        # ExtendedStatus controls whether Apache will generate "full" status
        # information (ExtendedStatus On) or just basic information (ExtendedStatus
        # Off) when the "server-status" handler is called. The default is Off.
        #
        #ExtendedStatus On
         
        #
        # If you wish httpd to run as a different user or group, you must run
        # httpd as root initially and it will switch.  
        #
        # User/Group: The name (or #number) of the user/group to run httpd as.
        #  . On SCO (ODT 3) use "User nouser" and "Group nogroup".
        #  . On HPUX you may not be able to use shared memory as nobody, and the
        #    suggested workaround is to create a user www and use that user.
        #  NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET)
        #  when the value of (unsigned)Group is above 60000; 
        #  don't use Group #-1 on these systems!
        #
        User apache
        Group apache
         
        ### Section 2: 'Main' server configuration
        #
        # The directives in this section set up the values used by the 'main'
        # server, which responds to any requests that aren't handled by a
        #  definition.  These values also provide defaults for
        # any  containers you may define later in the file.
        #
        # All of these directives may appear inside  containers,
        # in which case these default settings will be overridden for the
        # virtual host being defined.
        #
         
        #
        # ServerAdmin: Your address, where problems with the server should be
        # e-mailed.  This address appears on some server-generated pages, such
        # as error documents.  e.g. [email protected]
        #
        ServerAdmin root@localhost
         
        #
        # ServerName gives the name and port that the server uses to identify itself.
        # This can often be determined automatically, but we recommend you specify
        # it explicitly to prevent problems during startup.
        #
        # If this is not set to valid DNS name for your host, server-generated
        # redirections will not work.  See also the UseCanonicalName directive.
        #
        # If your host doesn't have a registered DNS name, enter its IP address here.
        # You will have to access it by its address anyway, and this will make 
        # redirections work in a sensible way.
        #
        #ServerName www.example.com:80
         
        #
        # UseCanonicalName: Determines how Apache constructs self-referencing 
        # URLs and the SERVER_NAME and SERVER_PORT variables.
        # When set "Off", Apache will use the Hostname and Port supplied
        # by the client.  When set "On", Apache will use the value of the
        # ServerName directive.
        #
        UseCanonicalName Off
         
        #
        # DocumentRoot: The directory out of which you will serve your
        # documents. By default, all requests are taken from this directory, but
        # symbolic links and aliases may be used to point to other locations.
        #
        DocumentRoot "/var/www/html"
         
        #
        # Each directory to which Apache has access can be configured with respect
        # to which services and features are allowed and/or disabled in that
        # directory (and its subdirectories). 
        #
        # First, we configure the "default" to be a very restrictive set of 
        # features.  
        #
         
            Options FollowSymLinks
            AllowOverride None
         
         
        #
        # Note that from this point forward you must specifically allow
        # particular features to be enabled - so if something's not working as
        # you might expect, make sure that you have specifically enabled it
        # below.
        #
         
        #
        # This should be changed to whatever you set DocumentRoot to.
        #
         
         
        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.2/mod/core.html#options
        # for more information.
        #
            Options Indexes FollowSymLinks
         
        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   Options FileInfo AuthConfig Limit
        #
            AllowOverride None
         
        #
        # Controls who can get stuff from this server.
        #
            Order allow,deny
            Allow from all
         
         
         
        #
        # UserDir: The name of the directory that is appended onto a user's home
        # directory if a ~user request is received.
        #
        # The path to the end user account 'public_html' directory must be
        # accessible to the webserver userid.  This usually means that ~userid
        # must have permissions of 711, ~userid/public_html must have permissions
        # of 755, and documents contained therein must be world-readable.
        # Otherwise, the client will only receive a "403 Forbidden" message.
        #
        # See also: http://httpd.apache.org/docs/misc/FAQ.html#forbidden
        #
         
            #
            # UserDir is disabled by default since it can confirm the presence
            # of a username on the system (depending on home directory
            # permissions).
            #
            UserDir disabled
         
            #
            # To enable requests to /~user/ to serve the user's public_html
            # directory, remove the "UserDir disabled" line above, and uncomment
            # the following line instead:
            # 
            #UserDir public_html
         
         
         
        #
        # Control access to UserDir directories.  The following is an example
        # for a site where these directories are restricted to read-only.
        #
        #
        #    AllowOverride FileInfo AuthConfig Limit
        #    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
        #    
        #        Order allow,deny
        #        Allow from all
        #    
        #    
        #        Order deny,allow
        #        Deny from all
        #    
        #
         
        #
        # DirectoryIndex: sets the file that Apache will serve if a directory
        # is requested.
        #
        # The index.html.var file (a type-map) is used to deliver content-
        # negotiated documents.  The MultiViews Option can be used for the 
        # same purpose, but it is much slower.
        #
        DirectoryIndex index.html index.html.var
         
        #
        # AccessFileName: The name of the file to look for in each directory
        # for additional configuration directives.  See also the AllowOverride
        # directive.
        #
        AccessFileName .htaccess
         
        #
        # The following lines prevent .htaccess and .htpasswd files from being 
        # viewed by Web clients. 
        #
         
            Order allow,deny
            Deny from all
            Satisfy All
         
         
        #
        # TypesConfig describes where the mime.types file (or equivalent) is
        # to be found.
        #
        TypesConfig /etc/mime.types
         
        #
        # DefaultType is the default MIME type the server will use for a document
        # if it cannot otherwise determine one, such as from filename extensions.
        # If your server contains mostly text or HTML documents, "text/plain" is
        # a good value.  If most of your content is binary, such as applications
        # or images, you may want to use "application/octet-stream" instead to
        # keep browsers from trying to display binary files as though they are
        # text.
        #
        DefaultType text/plain
         
        #
        # The mod_mime_magic module allows the server to use various hints from the
        # contents of the file itself to determine its type.  The MIMEMagicFile
        # directive tells the module where the hint definitions are located.
        #
         
        #   MIMEMagicFile /usr/share/magic.mime
            MIMEMagicFile conf/magic
         
         
        #
        # HostnameLookups: Log the names of clients or just their IP addresses
        # e.g., www.apache.org (on) or 204.62.129.132 (off).
        # The default is off because it'd be overall better for the net if people
        # had to knowingly turn this feature on, since enabling it means that
        # each client request will result in AT LEAST one lookup request to the
        # nameserver.
        #
        HostnameLookups Off
         
        #
        # EnableMMAP: Control whether memory-mapping is used to deliver
        # files (assuming that the underlying OS supports it).
        # The default is on; turn this off if you serve from NFS-mounted 
        # filesystems.  On some systems, turning it off (regardless of
        # filesystem) can improve performance; for details, please see
        # http://httpd.apache.org/docs/2.2/mod/core.html#enablemmap
        #
        #EnableMMAP off
         
        #
        # EnableSendfile: Control whether the sendfile kernel support is 
        # used to deliver files (assuming that the OS supports it). 
        # The default is on; turn this off if you serve from NFS-mounted 
        # filesystems.  Please see
        # http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile
        #
        #EnableSendfile off
         
        #
        # ErrorLog: The location of the error log file.
        # If you do not specify an ErrorLog directive within a 
        # container, error messages relating to that virtual host will be
        # logged here.  If you *do* define an error logfile for a 
        # container, that host's errors will be logged there and not here.
        #
        ErrorLog logs/error_log
         
        #
        # LogLevel: Control the number of messages logged to the error_log.
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        #
        LogLevel warn
         
        #
        # The following directives define some format nicknames for use with
        # a CustomLog directive (see below).
        #
        LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
        LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common
        LogFormat "%{Referer}i -&gt; %U" referer
        LogFormat "%{User-agent}i" agent
         
        # "combinedio" includes actual counts of actual bytes received (%I) and sent (%O); this
        # requires the mod_logio module to be loaded.
        #LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
         
        #
        # The location and format of the access logfile (Common Logfile Format).
        # If you do not define any access logfiles within a 
        # container, they will be logged here.  Contrariwise, if you *do*
        # define per- access logfiles, transactions will be
        # logged therein and *not* in this file.
        #
        #CustomLog logs/access_log common
         
        #
        # If you would like to have separate agent and referer logfiles, uncomment
        # the following directives.
        #
        #CustomLog logs/referer_log referer
        #CustomLog logs/agent_log agent
         
        #
        # For a single logfile with access, agent, and referer information
        # (Combined Logfile Format), use the following directive:
        #
        CustomLog logs/access_log combined
         
        #
        # Optionally add a line containing the server version and virtual host
        # name to server-generated pages (internal error documents, FTP directory
        # listings, mod_status and mod_info output etc., but not CGI generated
        # documents or custom error documents).
        # Set to "EMail" to also include a mailto: link to the ServerAdmin.
        # Set to one of:  On | Off | EMail
        #
        ServerSignature On
         
        #
        # Aliases: Add here as many aliases as you need (with no limit). The format is 
        # Alias fakename realname
        #
        # Note that if you include a trailing / on fakename then the server will
        # require it to be present in the URL.  So "/icons" isn't aliased in this
        # example, only "/icons/".  If the fakename is slash-terminated, then the 
        # realname must also be slash terminated, and if the fakename omits the 
        # trailing slash, the realname must also omit it.
        #
        # We include the /icons/ alias for FancyIndexed directory listings.  If you
        # do not use FancyIndexing, you may comment this out.
        #
        Alias /icons/ "/var/www/icons/"
         
         
            Options Indexes MultiViews FollowSymLinks
            AllowOverride None
            Order allow,deny
            Allow from all
         
         
        #
        # WebDAV module configuration section.
        # 
         
            # Location of the WebDAV lock database.
            DAVLockDB /var/lib/dav/lockdb
         
         
        #
        # ScriptAlias: This controls which directories contain server scripts.
        # ScriptAliases are essentially the same as Aliases, except that
        # documents in the realname directory are treated as applications and
        # run by the server when requested rather than as documents sent to the client.
        # The same rules about trailing "/" apply to ScriptAlias directives as to
        # Alias.
        #
        ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
         
        #
        # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
        # CGI directory exists, if you have that configured.
        #
         
            AllowOverride None
            Options None
            Order allow,deny
            Allow from all
         
         
        #
        # Redirect allows you to tell clients about documents which used to exist in
        # your server's namespace, but do not anymore. This allows you to tell the
        # clients where to look for the relocated document.
        # Example:
        # Redirect permanent /foo http://www.example.com/bar
         
        #
        # Directives controlling the display of server-generated directory listings.
        #
         
        #
        # IndexOptions: Controls the appearance of server-generated directory
        # listings.
        #
        IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable Charset=UTF-8
         
        #
        # AddIcon* directives tell the server which icon to show for different
        # files or filename extensions.  These are only displayed for
        # FancyIndexed directories.
        #
        AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
         
        AddIconByType (TXT,/icons/text.gif) text/*
        AddIconByType (IMG,/icons/image2.gif) image/*
        AddIconByType (SND,/icons/sound2.gif) audio/*
        AddIconByType (VID,/icons/movie.gif) video/*
         
        AddIcon /icons/binary.gif .bin .exe
        AddIcon /icons/binhex.gif .hqx
        AddIcon /icons/tar.gif .tar
        AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
        AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
        AddIcon /icons/a.gif .ps .ai .eps
        AddIcon /icons/layout.gif .html .shtml .htm .pdf
        AddIcon /icons/text.gif .txt
        AddIcon /icons/c.gif .c
        AddIcon /icons/p.gif .pl .py
        AddIcon /icons/f.gif .for
        AddIcon /icons/dvi.gif .dvi
        AddIcon /icons/uuencoded.gif .uu
        AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
        AddIcon /icons/tex.gif .tex
        AddIcon /icons/bomb.gif core
         
        AddIcon /icons/back.gif ..
        AddIcon /icons/hand.right.gif README
        AddIcon /icons/folder.gif ^^DIRECTORY^^
        AddIcon /icons/blank.gif ^^BLANKICON^^
         
        #
        # DefaultIcon is which icon to show for files which do not have an icon
        # explicitly set.
        #
        DefaultIcon /icons/unknown.gif
         
        #
        # AddDescription allows you to place a short description after a file in
        # server-generated indexes.  These are only displayed for FancyIndexed
        # directories.
        # Format: AddDescription "description" filename
        #
        #AddDescription "GZIP compressed document" .gz
        #AddDescription "tar archive" .tar
        #AddDescription "GZIP compressed tar archive" .tgz
         
        #
        # ReadmeName is the name of the README file the server will look for by
        # default, and append to directory listings.
        #
        # HeaderName is the name of a file which should be prepended to
        # directory indexes. 
        ReadmeName README.html
        HeaderName HEADER.html
         
        #
        # IndexIgnore is a set of filenames which directory indexing should ignore
        # and not include in the listing.  Shell-style wildcarding is permitted.
        #
        IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
         
        #
        # DefaultLanguage and AddLanguage allows you to specify the language of 
        # a document. You can then use content negotiation to give a browser a 
        # file in a language the user can understand.
        #
        # Specify a default language. This means that all data
        # going out without a specific language tag (see below) will 
        # be marked with this one. You probably do NOT want to set
        # this unless you are sure it is correct for all cases.
        #
        # * It is generally better to not mark a page as 
        # * being a certain language than marking it with the wrong
        # * language!
        #
        # DefaultLanguage nl
        #
        # Note 1: The suffix does not have to be the same as the language
        # keyword --- those with documents in Polish (whose net-standard
        # language code is pl) may wish to use "AddLanguage pl .po" to
        # avoid the ambiguity with the common suffix for perl scripts.
        #
        # Note 2: The example entries below illustrate that in some cases 
        # the two character 'Language' abbreviation is not identical to 
        # the two character 'Country' code for its country,
        # E.g. 'Danmark/dk' versus 'Danish/da'.
        #
        # Note 3: In the case of 'ltz' we violate the RFC by using a three char
        # specifier. There is 'work in progress' to fix this and get
        # the reference data for rfc1766 cleaned up.
        #
        # Catalan (ca) - Croatian (hr) - Czech (cs) - Danish (da) - Dutch (nl)
        # English (en) - Esperanto (eo) - Estonian (et) - French (fr) - German (de)
        # Greek-Modern (el) - Hebrew (he) - Italian (it) - Japanese (ja)
        # Korean (ko) - Luxembourgeois* (ltz) - Norwegian Nynorsk (nn)
        # Norwegian (no) - Polish (pl) - Portugese (pt)
        # Brazilian Portuguese (pt-BR) - Russian (ru) - Swedish (sv)
        # Simplified Chinese (zh-CN) - Spanish (es) - Traditional Chinese (zh-TW)
        #
        AddLanguage ca .ca
        AddLanguage cs .cz .cs
        AddLanguage da .dk
        AddLanguage de .de
        AddLanguage el .el
        AddLanguage en .en
        AddLanguage eo .eo
        AddLanguage es .es
        AddLanguage et .et
        AddLanguage fr .fr
        AddLanguage he .he
        AddLanguage hr .hr
        AddLanguage it .it
        AddLanguage ja .ja
        AddLanguage ko .ko
        AddLanguage ltz .ltz
        AddLanguage nl .nl
        AddLanguage nn .nn
        AddLanguage no .no
        AddLanguage pl .po
        AddLanguage pt .pt
        AddLanguage pt-BR .pt-br
        AddLanguage ru .ru
        AddLanguage sv .sv
        AddLanguage zh-CN .zh-cn
        AddLanguage zh-TW .zh-tw
         
        #
        # LanguagePriority allows you to give precedence to some languages
        # in case of a tie during content negotiation.
        #
        # Just list the languages in decreasing order of preference. We have
        # more or less alphabetized them here. You probably want to change this.
        #
        LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
         
        #
        # ForceLanguagePriority allows you to serve a result page rather than
        # MULTIPLE CHOICES (Prefer) [in case of a tie] or NOT ACCEPTABLE (Fallback)
        # [in case no accepted languages matched the available variants]
        #
        ForceLanguagePriority Prefer Fallback
         
        #
        # Specify a default charset for all content served; this enables
        # interpretation of all content as UTF-8 by default.  To use the 
        # default browser choice (ISO-8859-1), or to allow the META tags
        # in HTML content to override this choice, comment out this
        # directive:
        #
        AddDefaultCharset UTF-8
         
        #
        # AddType allows you to add to or override the MIME configuration
        # file mime.types for specific file types.
        #
        #AddType application/x-tar .tgz
         
        #
        # AddEncoding allows you to have certain browsers uncompress
        # information on the fly. Note: Not all browsers support this.
        # Despite the name similarity, the following Add* directives have nothing
        # to do with the FancyIndexing customization directives above.
        #
        #AddEncoding x-compress .Z
        #AddEncoding x-gzip .gz .tgz
         
        # If the AddEncoding directives above are commented-out, then you
        # probably should define those extensions to indicate media types:
        #
        AddType application/x-compress .Z
        AddType application/x-gzip .gz .tgz
         
        #
        #   MIME-types for downloading Certificates and CRLs
        #
        AddType application/x-x509-ca-cert .crt
        AddType application/x-pkcs7-crl    .crl
         
        #
        # AddHandler allows you to map certain file extensions to "handlers":
        # actions unrelated to filetype. These can be either built into the server
        # or added with the Action directive (see below)
        #
        # To use CGI scripts outside of ScriptAliased directories:
        # (You will also need to add "ExecCGI" to the "Options" directive.)
        #
        #AddHandler cgi-script .cgi
         
        #
        # For files that include their own HTTP headers:
        #
        #AddHandler send-as-is asis
         
        #
        # For type maps (negotiated resources):
        # (This is enabled by default to allow the Apache "It Worked" page
        #  to be distributed in multiple languages.)
        #
        AddHandler type-map var
         
        #
        # Filters allow you to process content before it is sent to the client.
        #
        # To parse .shtml files for server-side includes (SSI):
        # (You will also need to add "Includes" to the "Options" directive.)
        #
        AddType text/html .shtml
        AddOutputFilter INCLUDES .shtml
         
        #
        # Action lets you define media types that will execute a script whenever
        # a matching file is called. This eliminates the need for repeated URL
        # pathnames for oft-used CGI file processors.
        # Format: Action media/type /cgi-script/location
        # Format: Action handler-name /cgi-script/location
        #
         
        #
        # Customizable error responses come in three flavors:
        # 1) plain text 2) local redirects 3) external redirects
        #
        # Some examples:
        #ErrorDocument 500 "The server made a boo boo."
        #ErrorDocument 404 /missing.html
        #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
        #ErrorDocument 402 http://www.example.com/subscription_info.html
        #
         
        #
        # Putting this all together, we can internationalize error responses.
        #
        # We use Alias to redirect any /error/HTTP_.html.var response to
        # our collection of by-error message multi-language collections.  We use 
        # includes to substitute the appropriate text.
        #
        # You can modify the messages' appearance without changing any of the
        # default HTTP_.html.var files by adding the line:
        #
        #   Alias /error/include/ "/your/include/path/"
        #
        # which allows you to create your own set of files by starting with the
        # /var/www/error/include/ files and
        # copying them to /your/include/path/, even on a per-VirtualHost basis.
        #
         
        Alias /error/ "/var/www/error/"
         
         
         
         
                AllowOverride None
                Options IncludesNoExec
                AddOutputFilter Includes html
                AddHandler type-map var
                Order allow,deny
                Allow from all
                LanguagePriority en es de fr
                ForceLanguagePriority Prefer Fallback
         
         
        #    ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var
        #    ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var
        #    ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var
        #    ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var
        #    ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var
        #    ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var
        #    ErrorDocument 410 /error/HTTP_GONE.html.var
        #    ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var
        #    ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var
        #    ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var
        #    ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var
        #    ErrorDocument 415 /error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var
        #    ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var
        #    ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var
        #    ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var
        #    ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var
        #    ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var
         
         
         
         
        #
        # The following directives modify normal HTTP response behavior to
        # handle known problems with browser implementations.
        #
        BrowserMatch "Mozilla/2" nokeepalive
        BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
        BrowserMatch "RealPlayer 4\.0" force-response-1.0
        BrowserMatch "Java/1\.0" force-response-1.0
        BrowserMatch "JDK/1\.0" force-response-1.0
         
        #
        # The following directive disables redirects on non-GET requests for
        # a directory that does not include the trailing slash.  This fixes a 
        # problem with Microsoft WebFolders which does not appropriately handle 
        # redirects for folders with DAV methods.
        # Same deal with Apple's DAV filesystem and Gnome VFS support for DAV.
        #
        BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
        BrowserMatch "MS FrontPage" redirect-carefully
        BrowserMatch "^WebDrive" redirect-carefully
        BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully
        BrowserMatch "^gnome-vfs/1.0" redirect-carefully
        BrowserMatch "^XML Spy" redirect-carefully
        BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully
         
        #
        # Allow server status reports generated by mod_status,
        # with the URL of http://servername/server-status
        # Change the ".example.com" to match your domain to enable.
        #
        #
        #    SetHandler server-status
        #    Order deny,allow
        #    Deny from all
        #    Allow from .example.com
        #
         
        #
        # Allow remote server configuration reports, with the URL of
        #  http://servername/server-info (requires that mod_info.c be loaded).
        # Change the ".example.com" to match your domain to enable.
        #
        #
        #    SetHandler server-info
        #    Order deny,allow
        #    Deny from all
        #    Allow from .example.com
        #
         
        #
        # Proxy Server directives. Uncomment the following lines to
        # enable the proxy server:
        #
        #
        #ProxyRequests On
        #
        #
        #    Order deny,allow
        #    Deny from all
        #    Allow from .example.com
        #
         
        #
        # Enable/disable the handling of HTTP/1.1 "Via:" headers.
        # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
        # Set to one of: Off | On | Full | Block
        #
        #ProxyVia On
         
        #
        # To enable a cache of proxied content, uncomment the following lines.
        # See http://httpd.apache.org/docs/2.2/mod/mod_cache.html for more details.
        #
        #
        #   CacheEnable disk /
        #   CacheRoot "/var/cache/mod_proxy"
        #
        #
         
        #
        # End of proxy directives.
         
        ### Section 3: Virtual Hosts
        #
        # VirtualHost: If you want to maintain multiple domains/hostnames on your
        # machine you can setup VirtualHost containers for them. Most configurations
        # use only name-based virtual hosts so the server doesn't need to worry about
        # IP addresses. This is indicated by the asterisks in the directives below.
        #
        # Please see the documentation at 
        # 
        # for further details before you try to setup virtual hosts.
        #
        # You may use the command line option '-S' to verify your virtual host
        # configuration.
         
        #
        # Use name-based virtual hosting.
        #
        #NameVirtualHost *:80
        #
        # NOTE: NameVirtualHost cannot be used without a port specifier 
        # (e.g. :80) if mod_ssl is being used, due to the nature of the
        # SSL protocol.
        #
         
        #
        # VirtualHost example:
        # Almost any Apache directive may go into a VirtualHost container.
        # The first VirtualHost section is used for requests without a known
        # server name.
        #
        #
        #    ServerAdmin [email protected]
        #    DocumentRoot /www/docs/dummy-host.example.com
        #    ServerName dummy-host.example.com
        #    ErrorLog logs/dummy-host.example.com-error_log
        #    CustomLog logs/dummy-host.example.com-access_log common
        #
        localhost 127.0.0.1
        • Do you have some reason why you have localhost 127.0.0.1 alone in last line? If not then remove it or comment it out and try start/restart apache again.

          • Thank you JR. Its working perectly well now after removing localhost 127.0.0.1 from the file.
            Do I need to be superuser to add/edit files in /var/www/html/ directory to use with Apache. Kinldy let me know the procedure to access the contents of the folder as a user.

            • You are welcome Venkata! Nice to hear that you got apache working!

              For safety reasons, it is better to use Apache User dir than change /var/www/html directory permissions.

              So here is guide howto setup Apache User and then you can access / edit files as a user.

              • Thank you very much JR. All set to use Apache now. Your guidance was understandable, easy and effective.
                My thanks again for the prompt help too.

                • You are very welcome! Nice to hear that everything is working! And thank you for compliment! :)

  50. Also, we can install it with:

    # yum groupinstall -y web-server

    • Hi Boubakr,

      yum groupinstall -y web-server

      Doesn’t work on RHEL 6/5, CentOS 6/5 and earlier Fedora versions. And this installs only Apache not PHP with modules.

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackbacks/Pingbacks

  1. Install Apache (httpd) and PHP 5.3.3 on Fedora 13, CentOS/RHEL 5.5/6 « apache - [...] Pełny artykuł na: Install Apache (httpd) and PHP 5.3.3 on Fedora 13, CentOS/RHEL 5.5/6 [...]
  2. Configuring PHP, Apache and Squirrelmail - [...] scripting language. Take a look at this. https://www.digitalocean.com/communi...ck-on-centos-6 http://www.if-not-true-then-false.co...-red-hat-rhel/ & [...]