Results 1 to 6 of 6

Thread: Install PHP5 On Fedora 10 and Apache2 with mod_fcgid

  1. #1
    Join Date
    Aug 2005
    Posts
    822

    Install PHP5 On Fedora 10 and Apache2 with mod_fcgid

    For this guide, we have to use a Fedora 10 server with some hostname, consider it to be server1.example.com and the IP address 192.168.XXX.XXX.

    Now try to create two Apache vhosts, consider it to be www.example1.com and www.example2.com, for demonstration of application of mod_fcgid.

    Staring with this guide, Ensure that SELinux option is disabled with the help of Open /etc/selinux/config.

    Code:
    vi /etc/selinux/config
    and try to set it as SELINUX in order to disable it:

    This file helps you to control the state of SELinux on the working system:

    Code:
    SELINUX= can take one of these three values:
          enforcing - SELinux security policy is enforced.
          permissive - SELinux prints warnings instead of enforcing.
          disabled - No SELinux policy is loaded.
    SELINUX=disabled
          SELINUXTYPE= can take one of these two values:
          targeted - Targeted processes are protected,
          mls - Multi Level Security protection.
    SELINUXTYPE=targeted
    Execute

    Code:
    setenforce 0
    This will help you for making changes in order to take effect.

  2. #2
    Join Date
    Aug 2005
    Posts
    822

    Re: Install PHP5 On Fedora 10 and Apache2 with mod_fcgid

    Installation Procedure of Apache2/mod_fcgi/PHP5:

    Steps to install Apache2/mod_fcgi/Php5 is as follows:

    PHP Code:
    yum install httpd mod_fcgid php-cli 
    If you have already installed Apache2 with PHP5 just as an Apache module, you can disable the PHP5 module by opening /etc/httpd/conf.d/php.conf.

    PHP Code:
    vi /etc/httpd/conf.d/php.conf 
    Try to comment the entire content from the file:


    PHP is an HTML-embedded scripting language which attempts to make it
    easy for developers to write dynamically generated webpages.


    PHP Code:
    LoadModule php5_module modules/libphp5.so
    Cause the PHP interpreter to handle files with a 
    .php extension.
    AddHandler php5-script .php
    AddType text
    /html .php
    Add index
    .php to the list of files that will be served as directory
    indexes
    .

    DirectoryIndex index.php
    Uncomment the following line to allow PHP to pretty
    -print .phps
    files 
    as PHP source code:

    AddType application/x-httpd-php-source .phps 
    Try to create a system startup link for apache in order to start it:

    PHP Code:
    chkconfig --levels 235 httpd on
    /etc/init.d/httpd restart 
    Then the next step is to open it:

    PHP Code:
    vi /etc/php.ini 
    Also add a code just at the end of the file:

    PHP Code:
    cgi.fix_pathinfo 
    Then try to reload Apache:

    PHP Code:
    /etc/init.d/httpd reload 

  3. #3
    Join Date
    Aug 2005
    Posts
    822

    Re: Install PHP5 On Fedora 10 and Apache2 with mod_fcgid

    Steps To Create Vhosts For www.example1.com As well as www.example2.com:

    Now you have to create two vhosts, www.example1.com with the help of document root /var/www/web1/web and www.example2.com with the help of document root /var/www/web2/web. The example www.example1.com will be used and worked by the user and by the group web1, and www.example2.com owned by the user and by the group web2.

    Initially try to create users and groups:

    Code:
    groupadd web1
    groupadd web2
    useradd -s /bin/false -d /var/www/web1 -m -g web1 web1
    useradd -s /bin/false -d /var/www/web2 -m -g web2 web2
    chmod 755 /var/www/web1
    chmod 755 /var/www/web2
    Then try to create the document roots and make them accessed by the users/groups web1 resp. web2:

    Code:
    mkdir -p /var/www/web1/web
    chown web1:web1 /var/www/web1/web
    mkdir -p /var/www/web2/web
    chown web2:web2 /var/www/web2/web
    Now execute PHP using suExec; suExec's document root is /var/www, as per the below provided command explains:

    Code:
    /usr/sbin/suexec -V
    [root@server1 ~] /usr/sbin/suexec -V
    -D AP_DOC_ROOT="/var/www"
    -D AP_GID_MIN=100
    -D AP_HTTPD_USER="apache"
    -D AP_LOG_EXEC="/var/log/httpd/suexec.log"
    -D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin"
    -D AP_UID_MIN=500
    -D AP_USERDIR_SUFFIX="public_html"
    [root@server1 ~]

    It's actually not possible to call the PHP binary /usr/bin/php-cgi directly as it is actually located beyond suExec's document root. suExec will not allow symlinks, the only path for solving this problem is by creating a wrapper script for every web site in a provided subdirectory of /var/www; the wrapper script will then be able to call the PHP binary /usr/bin/php-cgi. The wrapper script must be accessed by the user and group of every web site, thus here you require a wrapper script for every web site. Try to create the wrapper scripts in provided subdirectories of /var/www/php-fcgi-scripts, e.g. /var/www/php-fcgi-scripts/web1 and /var/www/php-fcgi-scripts/web2.

    Code:
    mkdir -p /var/www/php-fcgi-scripts/web1
    mkdir -p /var/www/php-fcgi-scripts/web2
    PHP Code:
    vi /var/www/php-fcgi-scripts/web1/php-fcgi-starter 
    /bin/sh
    PHPRC=/etc/
    export PHPRC
    export PHP_FCGI_MAX_REQUESTS=5000
    export PHP_FCGI_CHILDREN=8
    exec /usr/bin/php-cgi

    PHP Code:
    vi /var/www/php-fcgi-scripts/web2/php-fcgi-starter 

  4. #4
    Join Date
    Aug 2005
    Posts
    822

    Re: Install PHP5 On Fedora 10 and Apache2 with mod_fcgid

    The PHPRC line consists of the directory where the php.ini file is actually located /etc/ translates to /etc/php.ini. PHP_FCGI_MAX_REQUESTS will be the maximum number of requests applied as an fcgid process will be stopped for and a new one will be launched. PHP_FCGI_CHILDREN also try to define the number of PHP children which will be actually launched.

    The php-fcgi-starter scripts will get executed, and they are actually present the directories which must be actually accessed by the web site's owner and group:

    PHP Code:
    chmod 755 /var/www/php-fcgi-scripts/web1/php-fcgi-starter
    chmod 755 
    /var/www/php-fcgi-scripts/web2/php-fcgi-starter
    chown 
    -R web1:web1 /var/www/php-fcgi-scripts/web1
    chown 
    -R web2:web2 /var/www/php-fcgi-scripts/web2 
    Also you can try to create the Apache vhosts for the www.example1.com and www.example2.com. Also you can add the required two vhosts at the end of /etc/httpd/conf/httpd.conf:

    Code:
    vi /etc/httpd/conf/httpd.conf
    PHP Code:
    NameVirtualHost *:80

    <VirtualHost *:80>
      
    ServerName www.example1.com
      ServerAlias example1
    .com
      ServerAdmin webmaster
    @example1.com
      DocumentRoot 
    /var/www/web1/web/

      <
    IfModule mod_fcgid.c>
        
    SuexecUserGroup web1 web1
        PHP_Fix_Pathinfo_Enable 1
        
    <Directory /var/www/web1/web/>
          
    Options +ExecCGI
          AllowOverride All
          AddHandler fcgid
    -script .php
          FCGIWrapper 
    /var/www/php-fcgi-scripts/web1/php-fcgi-starter .php
          Order allow
    ,deny
          Allow from all
        
    </Directory>
      </
    IfModule>

      
    # ErrorLog /var/log/apache2/error.log
      # CustomLog /var/log/apache2/access.log combined
      
    ServerSignature Off

    </VirtualHost>

    <
    VirtualHost *:80>
      
    ServerName www.example2.com
      ServerAlias example2
    .com
      ServerAdmin webmaster
    @example2.com
      DocumentRoot 
    /var/www/web2/web/

      <
    IfModule mod_fcgid.c>
        
    SuexecUserGroup web2 web2
        PHP_Fix_Pathinfo_Enable 1
        
    <Directory /var/www/web2/web/>
          
    Options +ExecCGI
          AllowOverride All
          AddHandler fcgid
    -script .php
          FCGIWrapper 
    /var/www/php-fcgi-scripts/web2/php-fcgi-starter .php
          Order allow
    ,deny
          Allow from all
        
    </Directory>
      </
    IfModule>

      
    # ErrorLog /var/log/apache2/error.log
      # CustomLog /var/log/apache2/access.log combined
      
    ServerSignature Off

    </VirtualHost

  5. #5
    Join Date
    Aug 2005
    Posts
    822

    Re: Install PHP5 On Fedora 10 and Apache2 with mod_fcgid

    Try to Ensure you fill in the correct options and the correct owner and group in the SuexecUserGroup lines.

    Try to Reload Apache later:

    Code:
    /etc/init.d/httpd reload
    Testing:

    Try to create a small PHP test file, for instance such as in the www.example1.com web site.

    Code:
    vi /var/www/web1/web/info.php
    PHP Code:
    <?php
    phpinfo
    ();
    ?>
    and then try to call the file present inside the browser http://www.example1.com/info.php). If everything works fine, the output you will recieve will be similar to this, and you should check CGI/FastCGI in the Server API line:


    Custom php.ini for Each Web Site:

    As every web site consists of its own php-fcgi-starter wrapper script, it can be a case in order to define different php.ini files for some different web sites. In order to demonstrate this activity, you have to copy the default php.ini /etc/php.ini to the /var/www/web2/ directory and create www.example2.com will help you to apply the php.ini from the /var/www/web2/ directory:

    PHP Code:
    cp /etc/php.ini /var/www/web2/
    chown web2:web2 /var/www/web2/php.ini 
    You are also able to modify /var/www/web2/php.ini to your likings.

    Then you can try to open /var/www/php-fcgi-scripts/web2/php-fcgi-starter.

    PHP Code:
    vi /var/www/php-fcgi-scripts/web2/php-fcgi-starter 
    Then try to insert /var/www/web2/ in the PHPRC line:

    PHP Code:
    !/bin/sh
    PHPRC
    =/var/www/web2/
    export PHPRC
    export PHP_FCGI_MAX_REQUESTS
    =5000
    export PHP_FCGI_CHILDREN
    =8
    exec 
    /usr/bin/php-cgi 

  6. #6
    Join Date
    Aug 2005
    Posts
    822

    Re: Install PHP5 On Fedora 10 and Apache2 with mod_fcgid

    Try to reload Apache later:

    Code:
    /etc/init.d/httpd reload
    You can create a new phpinfo(); file for www.example2.com.

    Code:
    vi /var/www/web2/web/info.php
    PHP Code:
    <?php
    phpinfo
    ();
    ?>
    Try to call this inside a browser by typing http://www.example2.com/info.php. The Loaded Configuration File line will display /var/www/web2/php.ini:


    Change Single PHP Configuration Settings:

    You can escape from passing the entire new php.ini file on your web site, you are also able to change single PHP configuration settings in the php-fcgi-starter wrapper script or can apply a combination of both just by inserting the -d switch on the PHP executable. For example, if you are not able to disable magic_quotes_gpc for the web site www.example2.com, you have to just perform as follows:

    Code:
    vi /var/www/php-fcgi-scripts/web2/php-fcgi-starter
    PHP Code:
    /bin/sh
    PHPRC
    =/etc/
    export PHPRC
    export PHP_FCGI_MAX_REQUESTS
    =5000
    export PHP_FCGI_CHILDREN
    =8
    exec 
    /usr/bin/php-cgi -d magic_quotes_gpc=off 
    You can alos Reload Apache later:

    Code:
    /etc/init.d/httpd reload
    You are also able to call the info.php script inside a browser http://www.example2.com/info.php and then try to search for the magic_quotes_gpc line - which will be displayed:


Similar Threads

  1. How to install PHP5 Framework Symfony
    By Danel in forum Software Development
    Replies: 4
    Last Post: 01-12-2010, 01:26 AM
  2. How to limit Number of PHP processes on w/ mod_fcgid
    By Winnebago in forum Software Development
    Replies: 7
    Last Post: 19-06-2010, 12:33 AM
  3. How to install Apache2 and PHP on Fedora 12
    By Kanakpriya in forum Operating Systems
    Replies: 5
    Last Post: 20-02-2010, 01:43 AM
  4. How to Install Nginx with PHP5 on Fedora 12
    By OSzilla in forum Operating Systems
    Replies: 5
    Last Post: 09-02-2010, 03:36 AM
  5. Learn how to Install Apache2 MySQL and PHP on Windows
    By ameer123 in forum Guides & Tutorials
    Replies: 1
    Last Post: 31-07-2009, 01:18 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,991,582.72438 seconds with 16 queries