Computersnyou

how to configure php5 with apache2 on ubuntu

Posted on  7/24/2014

This is second tutorial of LAMP installation series  , In this guide I will show you how to setup PHP with Apache2 , You can see first part here where I described How to install Apache web server .

NOTE : This tutorial was demonstrated on Ubuntu 14.04 trusty ( running as VM ).

php-logo
php-logo

Setup

sudo apt-get install php5 libapache2-mod-php5

Additional libs and extensions ( MySQL support etc)

sudo apt-get install php5-gd php5-mysql php5-cli php5-cgi libapache2-mod-fcgid apache2-suexec php-pear php-auth php5-mcrypt mcrypt php5-imagick imagemagick php5-curl php5-intl php5-memcache php5-memcached php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl 

now make sure php.conf and php.load is present in apache mods-enabled directories

there are many modules that require manual activation like mcrypt

for caching

sudo apt-get install php5-xcache

Lets enable rewrite and ssl mode

sudo a2enmod rewrite ssl 

testing php installation

configure apache to use index.php as index file ( if its exists then leave it like that only )

<IfModule mod_dir.c>
 DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>

Now restart Apache

sudo service apache2 restart

cd to your document root /var/www/html/ in my case , and create a index.php file
enter simple phpinfo(); function in index.php

<?php phpinfo(); ?>

and browse to http://yourserver/index.php
it will show you all php installation related info .

phpinfo
phpinfo

  • Home
  • About