Install nginx, php-fpm with oracle on Debian Wheezy

Install Oracle instant client

First of all, download those both files from the official Oracle website:

Put them on your server, and convert them to .deb files with alien for example and install :

apt-get install alien

# Converting to deb
alien -d oracle-instantclient11.2-basic-
alien -d oracle-instantclient11.2-devel- 

# Installing

dpkg -i oracle-instantclient11.2-devel_11.
dpkg -i oracle-instantclient11.2-basic_11.

It will take care of linking the specific includes files and copy them to /usr/include/oracle/{11.2}/client{64}.

11.2 might differ according to your instantclient version. Also, if you’re on an amd64 debian the client is in the client64 instead of the client directory.

Now we will build some oracle profile file that will be required later. Write in /etc/profile.d/

#This is the lib path were the instantclient is installed
#This locates C headers from your instantclient
#I've never had trouble with that but it might save you a couple debugging hours
#This is really important as that php-fpm does not set this variable comparing to apache that does (1)


(1) OCIEnvNlsCreate: Check the character set is valid and that PHP has access to Oracle libraries and NLS data

Now add this to your own ~/.profile:

Compile php

First thing to do is to get the proper dependencies that goes with your later configure options. Those are the dependencies I use from my other post on the subject :

Download the wanted php version, extract it and configure. My configure options are (you can list them all with ./configure --help):

./configure --enable-fpm --with-oci8 --with-pdo-oci
#non-relevent part to remember:
 --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-dba --enable-exif --enable-ftp --with-gd --with-gettext --with-kerberos --enable-mbstring --with-mcrypt --with-openssl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-wddx --enable-zip --with-zlib --with-xsl --with-mysql --with-mysqli --with-pgsql --with-pdo-mysql --with-pdo-pgsql 

Then make and sudo make install.


After the compilation, php-fpm should be installed. I had not the init.d script in the right directory (check first) but it’s available in PATH_TO_COMPILED_PHP/sapi/fpm/init.d.php-fpm.

After moving it to /etc/init.d/php-fpm, edit it and add:

. /etc/profile.d/

Now we can add the execute rights and start it on boot:

sudo chmod +x /etc/init.d/php-fpm
sudo update-rc.d php-fpm defaults

Install nginx

This is only a very basic apt-get install nginx.

Here comes the configuration for php-fpm, first of all you’ll need to add a pool in /etc/php5/fpm/pool.d/mypool.conf (2):

user = www-data
group = www-data
listen = /var/run/php5-fpm.sock
listen.owner = www-data = www-data
listen.mode = 0660

(2) this path can be configured at the end of the /usr/local/etc/php-fpm.conf

Then, do your own nginx virtual host or edit the default to have it look like this:

server {
	listen   80; ## listen for ipv4; this line is default and implied

	root /usr/share/nginx/www;
	index index.html index.htm index.php;

	server_name localhost;

	location / {
               try_files $uri $uri/ index.php;

	location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

That’s it. Start service start nginx and service start php-fpm and test a basic phpinfo(); file!