Installing PHP on Fedora

Now that apache is running on your Fedora server you might want to add PHP support to it. Here's how.

Adding mod_php

Once you have a basic apache installation in place, it might behoove you to install any modules and dependencies you know you'll need as well. For most users this will at least mean installing PHP. In this article we walk you through that process.

Install the PHP base

Let's start with an install of the basic PHP package:

sudo yum install php

Yum will want to nab some files to go with it, like "php-common", which is good.

More PHP libraries

Your web application may require more than the basic PHP installation to function. In that case you'll want to find any required PHP libraries in the yum repositories and install them.

To see what PHP modules are available try a:

yum search php-

Note the "-" at the end of "php". This will show any packages that start with "php5-", along with a brief description.

If you want to get more information about one of the available packages, use aptitude's "info" argument to get details:

yum info php-mysql

The output will include a longer description of the package, the version of the library in the package, and more.

Once you've decided what extra PHP modules you need to install (if any), run "sudo yum install" with a list of modules as the arguments. As an example, here's a command to install several commonly-used PHP libraries at once (handy if you aren't sure what you'll need):

sudo yum install php-mysql php-devel php-gd php-pecl-imagick php-mcrypt php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml

The php.ini file

You may need to make changes to your php.ini file for your application. If so, you can find the php.ini used by the apache module here:


The initialization files for additional PHP modules you may have installed should usually show up in this directory:


Restart apache

With PHP and its extras installed, you'll need to restart apache to get it to load the new module:

sudo /usr/sbin/apachectl graceful


With that, you have not just an apache web server, but one that runs PHP. Neat! Your work isn't done, however. In the next article we'll discuss apache's configuration files and where to find them, so you can start customizing apache for your slice.

  • -- Jered
Want to comment?

(not made public)


(use plain text or Markdown syntax)