Hardware Secrets
Home | Audio | Case | Cooling | CPU | Input | Memory | Mobile | Motherboard | Networking | Power | Storage | Video | Other
Content
Articles
First Look
News
Reviews
Tutorials
Main Menu
About Us
Compare Prices
Datasheets
Dictionary
Download
Drivers
Forums
Gabriel's Blog
Links
Manufacturer Finder
Newsletter
On The Web
RSS Feed
Test Your Skills
Newsletter
Subscribe today!
Search




Recommended Book
Build Your Own Wi-Fi Network (Build Your Own...(McGraw))
By
McGraw-Hill/OsborneMedia
Price: $0.32

Home » Networking
How to Build a Web Server with PHP 5 and MySQL 5 Support
Author: Gabriel Torres
Type: Tutorials Last Updated: April 19, 2007
Page: 4 of 5
$ Check REAL-TIME pricing for Linksys WRT54GS Wireless Router $
eBay: $43.10 TigerDirect.com: $59.99
TECHONWEB: $56.41 P.C. Richard & Son: $49.99
CompUSA.com: $59.99 Amazon: $73.99

Configuring and Installing PHP 5

Now it is time for downloading, configuring and installing PHP 5. You must install MySQL 5 client BEFORE configuring PHP 5, otherwise you will get a series of error messages. So if you came directly to this page, please go back to the previous page and follow the steps described there.

Before compiling PHP 5, you need to install several dependencies, if they aren’t already installed. They are Zlib, Jpeg and Png. They are required if you want to run GD, which is a module for editing images on the fly. We recommend enabling GD support, thus we will install these three items:

For zlib, download its latest version at http://www.zlib.net/ and do:

cd /root
wget http://www.zlib.net/zlib-1.2.3.tar.gz
tar -xvzf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/usr/lib
make
make install

For png support, download Libpng at http://www.libpng.org/pub/png/libpng.html and do:

cd /root
wget http://prdownloads.sourceforge.net/libpng/libpng-1.2.16.tar.gz?download
tar -xvzf libpng-1.2.16.tar.gz
cd libpng-1.2.16
./configure --prefix=/usr/lib
make
make install

For Jpeg support:

cd /root
wget ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz
tar -xvzf jpegsrc.v6b.tar.gz
cd jpegsrc.v6b
./configure --prefix=/usr/lib
make
make install

These are the support libraries for GD. On our installation on Debian, we needed to install the following libraries to solve dependency errors while compiling PHP 5:

Apt-get install libxml2
Apt-get install libxml2-dev
Apt-get install libxml2-utils
apt-get install autoconf
dpkg -s autoconf

Now it is time for downloading, configuring and compiling PHP. PHP can be downloaded from http://www.php.net/downloads.php. The step-by-step would be:

cd /root
wget http://www.php.net/get/php-5.2.1.tar.gz/from/us2.php.net/mirror
tar -xvzf php-5.2.1.tar.gz
cd php-5.2.1
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/bin/mysql_config --with-mysqli=/usr/local/bin/mysql_config --prefix=/usr/local/apache2/php --with-config-file-path=/usr/local/apache2/php --with-zlib-dir=/usr/lib --with-gd --with-imap=/usr/local/imap-2004a --with-xml --enable-shmop --with-zlib --with-png --with-jpeg-dir=/usr/lib --enable-gd-native-ttf --enable-exif --with-kerberos --with-imap-ssl
make
make install
cp php.ini-dist /usr/local/apache2/php/php.ini

Of course this configuration is the one we needed based on the PHP scripts we were going to run; your configure line can be different.

The major trick here are the --with-mysql and --with-mysqli parameters. They must tell configure script the location of mysql_config file: it can be at /usr/local/bin/ or at /usr/local/mysql/bin, depending wether you installed only MySQL 5 client or both client and server, respectively. The major problem with PHP 5 configuration with MySQL 5 support resides on these two parameters. If they are misconfigured, you will get errors such as:

configure: error: Cannot find MySQL header files under /usr/bin/mysql.
Note that the MySQL client library is not bundled anymore.

or

configure: error: mysql configure failed. Please check config.log for
more information.

Notice that php was installed at /usr/local/apache2/php.

Now you need to configure httpd.conf file to add PHP 5 support. Run vi /usr/local/apache2/conf/httpd.conf and look for the line below:

LoadModule php4_module        modules/libphp4.so

If it exists, please add a # in front of it. Now check if the line below exists and if it is uncommented. If it doesn’t exist, please add it:

LoadModule php5_module        modules/libphp5.so

Also look for the following line:

AddHandler php-script   php

If it exists, add a # in front of it. Now check if the line below exists and if it is uncommented. If it doesn’t exist, please add it:

AddHandler php5-script php

Now look for the following line and if it is uncommented. If it doesn’t exist, add it:

AddType text/html       php

Exit vi (Esc wq <Enter>) and restart Apache with the following command:

/usr/local/apache2/bin/apachectl restart

Now you need to check if you installation was successful by creating a file called phpinfo.php with the following contents:

<?
Echo phpinfo();
?>

