How to Use PHP5-FPM with Apache2 on Fedora 17

This step by step guide helps you to install an Apache 2 webserver on a Fedora 17 with PHP5 via PHP-FPM and MySQL support. PHP-FPM (FastCGI Process Manager) is used as a substitute of PHP FastCGI implementation with some extra utilities that are quite helpful to cater the need of every size of site, particularly those sites having high traffic. This is a simple step by step guide to help you in understanding the whole process.

The hostname that is used in this guide is server.example.com with the IP address 192.168.0.100. These settings vary from system to system, so you have to replace them accordingly.

Instructions

  • 1

    How to enable additional repositories

    You have to install mod_fastcgi after sometime which can be obtained in the RPMforge repositories. In order to enable RPMforge, follow the given code:

    rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

    cd /tmp
    wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
    rpm -ivh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

  • 2

    Installing MySQL 5
    In order to install MySQL, write the following code:

    yum install mysql mysql-server
    After that make the system startup links for MySQL. By doing this, MySQL will boot automatically every time the system starts. Now, launch the MySQL server:

    systemctl enable mysqld.service
    systemctl start mysqld.service

    Create passwords for the MySQL root account:

    mysql_secure_installation

    [root@server1 ~]# mysql_secure_installation





    One thing that should be remembered is that by running every part of this scrip is highly recommended for all MySQL servers in production use. Now, follow each step warily.

    You will need to have an existing password for the root user, if you want to log into MySQL to secure it. In case, you have recently installed MySQL, and you still have to create the root password, then it will show a blank space. Now, click on enter here.

    Enter current password for root (enter for none):
    OK, successfully used password, moving on...

    By creating the root password will enable only authorized people to log into MySQL root user.

    Set root password? [Y/n] <-- ENTER
    New password: <-- yourrootsqlpassword
    Re-enter new password: <-- yourrootsqlpassword
    Password updated successfully!
    Reloading privilege tables..
    ... Success!

    There is a by default option of an anonymous user in MySQL installation, which eventually allow anyone to log into MySQL even if he/she hasn’t any user account. It is because for testing purpose only, and to smoothly run the installation process. You have to delete them before going into a production environment.

    Remove anonymous users? [Y/n] <-- ENTER
    ... Success!

    Usually, root is only connected from ‘localhost’. This is intended because to shun anyone from guessing root password from the network.

    Disallow root login remotely? [Y/n] <-- ENTER
    ... Success!

    MySQL has a built in database name as ‘test’. It allows everyone to access it. It is used only for testing, and once you move into a production environment, it should be removed then.

    Remove test database and access to it? [Y/n] <-- ENTER
    - Dropping test database...
    ... Success!
    - Removing privileges on test database...
    ... Success!

    When the privilege tables are reloaded, it guarantees that all changes that have been up till now are successfully done.

    Reload privilege tables now? [Y/n] <-- ENTER
    ... Success!



    Cleaning up...

    The process is now completed, and your MySQL installation is now protected.

  • 3

    Installing Apache2
    Apache2 can be found in Fedora package, so we can install it in this way:

    yum install httpd

    You have to configure your system now in order to launch Apache at boot time…

    systemctl enable httpd.service

    Now start Apache:

    systemctl start httpd.service

    Now, write this on your browser http://192.168.0.100. By doing this, you will be able to see the Apache2 pageholder page:

  • 4

    Installing PHP5

    We can make PHP5 work in Apache2 through PHP-FPM and Apache's mod_fastcgi module. We install it according to the given procedure like this:

    yum install mod_fastcgi php-fpm

    Then open /etc/php.ini:
    vi /etc/php.ini

    In order to keep away from this type of error

    [08-Aug-2011 18:07:08] PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /usr/share/nginx/html/info.php on line 2

    ... in /var/log/php-fpm/www-error.log when you call a PHP script in your browser, you should set date.timezone in /etc/php.ini:

    [...]

    [Date]

    ; Defines the default timezone used by the date functions

    ; http://php.net/date.timezone

    date.timezone = "Europe/Berlin"

    [...]

    In order to find out accurate timezone for your system, run this:

    cat /etc/sysconfig/clock

    [root@server1 ~]# cat /etc/sysconfig/clock
    ZONE="Europe/Berlin"
    [root@server1 ~]#

    Now, mkake the system startup links for php-fpm and start it:

    systemctl enable php-fpm.service
    systemctl start php-fpm.service

    Now, restart Apache:

    systemctl restart httpd.service

Leave a Reply

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


two × = 10