UK WEB HOSTING FORUM FOR DISCUSSION ON WEB HOSTING SERVICE AND SUPPORT
LINUX HOSTING WINDOWS HOSTING PACKAGES SHOPPING CART OSCOMMERCE ZEN CART AGORA
ECOMMERCE HOSTING ASP MSSQL FRONTPAGE HOSTING PHP MYSQL HOSTING DISCUSSION FORUM
CPANEL RESELLER HOSTING DEDICATED SERVER VPS HOSTING PLESK VIRTUOZZO
Quick Search
Your forum announcement here!

  UK Web Hosting | Dedicated Server Windows and Linux VPS Forum > Technical Support > VPS Hosting - Virtual Private Servers

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 31-01-2008, 20:40
mephisto's Avatar
Senior Member
 
Join Date: Feb 2007
Location: Darlington
Posts: 101
Send a message via ICQ to mephisto Send a message via MSN to mephisto
Default Compiling PHP from Source on your linux [url=http://www.eukhost.com/vps-hosting.php]VPS Hosting[/url]

Compiling PHP from source code can achieve many things, more efficient instance of php, reducing the footprint by only having what you need etc. So here is a walk through of how to do just that.

First of you need some packages that will do the configuration, compiling etc. I use Debian for my OS, so the packaging manager is apt which would be the same for Ubuntu, but for CentOS and Fedora you'll need to use yum. The package names with yum maybe slightly different than for apt.

Code:
$ apt-get install gcc g++ make autoconf patch flex
You could just start compiling from here, but there are a few extra steps which will make php compile better suited to your hardware. You first need to find out what type of CPU is installed, which you can see by looking at /proc/cpuinfo

Code:
$ cat /proc/cpuinfo | grep ^model\ name
model name	: Intel(R) Core(TM)2 Quad CPU    Q6600  @ 2.40GHz
model name	: Intel(R) Core(TM)2 Quad CPU    Q6600  @ 2.40GHz
model name	: Intel(R) Core(TM)2 Quad CPU    Q6600  @ 2.40GHz
model name	: Intel(R) Core(TM)2 Quad CPU    Q6600  @ 2.40GHz
This tells you that there is an Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz installed and that there are four of them, based on your CPU you need to set to environment variables. There is a handy page for gentoo which applies the same here [ur]http://gentoo-wiki.com/Safe_Cflags[/url].

The environment variables for my VPS Hosting are

Code:
CHOST="i686-pc-linux-gnu"
CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
You can set these using export in your current shell session, or if you want to keep them for every session add them to /etc/profile for all users and /root/.bashrc for root.

There is one last thing to do make the compiling faster, make accepts an option to do parallel jobs -j#. This is personal preference, but I set mine to 2 more than the number of CPU's, so -j6. So to set this I create an alias, again for this session on the command line is fine, but for every session edit the same files as for environment variables.

Code:
alias make='make -j6'
Now you can actually get into compiling.

Download php from www.php.net, currently version 5.2.5, extract the source code and change into the new directory.

Code:
$ wget http://uk3.php.net/get/php-5.2.5.tar.bz2/from/uk.php.net/mirror
$ tar jxf php-5.2.5.tar.bz2
$ cd php-5.2.5
Inside this directory is a script which sets up your configuration, called configure. If you run that with --help as a parameter you will see the available options to you for compiling. To keep this simple, I will give an example for compiling for apache2, mysql, gd and soap, to add in more it's pretty much more of the same.

Here I will be installing php into /usr/local/php, pear directory as /usr/local/php/pear and php.ini to be located in /etc/php, which is done with the following options.

Code:
--prefix=/usr/local/php --with-pear=/usr/local/php/pear --with-config-file-path=/etc/php
Now you need to find apache extension tool, apxs, which can be located with the which command

Code:
$ which apxs
/usr/sbin/apxs
so to add apache2 support, the following option is used

Code:
--with-apxs2=/usr/sbin/apxs
For mysql, you need to know where MySQL Server libraries are installed (the lib/mysql directory), which is normally in /usr, but you can check this with mysql_config

Code:
$ which mysql_config
$ /usr/bin/mysql_config 
Usage: /usr/bin/mysql_config [OPTIONS]
Options:
        --cflags         [-I/usr/include/mysql]
        --include        [-I/usr/include/mysql]
        --libs           [-L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm]
        --libs_r         [-L/usr/lib/mysql -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread]
        --socket         [/tmp/mysql.sock]
        --port           [3306]
        --version        [5.0.51]
        --libmysqld-libs [-L/usr/lib/mysql -lmysqld -lz -lpthread -lcrypt -lnsl -lm -lpthread -lrt]
You can see that the libraries are installed in /usr. So now the following commands will add mysql, mysqli and pdo support into php

Code:
--with-mysql=/usr --with-mysqli=/usr/bin/mysql_config --with-pdo-mysql=/usr
After that, it's just adding gd, which fortunately is bundled with php source code, so it just need to install the header files for png and jpeg support. You can add more image types, [ur]http://www.php.net/gd[/url] explains further options.

Code:
$ apt-get install libpng12-dev libjpeg62-dev
This will install the headers into /usr, so now the following options will add gd support.

Code:
--with-gd --with-png-dir=/usr --with-jpeg-dir=/usr
Soap depends on libxml, so you first need to install the library.
Code:
$ apt-get install libxml-dev
The options to include soap is
Code:
--enable-soap
So to configure php with all these options, you run

Code:
./configure --prefix=/usr/local/php --with-pear=/usr/local/php/pear --with-config-file-path=/etc/php \
--with-apxs2=/usr/sbin/apxs \
--with-mysql=/usr --with-mysqli=/usr/bin/mysql_config --with-pdo-mysql=/usr \
--enable-soap
Once you have ran this command, you should see something like

Code:
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.
Now you can compile and install php

Code:
$ make
$ make install
This should automatically configure apache to use php, but to make sure, check your httpd.conf file has the following

Code:
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
The last line is optional, having it will make .phps files render as code with syntax high-lighting in your browser.

Then you just need to restart apache

Code:
$ apachectl restart
Hope this is helpful you all of you.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-02-2008, 11:46
eUK-Martin's Avatar
Windows System Administrator
 
Join Date: Nov 2005
Location: Earth
Posts: 462
Default

This is a great contribution. I am sure that this is going to be helpful to many around. Great work
__________________
Martin
Windows System Admin.


Windows VPS Hosting - Windows Dedicated Server - Web Hosting Tutorials

Email :: windows @ eUKhost.com AND support @ eUKhost.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-02-2008, 09:37
DavidAllen's Avatar
Premium Member
 
Join Date: Jan 2007
Location: Amersham
Posts: 362
Send a message via MSN to DavidAllen Send a message via Skype™ to DavidAllen
Default

This is brilliant - Thanks. As a 'newbie' to VPS Hosting hosting I'm not used to shell access and using these 'odd' unix commands. But this is going to help a lot to streamline my php intalation - the default one has just about everything included. Some of which I'm sure I don't need.
Thanks
__________________
David Allen - www.serina.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 16:58.

 

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by Web Hosting 3.1.0
Copyright © 2001-2008, eUKhost.com. All rights reserved.

 
Site Map

VPS Hosting
VPS Hosting plans

Dedicated Server Hosting
Dedicated Server plans

Business Web Hosting
100% uptime Hosting

Cpanel Hosting
cPanel Shared Hosting

Reseller Hosting
Reseller Web Hosting

Windows Hosting
Windows Shared Hosting

Windows VPS

Windows VPS Hosting

Semi Dedicated Servers
Semi-Dedicated Hosting

Dedicated Server Mirroring
Dedicated Server Mirroring

Webhosting Knowledgebase
Frequently asked Questions

Web Hosting Blog
eUKhost Blog

Web Hosting Support
Support Helpdesk

UK Data Center
eUKhost Datacenter

Web Hosting Forum
eUKhost Forum

Support Tutorials
Online Flash Tutorials

Offsite Back-up Plans
Remote Backup Service

Customer Testimonials
eUK Customer Testimonials


knowledgebase articles

eUKhost.com Services

Pre-Sales Questions
Pre-sales FAQ's

Domain Names
Domain registration FAQ's

cPanel Hosting
cPanel Hosting FAQ's

Windows Web Hosting
Plesk Control Panel

Reseller Hosting
Reseller Hosting FAQ's

VPS Hosting
Virtual Private Server

Semi-Dedicated Servers
Semi-Dedicated FAQ's

Dedicated Servers
Dedicated Server Hosting


popular blog categories


Web Hosting
Website Hosting articles

UK Web Hosting
UK Hosting articles

Dedicated Server Hosting
Dedicated Server guidelines

VPS Hosting
VPS hosting articles

cPanel Hosting
cPanel Hosting articles

Linux Operating System
Linux Operating techniques

Windows Web Hosting
Windows plesk articles

Web Hosting
Web Hosting Service