Put it at the root directory of your webserver (e.g. /www/your-website) and call it with your web browser (http://www.your-website.com/phpinfo.php). Of course you must have configured httpd.conf first in order to make Apache to know which directory it should use for your website. Even if you don’t have an URL pointing to your server IP address yet or if the server you are building is a local server on your own network, you can configure Apache (at its httpd.conf file) to answer requests based on the server IP address, thus you can use http://192.168.0.2/phpinfo.php (where 192.168.0.2 is obviously our web server IP address).

You should get a detailed description of how PHP is configured on your server. If you get this screen, congratulations, Apache and PHP are up and running. You should look if the following sessions exist on this page (below “Configuration”) and if they are enabled: mysql (“MySQL Support: Enabled” and if “Client API version” is the same as you installed, 5.0.21 on the example we used on our tutorial), mysqli (“MySQLi Support: Enabled” and if “Client library version” is the same as you installed, 5.0.37 on the example we used on our tutorial) and GD (“GD Support: Enabled”). If you can’t find them, check the configuration and installation process.

If everything is fine with your Apache and PHP 5 with MySQL 5 support installation, you can go ahead to the final step, which is installing a PHP cache and optimizer, which is a module that will save CPU resources from your web server, improving its performance.

Pages (5): « 1 2 3 [4] 5 »
Print Version | Send to Friend | | Bookmark Article | Comments (7)

Related Content
  • All Opteron Models
  • All Xeon Models

  • RSSLatest News
    Titan Launches Cooler for Intel Core i7 CPUs
    November 20, 2008 - 4:47 PM PST
    Thermaltake Launches Fanless 330 VGA Cooler
    November 19, 2008 - 6:17 PM PST
    Mushkin Launches Triple-Channel DDR3 kits for Core i7 Processors
    November 18, 2008 - 6:43 PM PST
    Manufacturers Launch Intel X58 Motherboards
    November 18, 2008 - 6:11 PM PST
    Intel Launches Core i7 Processors
    November 18, 2008 - 6:02 PM PST
    Scythe Kama Panel 3.5” Multifunctional Panel
    November 17, 2008 - 6:50 PM PST
    AMD Launches 45-nm Opteron Processors
    November 14, 2008 - 4:34 PM PST
    Noctua Presents Cooler for Intel Core i7 CPUs
    November 12, 2008 - 11:37 AM PST
    Thermalright Launches Ultra-120 eXtreme Cooler
    November 11, 2008 - 4:04 AM PST
    PowerColor Launches Water-Cooling Ready Radeon HD 4870
    November 10, 2008 - 4:22 PM PST
    .:: More News ::.

    RSSLatest Content
    Seventeam ST-550P-AG Power Supply Review
    Logitech QuickCam Pro 9000 Review
    GeForce GTX 260 with 216 cores Video Card Review
    Laptop Design: What are some ways that form can enhance function?
    Panasonic Link-to-Cell Phone System Review
    Topower TOP-1100P10 Power Supply Review
    Gigabyte MA78GM-S2H Motherboard
    OCZ Neural Impulse Actuator Review
    OCZ EliteXStream 1000 W Power Supply Review
    Everything You Need to Know About Megapixels
    Battery Life: How Long Does a Battery Need to Last?
    Corsair HX1000W Power Supply Review
    AMD ATI Chips Comparison Table
    What is the ideal size for a notebook?
    ASUS P6T Deluxe OC Palm Edition Motherboard

    Our Most Popular Articles
    Maximum CPU Temperature
    822,284 views
    nVidia Chips Comparison Table
    512,387 views
    AMD ATI Chips Comparison Table
    451,232 views
    How to Find Out Your Motherboard Manufacturer and Model
    432,800 views
    ATI Radeon X1300 Pro Review
    428,866 views
    ATI Radeon X1600 XT Review
    422,399 views
    Connecting Two PCs Using a USB-USB Cable
    384,109 views
    How To Correctly Apply Thermal Grease
    368,584 views
    Sempron vs. Athlon XP
    289,564 views
    Sempron 3400+ Review
    281,957 views

    Latest Threads in Our Forums
    Best thermal paste on the market?
    by zargon48
    Seventeam ST-550P-AG Power Supply Review
    by Hardware Secrets Team
    Thnx for help w/new buid!!
    by zargon48
    How to Manually Clean Your VCR Heads
    by Gabriel Torres
    Titan Launches Cooler for Intel Core i7 CPUs
    by Hardware Secrets Team
    Computer to Sony Bravia 23 in (1920 x 1080)
    by Wromx
    Logitech QuickCam Pro 9000 Review
    by Hardware Secrets Team
    Motherboard Repairing
    by joseph
    Thermaltake Launches Fanless 330 VGA Cooler
    by Hardware Secrets Team
    GeForce GTX 260 with 216 cores Video Card Review
    by Hardware Secrets Team
    .:: Visit Our Forums ::.

    © 2004-8, Hardware Secrets, LLC. All rights reserved.
    Advertising | Legal Information | Privacy Policy
    All times are Pacific Standard Time (PST, GMT -08:00)