Installing Apache2 With PHP5 And MySQL Support On Fedora 17 (LAMP) - Page 2

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Tue, 2012-06-19 19:56. ::

5 Testing PHP5 / Getting Details About Your PHP5 Installation

The document root of the default web site is /var/www/html. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.

vi /var/www/html/info.php

<?php
phpinfo();
?>

Now we call that file in a browser (e.g. http://192.168.0.100/info.php):

As you see, PHP5 is working, and it's working through the Apache 2.0 Handler, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5. MySQL is not listed there which means we don't have MySQL support in PHP5 yet.

 

6 Getting MySQL Support In PHP5

To get MySQL support in PHP, we can install the php-mysql package. It's a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:

yum search php

Pick the ones you need and install them like this:

yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-magickwand php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy

APC is a free and open PHP opcode cacher for caching and optimizing PHP intermediate code. It's similar to other PHP opcode cachers, such as eAccelerator and Xcache. It is strongly recommended to have one of these installed to speed up your PHP page.

APC can be installed as follows:

yum install php-pecl-apc

Now restart Apache2:

systemctl restart httpd.service

Now reload http://192.168.0.100/info.php in your browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module:

 

7 phpMyAdmin

phpMyAdmin is a web interface through which you can manage your MySQL databases.

phpMyAdmin can be installed as follows:

yum install phpmyadmin

Now we configure phpMyAdmin. We change the Apache configuration so that phpMyAdmin allows connections not just from localhost (by commenting out the <Directory /usr/share/phpMyAdmin/> stanza):

vi /etc/httpd/conf.d/phpMyAdmin.conf

# phpMyAdmin - Web based MySQL browser written in php
#
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

#<Directory /usr/share/phpMyAdmin/>
#   <IfModule mod_authz_core.c>
#     # Apache 2.4
#     <RequireAny>
#       Require ip 127.0.0.1
#       Require ip ::1
#     </RequireAny>
#   </IfModule>
#   <IfModule !mod_authz_core.c>
#     # Apache 2.2
#     Order Deny,Allow
#     Deny from All
#     Allow from 127.0.0.1
#     Allow from ::1
#   </IfModule>
#</Directory>

<Directory /usr/share/phpMyAdmin/setup/>
   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

# These directories do not require access over HTTP - taken from the original
# phpMyAdmin upstream tarball
#
<Directory /usr/share/phpMyAdmin/libraries/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/lib/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/frames/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

# This configuration prevents mod_security at phpMyAdmin directories from
# filtering SQL etc.  This may break your mod_security implementation.
#
#<IfModule mod_security.c>
#    <Directory /usr/share/phpMyAdmin/>
#        SecRuleInheritance Off
#    </Directory>
#</IfModule>

Restart Apache:

systemctl restart httpd.service

Afterwards, you can access phpMyAdmin under http://192.168.0.100/phpmyadmin/:

 

8 Links


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Thu, 2013-07-04 11:57.
Thanks man.....perfect!
Submitted by Bryan Wolfford (not registered) on Sat, 2012-12-01 23:11.

At the very end of this tutorial, when you load .../phpmyadmin/ you will be prompted for a username and password. If you followed this tutorial verbatim, this is the mysql user 'root' (not the linux root)  and the password that you set up earlier in the process.

 

Submitted by Jamal (not registered) on Sat, 2012-10-27 08:43.

Thank you.

every thing worked well!!!

Submitted by Gautam (not registered) on Sun, 2012-09-30 12:59.
Awesome tutorial, i didn;t get stuck even once! Great job and thanks a ton!
Submitted by George (not registered) on Sat, 2012-09-29 23:36.

Great job on this tutorial. It worked perfectly for me from the first command. Now I am at the phpmyadmin and can continue on my work. Really nice job!

The only small request is to add additional information about perl and python configuration also on Fedora. I think in lamp p sometimes stands for those other languages and you may have an even more complete tutorial by adding those.

Thanks again.

Submitted by Chris Thain (not registered) on Wed, 2012-08-15 17:58.

Great article, thank you! I followed the instructions and everything worked very well indeed. A few tweaks to the configuration files and I was off to the races.

I will add one comment for anyone who may encounter the same problem I did: I use mysqli_result::fetch_all() in one of my applications and after installing PHP and MySQL following these instructions my application stopped working. I got the following error:

Fatal error: Call to undefined method mysqli_result::fetch_all()

The reason is that mysqli_result::fetch_all() is only available for the MySQL Native Driver so if you want/need to use mysqli_result::fetch_all() then you must install php-mysqlnd ( yum install php-mysqlnd ) rather than php-mysql.

Submitted by AgR (not registered) on Thu, 2012-07-26 02:47.

Good explication :D :D :D

Thanks!!

Submitted by Anonymous (not registered) on Wed, 2012-06-27 19:03.

Thank you for the excellent lamp tutorial.

It was easy to follow and everything worked.