Here I will explain how to install php 5.5 under debian based system and configure apache and nginx webservers to get php support.
mkdir /opt/source/
cd /opt/source/
Download the latest php package from the below link,
wget http://ar2.php.net/distributions/php-5.5.7.tar.gz
Now install the dependencies,
apt-get install libexpat1-dev libssl-dev libjpeg62-dev libpng12-dev libt1-dev libfreetype6-dev fontconfig libxpm-dev libxml2-dev libfontconfig1-dev
Download and install curl package from this link,
wget http://curl.haxx.se/download/curl-7.34.0.tar.gz
tar -zxvf curl-7.34.0.tar.gz
cd curl-7.34.0
./configure
make
make install
Now install php,
tar -zxvf php-5.5.7.tar.gz
cd php-5.5.7
./configure --prefix=/usr --with-apxs2=/usr/local/bin/apxs --with-config-file-path=/etc --with-openssl=/usr/local/ssl/ --with-pear --with-zlib=/usr --enable-bcmath --enable-ftp --with-gd --with-jpeg-dir=/usr --enable-gd-native-ttf --with-png-dir=/usr --with-gettext --with-mysql=/usr/local --with-mysql-sock=/tmp/mysql.sock --sysconfdir=/etc --with-curl=/usr/local/ --enable-gd-native-ttf --with-freetype-dir=/usr --with-t1lib=/usr --enable-soap --enable-mbstring --with-mysqli=/usr/local/bin/mysql_config --with-pdo-mysql=/usr/local/bin/mysql_config -enable-fpm --with-fpm-user=apache --with-fpm-group=apache
make
make install
verify php
~# php -v
PHP 5.5.7 (cli) (built: Dec 24 2013 00:32:28)
Copy the configuration file,
cp -vf /opt/source/php-5.5.7/php.ini-production /etc/php.ini
~# php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
For apache to get php support, The following dso module should be loaded in apache configuration file,
LoadModule php5_module /usr/local/modules/libphp5.so
Edit httpd.conf to add this line,
AddType application/x-httpd-php .php
apachectl restart
Check by pointing your url to info.php,
vim info.php
<?php
phpinfo();
?>
For nginx to run php scripts,
Here we are using php-fpm support, for that php should be installed with fpm (Fast Process Manager) support.
cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf
vim /usr/local/etc/php-fpm.conf
user = apache
group = apache
pm = dynamic
pm.max_children = 50
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 35
listen = /var/run/php5-fpm.sock (This socket is used by nginx for php support)
Now start and enable socket listening in startup script,
cd /opt/source/php-5.5.7/sapi/fpm/
cp init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
update-rc.d -f php-fpm defaults
/etc/init.d/php-fpm start
nginx-installation-on-linux
Nginx should be configured as follows,
vim /etc/nginx/nginx.conf
server {
server_name test.com www.test.com;
listen 80;
access_log /var/www/logs/nginx/test.log;
#include /etc/nginx/localserve.conf;
root /var/www/test.com/;
index index.html;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}
Restart nginx,
/etc/init.d/nginx restart
Check by pointing your url to info.php,
vim info.php
<?php
phpinfo();
?>
Thanks for reading,
Cheers/-
mkdir /opt/source/
cd /opt/source/
Download the latest php package from the below link,
wget http://ar2.php.net/distributions/php-5.5.7.tar.gz
Now install the dependencies,
apt-get install libexpat1-dev libssl-dev libjpeg62-dev libpng12-dev libt1-dev libfreetype6-dev fontconfig libxpm-dev libxml2-dev libfontconfig1-dev
Download and install curl package from this link,
wget http://curl.haxx.se/download/curl-7.34.0.tar.gz
tar -zxvf curl-7.34.0.tar.gz
cd curl-7.34.0
./configure
make
make install
Now install php,
tar -zxvf php-5.5.7.tar.gz
cd php-5.5.7
./configure --prefix=/usr --with-apxs2=/usr/local/bin/apxs --with-config-file-path=/etc --with-openssl=/usr/local/ssl/ --with-pear --with-zlib=/usr --enable-bcmath --enable-ftp --with-gd --with-jpeg-dir=/usr --enable-gd-native-ttf --with-png-dir=/usr --with-gettext --with-mysql=/usr/local --with-mysql-sock=/tmp/mysql.sock --sysconfdir=/etc --with-curl=/usr/local/ --enable-gd-native-ttf --with-freetype-dir=/usr --with-t1lib=/usr --enable-soap --enable-mbstring --with-mysqli=/usr/local/bin/mysql_config --with-pdo-mysql=/usr/local/bin/mysql_config -enable-fpm --with-fpm-user=apache --with-fpm-group=apache
make
make install
verify php
~# php -v
PHP 5.5.7 (cli) (built: Dec 24 2013 00:32:28)
Copy the configuration file,
cp -vf /opt/source/php-5.5.7/php.ini-production /etc/php.ini
~# php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
For apache to get php support, The following dso module should be loaded in apache configuration file,
LoadModule php5_module /usr/local/modules/libphp5.so
Edit httpd.conf to add this line,
AddType application/x-httpd-php .php
apachectl restart
Check by pointing your url to info.php,
vim info.php
<?php
phpinfo();
?>
For nginx to run php scripts,
Here we are using php-fpm support, for that php should be installed with fpm (Fast Process Manager) support.
cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf
vim /usr/local/etc/php-fpm.conf
user = apache
group = apache
pm = dynamic
pm.max_children = 50
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 35
listen = /var/run/php5-fpm.sock (This socket is used by nginx for php support)
Now start and enable socket listening in startup script,
cd /opt/source/php-5.5.7/sapi/fpm/
cp init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
update-rc.d -f php-fpm defaults
/etc/init.d/php-fpm start
nginx-installation-on-linux
Nginx should be configured as follows,
vim /etc/nginx/nginx.conf
server {
server_name test.com www.test.com;
listen 80;
access_log /var/www/logs/nginx/test.log;
#include /etc/nginx/localserve.conf;
root /var/www/test.com/;
index index.html;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}
Restart nginx,
/etc/init.d/nginx restart
Check by pointing your url to info.php,
vim info.php
<?php
phpinfo();
?>
Thanks for reading,
Cheers/-
No comments:
Post a Comment