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




Recommended
Wireless Home Networking For Dummies
Wireless Home Networking For Dummies, by Edward Ferris (For Dummies), starting at $10.83
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 Amazon.com Brother HL-2170W 23ppm Laser Printer with Wireless and Wired Network Interfaces Electronics $.
Amazon: $99.99 Wal-Mart: $168.88
CircuitCity: $149.99 Newegg: $149.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

  • Recommended Deal.
    Link Xtreme D-Link Gigabit Wireless IEEED Link D-Link DIR-655 - Xtreme N Gigabit Router


    Buy.com: $99.11 TigerDirect: $99.99
    Wal-Mart: $127.82 Newegg: $92.85

    RSSLatest News
    IN WIN LAN Party in Southern California
    November 20, 2009 - 12:37 PM PST
    Patriot Announces PS-100 SSD Series
    November 19, 2009 - 7:30 AM PST
    Antec Launches TPQ-1200 PSU
    November 18, 2009 - 11:30 AM PST
    AMD/ATI Launches Radeon HD 5970
    November 18, 2009 - 10:18 AM PST
    OCZ Launches Colossus SSD Series
    November 17, 2009 - 1:39 PM PST
    NZXT Unleashes Tempest EVO Mid-Tower Case
    November 17, 2009 - 1:06 PM PST
    nVidia Launches GeForce GT 240
    November 17, 2009 - 10:18 AM PST
    Arctic Cooling Announces Accelero TWIN TURBO PRO VGA Cooler
    November 16, 2009 - 11:46 AM PST
    PowerColor Announces PLAY! HD5770 Video Card
    November 13, 2009 - 12:51 PM PST
    G.Skill Announces Falcon II SSD Series
    November 11, 2009 - 3:31 PM PST
    .:: More News ::.

    RSSLatest Content
    Ultra X4 500 W Power Supply Review
    Seagate Barracuda XT 2 TB Hard Disk Drive Review
    Nintendo Wii Fit Plus Review
    AMD ATI Chips Comparison Table
    nVidia Chips Comparison Table
    Gigabyte G41M-ES2L Motherboard
    Netflix on Playstation 3 Review
    CM Storm Sentinel Advance Mouse Review
    Titan Skalli CPU Cooler Review
    Nexus RX-6300 630 W Power Supply Review
    Gigabyte P55-UD6 Motherboard
    Nintendo Wii Review
    SilverStone Grandia GD04 Case Review
    Can We Trust the 80 Plus Certification?
    NZXT Gamma Case Review

    Our Most Popular Articles
    Maximum CPU Temperature
    1,078,835 views
    How to Find Out Your Motherboard Manufacturer and Model
    706,982 views
    nVidia Chips Comparison Table
    679,668 views
    Connecting Two PCs Using a USB-USB Cable
    593,978 views
    How To Correctly Apply Thermal Grease
    562,884 views
    AMD ATI Chips Comparison Table
    560,538 views
    ATI Radeon X1300 Pro Review
    488,082 views
    ATI Radeon X1600 XT Review
    477,240 views
    How To Perform a BIOS Upgrade
    394,853 views
    Sempron vs. Athlon XP
    338,661 views

    Latest Threads in Our Forums
    DVD ripper/mp4 joiner
    by rektech
    what mobo do i need? pls help!
    by zakk21
    Dell Inspiron 6000 Powers but will not boot...
    by Merman
    Ultra X4 500 W Power Supply Review
    by Merman
    IN WIN LAN Party in Southern California
    by Hardware Secrets Team
    Getting A Hard Copy
    by Trevorrross
    Am I Making The Right Choice?
    by need2know
    Is it available to mount the Zalman cooler?
    by Olle P
    dsl modem prob
    by Sherry
    Seagate Barracuda XT 2 TB Hard Disk Drive Review
    by Hardware Secrets Team
    .:: Visit Our Forums ::.


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