Install Apache/PHP 5.4.14 on Fedora 18/17, CentOS/RHEL 6.4/5.9

This guide shows howto install Apache HTTP Server (httpd) with PHP 5.4.14 and following modules on Fedora 18/17/16/15/14, CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9 systems.

  • APC (php-pecl-apc) – APC caches and optimizes PHP intermediate code
  • 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-mysql) – 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.4.14

1. Change root user

su -
## OR ##
sudo -i

2. Install Remi repository

Fedora

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

Fedora 18/17/16/15/14/13/12

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

CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9

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

4. Install PHP 5.4.14 modules

Select what you need: APC, 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 18/17/16/15/14/13/12

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

CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9

yum --enablerepo=remi,remi-test install php-pecl-apc php-cli php-pear php-pdo php-mysql 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
 
chkconfig --levels 235 httpd on

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

Add following content to /var/www/html/test.php file.

<?php
 
    phpinfo();
 
?>

7. Check created page with browser

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

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

1. Edit /etc/sysconfig/iptables file:

nano -w /etc/sysconfig/iptables

2. Add following INPUT rule:

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

3. Restart Iptables Firewall:

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

4. Test remote connection

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

More reading:

Enable Apache Userdir with SELinux on Fedora 18/17/16/15/14, 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!

184 Comments

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

    Help Please!

    • Hi UZ,

      Try following instead:

      service httpd restart
  2. Hello JR,

    [root@phi umar]# service httpd restart
    Restarting httpd (via systemctl): Job failed. See system logs and ‘systemctl status’ for details.
    [FAILED]
  3. [root@phi umar]# service httpd restart
    Restarting httpd (via systemctl): Job failed. See system logs and ‘systemctl status’ for details.
    [FAILED]

    • Hi again UZ,

      Could you post output of following commands:

      systemctl status httpd.service
       
      cat /var/log/messages | grep httpd
       
      httpd -t
       
      tail -n 150 /var/log/httpd/error_log
  4. Hi, I’ve use the command as follow: yum --enablerepo=remi install httpd php php-common so PHP 5.3.17 was installed instead of 5.4.7. It’s possible to upgrade from 5.3.17 to 5.4.7 without mess the system? How?
    Thanks

    • Hi ReynierPM,

      Following should work:

      yum --enablerepo=remi,remi-test update httpd php php-common
       
      service httpd restart

      You should also make sure that you update also all PHP modules and all your PHP scripts should work with PHP 5.4. Best and safest method is backup your system before update and test this change on test server or some virtual machine.

  5. If it is not working as you expect, just do yum downgrade php* and all will be set to working stock versions.

  6. if i use this cmd: yum --enablerepo=remi,remi-test install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
    come this why?

    http://www.upload.ee/image/2768958/Untitled.png

    • Hi tarmo,

      You have conflict between your current MySQL 5.0.95 installation and remi repo php-mysql (mysql-libs) 5.5.28 packages.

  7. Hi,

    When i try to update the php, this error show:-

    Error: Package: php-gd-5.4.9-1.el6.remi.x86_64 (remi-test)
    Requires: libt1.so.5()(64bit)

    • Hi Faisal,

      Could you post output of following commands:

      yum list installed t1lib
       
      ls -la /usr/lib64/libt1.*
       
      uname -a
       
      lsb_release -a
  8. i get this error :

    Error unpacking rpm package php-common-5.4.10-1.el5.remi.i386
    warning: /etc/php.ini created as /etc/php.ini.rpmnew
    error: unpacking of archive failed on file /usr/lib/php: cpio: chown

    • Hi joe,

      Could you post output of following commands:

      df
       
      free
  9. Everything always posts when they have problems.. Everything worked fine for me on CentOS 6.3 x86_64. This saved me some time, thanks!

  10. Thanks for this, worked great. I was having problems previously with permissions and the GD library so I wiped and used this as a clean install.

    My only issue now is that mod_rewrite doesn’t seem to work properly. An existing wordpress install I had gives me 404′s when I follow any of the “pretty permalinks”. When I change them back to query strings, they work just fine.

    I checked httpd.conf and the module is imported. I refreshed the permalink settings in WordPress and made sure the .htaccess file was writeable by the server. The rewrite rules are in the .htaccess file properly. Any ideas?

    Thanks!

    • Fixed!

      Had to change AllowOverride from None to All under .

      Thanks again for this great guide. I’ll be coming back here often.

  11. Dear JR
    I followed the steps but got the error

    [root@localhost conf.d]# service httpd restart
    Restarting httpd (via systemctl): Job failed. See system logs and ‘systemctl status’ for details.
    [FAILED]

    [root@localhost conf.d]# systemctl status httpd.service
    httpd.service – LSB: start and stop Apache HTTP Server
    Loaded: loaded (/etc/rc.d/init.d/httpd)
    Active: failed since Thu, 31 Jan 2013 20:04:28 +0530; 52s ago
    Process: 22198 ExecStart=/etc/rc.d/init.d/httpd start (code=exited, status=1/FAILURE)
    Main PID: 30487 (code=exited, status=0/SUCCESS)
    CGroup: name=systemd:/system/httpd.service

    [root@localhost conf.d]# httpd -t
    Syntax OK

    [root@localhost conf.d]# cat /var/log/messages | grep httpd
    Jan 31 20:03:43 localhost systemd[1]: httpd.service: control process exited, code=exited status=1
    Jan 31 20:03:43 localhost systemd[1]: Unit httpd.service entered failed state.
    Jan 31 20:04:28 localhost systemd[1]: httpd.service: control process exited, code=exited status=1
    Jan 31 20:04:28 localhost systemd[1]: Unit httpd.service entered failed state.
    Jan 31 20:05:44 localhost systemd[1]: httpd.service: control process exited, code=exited status=1
    Jan 31 20:05:44 localhost systemd[1]: Unit httpd.service entered failed state.

    Please help

    • Hi Priyabrata,

      Could you also post output of following commands:

      cat /var/log/httpd/error_log
       
      lsb_release -a
       
      uname -a
      • [root@localhost Test30Jan2013]# ll /var/log/httpd/
        total 20
        -rw-r–r–. 1 root root 0 Dec 11 2011 access_log
        -rw-r–r–. 1 root root 1749 Dec 6 2011 access_log-20111211
        -rw-r–r–. 1 root root 0 Jan 26 03:16 error_log
        -rw-r–r–. 1 root root 1723 Dec 11 2011 error_log-20111211
        -rw-r–r–. 1 root root 958 Jan 31 19:08 error_log-20130126
        -rw-r–r–. 1 root root 0 Dec 6 2011 ssl_access_log
        -rw-r–r–. 1 root root 0 Jan 26 03:16 ssl_error_log
        -rw-r–r–. 1 root root 258 Dec 6 2011 ssl_error_log-20111211
        -rw-r–r–. 1 root root 258 Jan 25 17:21 ssl_error_log-20130126
        -rw-r–r–. 1 root root 0 Dec 6 2011 ssl_request_log

        ###############
        cat /var/log/httpd/error_log: Empty file, nothing is written

        ################
        [root@localhost Test30Jan2013]# lsb_release -a
        LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch
        Distributor ID: Fedora
        Description: Fedora release 15 (Lovelock)
        Release: 15
        Codename: Lovelock

        ##################
        [root@localhost Test30Jan2013]# uname -a
        Linux localhost.localdomain 2.6.43.8-1.fc15.x86_64 #1 SMP Mon Jun 4 20:33:44 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

        • Thanks, then use following to get older log entries:

          cat /var/log/httpd/error_log*

          And check also syntax errors:

          httpd -t
          • [root@localhost Test30Jan2013]# httpd -t
            Syntax OK

            ########## Sorry for lengthy output ###########

            [root@localhost Test30Jan2013]# cat /var/log/httpd/error_log*
            [Tue Dec 06 14:48:39 2011] [notice] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
            [Tue Dec 06 14:48:39 2011] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
            [Tue Dec 06 14:48:39 2011] [notice] SSL FIPS mode disabled
            [Tue Dec 06 14:48:39 2011] [notice] Digest: generating secret for digest authentication …
            [Tue Dec 06 14:48:39 2011] [notice] Digest: done
            [Tue Dec 06 14:48:39 2011] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
            [Tue Dec 06 14:48:39 2011] [notice] mod_python: using mutex_directory /tmp
            [Tue Dec 06 14:48:40 2011] [notice] SSL FIPS mode disabled
            [Tue Dec 06 14:48:40 2011] [notice] Apache/2.2.21 (Unix) DAV/2 PHP/5.3.8 mod_python/3.3.1 Python/2.7.1 mod_ssl/2.2.21 OpenSSL/1.0.0e-fips mod_perl/2.0.4 Perl/v5.12.4 configured — resuming normal operations
            [Tue Dec 06 14:48:53 2011] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
            [Tue Dec 06 14:48:53 2011] [error] [client ::1] File does not exist: /var/www/html/favicon.ico
            [Tue Dec 06 14:48:53 2011] [error] [client ::1] File does not exist: /var/www/html/favicon.ico
            [Tue Dec 06 14:51:49 2011] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
            [Tue Dec 06 14:52:29 2011] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
            [Tue Dec 06 14:52:36 2011] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
            [Sun Dec 11 03:38:03 2011] [notice] SIGHUP received. Attempting to restart
            (98)Address already in use: make_sock: could not bind to address 172.16.49.47:80
            no listening sockets available, shutting down
            Unable to open logs
            [Fri Jan 25 17:21:17 2013] [notice] SELinux policy enabled; httpd running as context unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
            [Fri Jan 25 17:21:17 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
            [Fri Jan 25 17:21:17 2013] [notice] SSL FIPS mode disabled
            [Fri Jan 25 17:21:17 2013] [notice] Digest: generating secret for digest authentication …
            [Fri Jan 25 17:21:17 2013] [notice] Digest: done
            [Fri Jan 25 17:21:17 2013] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
            [Fri Jan 25 17:21:17 2013] [notice] mod_python: using mutex_directory /tmp
            [Fri Jan 25 17:21:17 2013] [notice] SSL FIPS mode disabled
            [Fri Jan 25 17:21:18 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.13 mod_python/3.3.1 Python/2.7.1 mod_ssl/2.2.22 OpenSSL/1.0.0j-fips mod_perl/2.0.4 Perl/v5.12.4 configured — resuming normal operations
            [Thu Jan 31 19:08:55 2013] [notice] caught SIGTERM, shutting down

            • Thanks Priyabrata,

              First thing what I noticed is:
              (98)Address already in use: make_sock: could not bind to address 172.16.49.47:80

              Do you have some other server/service running on port 80?

              • Dear JR

                The problem was sorted out. Actually I had installed Apache latest version with –prefix option and where I have configured for 172.16.49.47:80. This new installation was conflicting with the default httpd conf file at /etc/httpd/conf/http.conf.

                I deleted the newly installed apache, restarted the server. It worked fine now.

                Dear JR, Thanks for your nice blog, time and ur patience. Really thanks :)

                Now my next task is to configure mysql and php. In this regard if I may face any problem then reply u.

                • Hi again Priyabrata,

                  Excellent to hear that you got it working! :)

                  And thanks for the compliments! You are very welcome! :)

                  Did you get mysql and php up and running?

  12. I installed apache on fedora 18 x86_64, but when I started the service I had some error on config files:


    [root@localhost conf.d]# service httpd start
    Redirecting to /bin/systemctl start httpd.service
    Job for httpd.service failed. See ‘systemctl status httpd.service’ and ‘journalctl -xn’ for details.

    [root@localhost conf.d]# systemctl status httpd.service
    httpd.service – The Apache HTTP Server
    Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
    Active: failed (Result: exit-code) since mer 2013-02-06 14:39:48 CET; 1min 55s ago
    Process: 14515 ExecStop=/usr/sbin/httpd $OPTIONS -k graceful-stop (code=exited, status=1/FAILURE)
    Process: 14513 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
    Status: “Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec”

    feb 06 14:39:48 localhost.localdomain systemd[1]: Starting The Apache HTTP Server…
    feb 06 14:39:48 localhost.localdomain httpd[14513]: httpd: Syntax error on line 351 of /etc/httpd/conf/httpd.conf: Syntax error on line 140 of /etc/httpd/conf.d/system-config-httpd.conf: /etc/httpd/conf.d/system-config-httpd.conf:146: was not closed.\n/etc/httpd/conf.d/system-config-httpd.conf:144: was not closed.\n/etc/httpd/conf.d/system-config-httpd.conf:142: was not closed.\n/etc/httpd/conf.d/system-config-httpd.conf:140: was not closed.
    feb 06 14:39:48 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
    feb 06 14:39:48 localhost.localdomain httpd[14515]: httpd: Syntax error on line 351 of /etc/httpd/conf/httpd.conf: Syntax error on line 140 of /etc/httpd/conf.d/system-config-httpd.conf: /etc/httpd/conf.d/system-config-httpd.conf:146: was not closed.\n/etc/httpd/conf.d/system-config-httpd.conf:144: was not closed.\n/etc/httpd/conf.d/system-config-httpd.conf:142: was not closed.\n/etc/httpd/conf.d/system-config-httpd.conf:140: was not closed.
    feb 06 14:39:48 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
    feb 06 14:39:48 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
    feb 06 14:39:48 localhost.localdomain systemd[1]: Unit httpd.service entered failed state

    Can you help me please?

    • Hi Bruno,

      Check this:

      feb 06 14:39:48 localhost.localdomain httpd[14513]: httpd: Syntax error on line 351 of /etc/httpd/conf/httpd.conf: Syntax error on line 140 of /etc/httpd/conf.d/system-config-httpd.conf: /etc/httpd/conf.d/system-config-httpd.conf:146: was not closed.\n/etc/httpd/conf.d/system-config-httpd.conf:144: was not closed.\n/etc/httpd/conf.d/system-config-httpd.conf:142: was not closed.\n/etc/httpd/conf.d/system-config-httpd.conf:140: was not closed.

      Looks like you have some syntax error on your httpd.conf file.

      Try to run:

      httpd -t

      And fix error and then try start httpd again.

      • Hi HR,
        I tried, this is the output:


        [root@localhost ~]# httpd
        httpd: Syntax error on line 351 of /etc/httpd/conf/httpd.conf: Syntax error on line 137 of /etc/httpd/conf.d/system-config-httpd.conf: /etc/httpd/conf.d/system-config-httpd.conf:143: was not closed.\n/etc/httpd/conf.d/system-config-httpd.conf:141: was not closed.\n/etc/httpd/conf.d/system-config-httpd.conf:139: was not closed.\n/etc/httpd/conf.d/system-config-httpd.conf:137: was not closed.
        [root@localhost ~]# httpd -t
        httpd: Syntax error on line 351 of /etc/httpd/conf/httpd.conf: Syntax error on line 137 of /etc/httpd/conf.d/system-config-httpd.conf: /etc/httpd/conf.d/system-config-httpd.conf:143: was not closed.\n/etc/httpd/conf.d/system-config-httpd.conf:141: was not closed.\n/etc/httpd/conf.d/system-config-httpd.conf:139: was not closed.\n/etc/httpd/conf.d/system-config-httpd.conf:137: was not closed.
        [root@localhost ~]# tail -20 /etc/httpd/conf.d/system-config-httpd.conf
        # 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).
        #
        # 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.
        #

        Options FollowSymLinksAllowOverride None

        Options Indexes Includes FollowSymLinksAllowOverride NoneAllow from allOrder allow,deny

        Options Indexes MultiViewsAllowOverride NoneAllow from allOrder allow,deny

        Options ExecCGIAllowOverride NoneAllow from allOrder allow,deny

        [root@localhost ~]#

        I don’t understand what kind of error is was not closed. so I don’t how to fix.
        I tried to comment these lines and apache start without errors but doesn’t work.

        • Sorry, the previous output is no readable becouse the characters < and > are recoded.
          The error that I don’t understand is:

          <Directory> is not closed.

          The error lines are in /etc/httpd/conf.d/system-config-httpd.conf , and the error lines are thease:


          <Directory “/”>
          Options FollowSymLinksAllowOverride None</Directory>
          <Directory “/var/www/html”>
          Options Indexes Includes FollowSymLinksAllowOverride NoneAllow from allOrder allow,deny</Directory>
          <Directory “/var/www/icons”>
          Options Indexes MultiViewsAllowOverride NoneAllow from allOrder allow,deny</Directory>
          <Directory “/var/www/cgi-bin”>
          Options ExecCGIAllowOverride NoneAllow from allOrder allow,deny</Directory>

          • Hi Bruno,

            This conf looks good, but is there somewhere near this, some <directory> element which is not closed?

            Could you paste all of your config files example to http://pastebin.com ?

            • Hi HR,
              I put the tarball of /etc/httpd directory in google drive:

              https://docs.google.com/file/d/0Bxuknh8WR68bcW9xM3FLLTB4UFk/edit?usp=sharing

              • I checked your config and check following part:

                # Virtual host Default Virtual Host<VirtualHost *>
                 	ServerSignature emailDirectoryIndex  index.php index.html index.htm index.shtmlLogLevel  warnHostNameLookups off</VirtualHost>
                 
                 
                #
                # 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). 
                #
                # 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.
                #
                <Directory "/">
                        Options FollowSymLinksAllowOverride None</Directory>
                <Directory "/var/www/html">
                        Options Indexes Includes FollowSymLinksAllowOverride NoneAllow from allOrder allow,deny</Directory>
                <Directory "/var/www/icons">
                        Options Indexes MultiViewsAllowOverride NoneAllow from allOrder allow,deny</Directory>
                <Directory "/var/www/cgi-bin">
                        Options ExecCGIAllowOverride NoneAllow from allOrder allow,deny</Directory>

                It should look something like:

                # Virtual host Default Virtual Host
                <VirtualHost *>
                 	ServerSignature email
                 	DirectoryIndex  index.php index.html index.htm index.shtml
                 	LogLevel  warn
                 	HostNameLookups off
                </VirtualHost>
                 
                 
                #
                # 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). 
                #
                # 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.
                #
                <Directory "/">
                        Options FollowSymLinks
                 	AllowOverride None
                </Directory>
                <Directory "/var/www/html">
                        Options Indexes Includes FollowSymLinks
                 	AllowOverride None
                 	Allow from all
                 	Order allow,deny
                </Directory>
                <Directory "/var/www/icons">
                        Options Indexes MultiViews
                 	AllowOverride None
                 	Allow from all
                 	Order allow,deny
                </Directory>
                <Directory "/var/www/cgi-bin">
                        Options ExecCGI
                 	AllowOverride None
                 	Allow from all
                 	Order allow,deny
                </Directory>

                So you are missing line breaks or have some problem with those.

                • Thank you for your correction!
                  Now the service start, but doesn’t work.
                  The status of service is this:


                  [root@tron httpd]# service httpd status
                  Redirecting to /bin/systemctl status httpd.service
                  httpd.service – The Apache HTTP Server
                  Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
                  Active: active (running) since mar 2013-02-19 10:31:36 CET; 4min 56s ago
                  Process: 2845 ExecStop=/usr/sbin/httpd $OPTIONS -k graceful-stop (code=exited, status=1/FAILURE)
                  Main PID: 3070 (httpd)
                  Status: “Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec”
                  CGroup: name=systemd:/system/httpd.service
                  ├─3070 /usr/sbin/httpd -DFOREGROUND
                  ├─3072 /usr/sbin/httpd -DFOREGROUND
                  ├─3073 /usr/sbin/httpd -DFOREGROUND
                  ├─3074 /usr/sbin/httpd -DFOREGROUND
                  ├─3075 /usr/sbin/httpd -DFOREGROUND
                  ├─3076 /usr/sbin/httpd -DFOREGROUND
                  ├─3077 /usr/sbin/httpd -DFOREGROUND
                  ├─3078 /usr/sbin/httpd -DFOREGROUND
                  └─3079 /usr/sbin/httpd -DFOREGROUND

                  feb 19 10:31:36 tron.domus systemd[1]: Started The Apache HTTP Server.

                  I found some messages in /var/log/httpd/error_log:


                  [root@tron httpd]# cat error_log
                  [Tue Feb 19 10:31:34.079365 2013] [core:notice] [pid 3070] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
                  [Tue Feb 19 10:31:34.093751 2013] [suexec:notice] [pid 3070] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
                  [Tue Feb 19 10:31:35.024704 2013] [auth_digest:notice] [pid 3070] AH01757: generating secret for digest authentication …
                  [Tue Feb 19 10:31:36.000844 2013] [lbmethod_heartbeat:notice] [pid 3070] AH02282: No slotmem from mod_heartmonitor
                  [Tue Feb 19 10:31:36.508975 2013] [mpm_prefork:notice] [pid 3070] AH00163: Apache/2.4.3 (Fedora) PHP/5.4.11 configured — resuming normal operations
                  [Tue Feb 19 10:31:36.509008 2013] [core:notice] [pid 3070] AH00094: Command line: ‘/usr/sbin/httpd -D FOREGROUND’

                  What do you think about this?

                  • Do you use heartbeat?

                    • No, I don’t.

                    • Try following (as root):

                      cd /etc/httpd/conf.modules.d
                       
                      mv 00-proxy.conf 00-proxy.bak
                       
                      service httpd restart
                • I had exactly this same problem with Fedora 18. Looks like the default system-config-httpd.conf file has a problem with missing line breaks??

  13. I have developed a web server using Apache,Php. I am very new to this field. Although I have developed the server but my concern is the secuirity. I am not sure whether I have developed a secured server or not? Kindly suggest me.

    What my server does
    ———————–
    I have set of files (about 80,000) stored in /var/www/pdb folder. User will give the name of file and I have written some R-scripts (about 10-15) which will parse that file and generates some output, which I have to give back to the user.

    So I had separately kept All database files in /var/www/pdb, all my R-scripts in /var/www/SASMAT. My front-end webpage is /var/www/html/SASMAT.html. Upon input of filename and submit, the action is to call a Php script “upload.php” which fetch user inputs and calls R-script with the input as command line arguments. I have separated the Php script from R-script and kept under /var/www/cgi-bin

    ### Action of form submission is to call upload.php

    ### Php script calls R-script by passing $_POST["pdbid"] as comamdn line args
    $url=’/usr/bin/Rscript /var/www/SASMAT/pipeline.r ‘ . $_POST["pdbid"];
    exec($url,$x);

    ### What R-script does
    1) Copies the filename ($_POST["pdbid"]) from /var/www/pdb to /var/www/upload
    2) Set the working directory to /var/www/upload
    3) Parse the files and generates many outputs
    4) Moves the output files from /var/www/upload back to /var/www/html so that I can give as output.

    Summarizing each folder
    ————————-
    1) My source files (appx 80000 files) : /var/www/pdb
    2) My all R-scripts (appx 10-15 scripts): /var/www/SASMAT
    3) My working directory: /var/www/upload where all parsing stuffs will go
    4) My main output directory: /var/www/html

    What I want
    ———–
    1) User should not access to SASMAT, upload, cgi-bin, pdb.
    2) User only have access to /var/www/html folder.

    ll /var/www
    drwxr-xr-x. 2 manas manas 4096 Feb 18 19:26 cgi-bin
    drwxr-xr-x. 3 manas manas 4096 Oct 31 21:55 error
    drwxr-xrwx. 3 manas manas 4096 Feb 19 17:44 html
    drwxr-xr-x. 3 manas manas 4096 Feb 13 19:28 icons
    drwxrwxrwx 2 apache apache 4096 Feb 19 14:17 pdb
    drwxrwxr-x 2 manas manas 4096 Feb 13 19:29 plots
    drwxrwxr-x 2 manas manas 4096 Feb 19 15:52 SASMAT
    drwxrwxrwx 2 manas manas 4096 Feb 19 17:42 upload

    Currently when user types http://www.example.com/cgi-bin/upload.php: It executes the upload.php which I dont want. I want to restrict the user to use the php scripts directly.

    I am sorry for this lengthy post but I had to.

    • Sorry that at the end the url http://www.example.com/cgi-bin/upload.php is just I had given as examplt. Not the true link

      • Priyabrata,

        First you should add to your upload.php some check that this request is post request.

        Real thing what you can do is post some unique one time hash, which is generated from user data or something else, like timestamp+salt which is saved database and added to form.

        This is just idea:
        1. Generate hash and add it to db
        2. Add this hash to form
        3. Check hash (on upload.php) from $_POST that matches hash in db
        4. Remove hash from db

        Now when someone use your form, upload.php checks first that request is $_POST and then verify hash before doing anything. I think that this is secure enough for most cases. :)

        • Dear JR
          Thanks for nice suggestion. Apart from this as I mentioned how can I make the cgi-bin (All php scripts) not access by client.

          Lets assume my server is http://myip.com/index.html
          upon submit it calls upload.php
          “”

          When user view the source code of my index.html, he can easily see the form action i.e. “../cgi-bin/upload.php”.

          Then by using this knowledge if he types the url http://myip.com/cgi-bin/upload.php, it executes the script.

          Actually I have other php scripts in cgi-bin, for example clean.php which cleans all output files. If user types http://myip.com/cgi-bin/clean.php, it will clean my output files.

          I want to restrict the direct access. Please give ur suggestion in this respect also.

          • Hi Priyabrata,

            You can restrict direct access using httpd conf file or .htaccess and deny access to cgi-bin or selected files, but then those files are accessible only from localhost or specific IP addresses, like:

            <Files *>
                Order Deny,Allow 
                Allow from 127.0.0.1 192.168.0.1
                Deny from all
            </Files>

            So then you can example call your scripts from localhost, but not from public Internet.

            If you really want restrict the direct access, then your users can’t really use your scripts, even they use your form. So then you need another public script which calls example your upload.php and then situation is same, someone could use this script directly and do same thing. So if you want let your users use your scripts then you need something public anyways. And if you want public and protected scripts then you will need some more sophisticated logic than just restrict direct access.

  14. When installing php from remi I keep on getting this error

    Error: Package: php-gd-5.4.12-1.el6.remi.i686 (remi)
    Requires: libt1.so.5

    Running a 32bit rhel 6.3

    Thanks for any pointers on where to go, want to get phpmyadmin running.

    Frank

    • Hi Frank,

      Could you post output of following command:

      yum list available |grep t1lib
      • Hi JR,

        [root@rxxxx ~]# yum list available |grep t1lib
        [root@rxxxx ~]#

        nothing comes out…
        Thanks,
        F.

        • Hi Frank,

          Do you have RHEL Subscription?

          • Hi JR,

            Yes I do.

          • So I enabled the subscription and after installing every thing, I now get: 403 Forbidden You don’t have permission to access /phpmyadmin/ on this server,
            was the install not supposed to also set phpmyadmin to run?
            Thanks,
            F.

            • Hi Frank,

              I’m not sure which is your current setup, but you can check phpMyAdmin install guide for more information.

              • Hi JR,

                Thanks for the help, the issue was in phpMyAdmin.conf, I commented out of

                Require local
                #Order Deny,Allow
                #Deny from All
                Allow from 127.0.0.1
                Allow from ::1

                Frank

                • You are welcome! And nice to hear that you got it working!

  15. Hello,

    I’m getting in trouble when trying to install the following modules :
    yum –enablerepo=remi,remi-test install php-pecl-memcached php-mcrypt

    I receive message from yum complaining about compatibilities :
    –> Finished Dependency Resolution
    Error: Package: php-pecl-memcached-1.0.0-1.el6.x86_64 (epel)
    Requires: php(api) = 20090626
    Installed: php-common-5.4.12-1.el6.remi.x86_64 (@remi)
    php(api) = 20100412-x86-64
    Available: php-common-5.3.3-3.el6_2.8.x86_64 (base)
    php(api) = 20090626
    Available: php-common-5.3.3-14.el6_3.x86_64 (updates)
    php(api) = 20090626
    Available: php-common-5.4.11-1.el6.remi.x86_64 (remi)
    php(api) = 20100412-x86-64
    Error: Package: php-pecl-memcached-1.0.0-1.el6.x86_64 (epel)
    Requires: php(zend-abi) = 20090626
    Installed: php-common-5.4.12-1.el6.remi.x86_64 (@remi)
    php(zend-abi) = 20100525-x86-64
    Available: php-common-5.3.3-3.el6_2.8.x86_64 (base)
    php(zend-abi) = 20090626
    Available: php-common-5.3.3-14.el6_3.x86_64 (updates)
    php(zend-abi) = 20090626
    Available: php-common-5.4.11-1.el6.remi.x86_64 (remi)
    php(zend-abi) = 20100525-x86-64
    Error: Package: php-mcrypt-5.3.3-1.el6.x86_64 (epel)
    Requires: php-api = 20090626
    Installed: php-common-5.4.12-1.el6.remi.x86_64 (@remi)
    php-api = 20100412-x86-64
    Available: php-common-5.3.3-3.el6_2.8.x86_64 (base)
    php-api = 20090626
    Available: php-common-5.3.3-14.el6_3.x86_64 (updates)
    php-api = 20090626
    Available: php-common-5.4.11-1.el6.remi.x86_64 (remi)
    php-api = 20100412-x86-64

    Sorry, but despite googling this, no result or ways to resolve this !

    Any idea ?

    Regards,

    Laurent

    • Try following command instead:

      yum --enablerepo=remi,remi-test --disablerepo=epel install php-pecl-memcached php-mcrypt

      If it’s not working, could you post error messages then and output of following command:

      rpm -qa php\*
  16. Thanks. It helped me a lot.

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