Setting New PHP Development with Apricity OS & VirtualBox : Part 4 – Connecting Shared Folder, Setting PHP-FPM and Nginx

public_folder

Host Activities

Create document root folder

In last post I already write about PHP installation in Ubuntu 14.04 LTS server 32 bit. All those PHP must have their own place and I already create the folders in VirtualBox Host (Apricity OS) within public_html folder :

php52; for location of testing on php 5.2.17

php53; for location of testing on php 5.3.29

php54; for location of testing on php 5.4.33

php55; for location of testing on php 5.5.34

php56; location of testing on php 5.6.20

php70; location of testing on php 7.0.5

Each folder already has file info.php with this code :

<?php

phpinfo();

?>

Create Server Name

Server name will be use in nginx configuration. I need to map it in hosts file for each folder. Great. Continue with mapping the address (127.0.0.1) to a hostname.

sudo nano /etc/hosts

Add these lines (hostname for virtualhost) :

127.0.0.1   52dev
127.0.0.1   53dev
127.0.0.1   54dev
127.0.0.1   55dev
127.0.0.1   56dev
127.0.0.1   70dev

save.

Try ping sample hostname :

ping 52dev

PING 52dev (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.023 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.032 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.033 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.033 ms
64 bytes from localhost (127.0.0.1): icmp_seq=5 ttl=64 time=0.035 ms

Guest Activities

Login to ubuntu server with terminal.

Configure php-fpm on Ubuntu Server 14.04 32 bit

php-fpm for php 5.2.17

sudo cp /opt/source/php-5.2.17/sapi/cgi/fpm/init.d/php-fpm.in /etc/init.d/php-fpm5217

sudo chmod +x /etc/init.d/php-fpm5217

Change setting php-fpm5217

php_fpm_BIN=/opt/source/php-5.2.17/bin/php-cgi
php_fpm_CONF=/opt/source/php-5.2.17/etc/php-fpm.conf
php_fpm_PID=/opt/source/php-5.2.17/php-fpm.pid

save.

Configuration of php-fpm.conf

sudo nano /opt/source/php-5.2.17/etc/php-fpm.conf

<value name=”listen_address”>127.0.0.1:9001</value>
<value name=”owner”>www-data</value>
<value name=”group”>www-data</value>
Unix user of processes
<value name=”user”>www-data</value>
Unix group of processes
<value name=”group”>www-data</value>

save.

Set it for boot ready.

sudo update-rc.d php-fpm5217 defaults

Run the process

sudo service php-fpm5217 start

Check it :

ps ax | grep php

7989 ?        Ss     0:00 /opt/source/php-5.2.17/bin/php-cgi –fpm –fpm-config /opt/source/php-5.2.17/etc/php-fpm.conf
7991 ?        S      0:00 /opt/source/php-5.2.17/bin/php-cgi –fpm –fpm-config /opt/source/php-5.2.17/etc/php-fpm.conf
7992 ?        S      0:00 /opt/source/php-5.2.17/bin/php-cgi –fpm –fpm-config /opt/source/php-5.2.17/etc/php-fpm.conf
7993 ?        S      0:00 /opt/source/php-5.2.17/bin/php-cgi –fpm –fpm-config /opt/source/php-5.2.17/etc/php-fpm.conf
7994 ?        S      0:00 /opt/source/php-5.2.17/bin/php-cgi –fpm –fpm-config /opt/source/php-5.2.17/etc/php-fpm.conf
7995 ?        S      0:00 /opt/source/php-5.2.17/bin/php-cgi –fpm –fpm-config /opt/source/php-5.2.17/etc/php-fpm.conf

php-fpm for php 5.3.29

sudo cp /opt/source/php-5.3.29/etc/php-fpm.conf.default /opt/source/php-5.3.29/etc/php-fpm.conf

sudo nano /opt/source/php-5.3.29/etc/php-fpm.conf

Change port from 9000 to 9002

listen = 127.0.0.1:9002

Change user and group to www-data

user = www-data
group = www-data

save.

sudo cp /opt/source/php-5.3.29/sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm5329

sudo chmod +x /etc/init.d/php-fpm5329

sudo nano /etc/init.d/php-fpm5329

Change the content into ::

prefix=/usr/local
exec_prefix=/usr/local/bin

php_fpm_BIN=/opt/source/php-5.3.29/sbin/php-fpm
php_fpm_CONF=/opt/source/php-5.3.29/etc/php-fpm.conf
php_fpm_PID=/opt/source/php-5.3.29/var/run/php-fpm.pid

save.

Set it for boot ready.

sudo update-rc.d php-fpm5329 defaults

Run the process

sudo service php-fpm5329 start

Check it from ps :

1493 ?        Ss     0:00 php-fpm: master process (/opt/source/php-5.3.29/etc/php-fpm.conf)
1494 ?        S      0:00 php-fpm: pool www
1495 ?        S      0:00 php-fpm: pool www

php-fpm for php 5.4.33

sudo cp /opt/source/php-5.4.33/etc/php-fpm.conf.default /opt/source/php-5.4.33/etc/php-fpm.conf
sudo nano /opt/source/php-5.4.33/etc/php-fpm.conf

Change port from 9000 to 9003

listen = 127.0.0.1:9003

Change user and group to www-data

    user = www-data
group = www-data

save.

sudo cp /opt/source/php-5.4.33/sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm5433
sudo chmod +x /etc/init.d/php-fpm5433
sudo nano /etc/init.d/php-fpm5433

Change the content into ::

    prefix=/usr/local
exec_prefix=/usr/local/bin

php_fpm_BIN=/opt/source/php-5.4.33/sbin/php-fpm
php_fpm_CONF=/opt/source/php-5.4.33/etc/php-fpm.conf
php_fpm_PID=/opt/source/php-5.4.33/var/run/php-fpm.pid

save.

Set it for boot ready.

    sudo update-rc.d php-fpm5433 defaults

Run the process

    sudo service php-fpm5433 start

Check it from ps :

1602 ?        Ss     0:00 php-fpm: master process (/opt/source/php-5.4.33/etc/php-fpm.conf)
1603 ?        S      0:00 php-fpm: pool www
1604 ?        S      0:00 php-fpm: pool www

php-fpm for php 5.5.34

sudo cp /opt/source/php-5.5.34/etc/php-fpm.conf.default /opt/source/php-5.5.34/etc/php-fpm.conf
sudo nano /opt/source/php-5.5.34/etc/php-fpm.conf

Change port from 9000 to 9004

    listen = 127.0.0.1:9004

Change user and group to www-data

    user = www-data
group = www-data

save.

    sudo cp /opt/source/php-5.5.34/sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm5534
sudo chmod +x /etc/init.d/php-fpm5534
sudo nano /etc/init.d/php-fpm5534

Change the content into ::

 prefix=/usr/local
exec_prefix=/usr/local/bin

php_fpm_BIN=/opt/source/php-5.5.34/sbin/php-fpm
php_fpm_CONF=/opt/source/php-5.5.34/etc/php-fpm.conf
php_fpm_PID=/opt/source/php-5.5.34/var/run/php-fpm.pid

save.

Set it for boot ready.

    sudo update-rc.d php-fpm5534 defaults

Run the process

    sudo service php-fpm5534 start

Check it from ps :

1656 ?        Ss     0:00 php-fpm: master process (/opt/source/php-5.5.34/etc/php-fpm.conf)
1657 ?        S      0:00 php-fpm: pool www
1658 ?        S      0:00 php-fpm: pool www

php-fpm for php 5.6.20

sudo cp /opt/source/php-5.6.20/etc/php-fpm.conf.default /opt/source/php-5.6.20/etc/php-fpm.conf
sudo nano /opt/source/php-5.6.20/etc/php-fpm.conf

Change port from 9000 to 9005

    listen = 127.0.0.1:9005

Change user and group to www-data

    user = www-data
group = www-data

save.

    sudo cp /opt/source/php-5.6.20/sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm5620
sudo chmod +x /etc/init.d/php-fpm5620
sudo nano /etc/init.d/php-fpm5620

Change the content into ::

    prefix=/usr/local
exec_prefix=/usr/local/bin

php_fpm_BIN=/opt/source/php-5.6.20/sbin/php-fpm
php_fpm_CONF=/opt/source/php-5.6.20/etc/php-fpm.conf
php_fpm_PID=/opt/source/php-5.6.20/var/run/php-fpm.pid

save.

Set it for boot ready.

    sudo update-rc.d php-fpm5620 defaults

Run the process

    sudo service php-fpm5620 start

Check it from ps :

1680 ?        Ss     0:00 php-fpm: master process (/opt/source/php-5.6.20/etc/php-fpm.conf)
1681 ?        S      0:00 php-fpm: pool www
1682 ?        S      0:00 php-fpm: pool www

php-fpm for php 7.0.5

sudo cp /opt/source/php-7.0.5/etc/php-fpm.conf.default /opt/source/php-7.0.5/etc/php-fpm.conf
sudo nano /opt/source/php-7.0.5/etc/php-fpm.conf

pid = run/php-fpm.pid

remove ; sign

save.

sudo cp /opt/source/php-7.0.5/etc/php-fpm.d/www.conf.default /opt/source/php-7.0.5/etc/php-fpm.d/www.conf
sudo nano /opt/source/php-7.0.5/etc/php-fpm.d/www.conf

Change port from 9000 to 9006

    listen = 127.0.0.1:9006

change user and group to www-data

    user = www-data
group = www-data

save.

sudo cp /opt/source/php-7.0.5/sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm705
sudo chmod +x /etc/init.d/php-fpm705

sudo nano /etc/init.d/php-fpm705

change the content into ::

    prefix=/usr/local
exec_prefix=/usr/local/bin

php_fpm_BIN=/opt/source/php-7.0.5/sbin/php-fpm
php_fpm_CONF=/opt/source/php-7.0.5/etc/php-fpm.conf
php_fpm_PID=/opt/source/php-7.0.5/var/run/php-fpm.pid

save.

sudo update-rc.d php-fpm705 defaults

Start

/etc/init.d/php-fpm705 start

Edit Nginx.conf

sudo nano /etc/nginx/sites-enabled/default

Add these lines :

    #php 5.2.17

server{
listen 80;
server_name 52dev;

root /media/sf_public_html/php52;

location / {
index index.php;

autoindex on;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

# eof php 5.2.17

#php 5.3.29

server{
listen 80;
server_name 53dev;

root /media/sf_public_html/php53;

location / {
index index.php;

autoindex on;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

# eof php 5.3.29

#php 5.4.33

server{
listen 80;
server_name 54dev;

root /media/sf_public_html/php54;

location / {
index index.php;

autoindex on;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9003;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

# eof php 5.4.33

#php 5.5.34

server{
listen 80;
server_name 55dev;

root /media/sf_public_html/php55;

location / {
index index.php;

autoindex on;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9004;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

# eof php 5.4.34

#php 5.6.20

server{
listen 80;
server_name 56dev;

root /media/sf_public_html/php56;

location / {
index index.php;

autoindex on;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9005; #(You can change it to your private IP in the future)
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

# eof php 5.6.20

#php 7.0.5

server{
listen 80;
server_name 70dev;

root /media/sf_public_html/php70;

location / {
index index.php;

autoindex on;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9006; #(You can change it to your private IP in the future)
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
# eof php 7.0.5

save.