599Chapter 23Running a Linux, Apache, MySQL, and PHP (Hosting web)
599Chapter 23Running a Linux, Apache, MySQL, and PHP (LAMP) ServerThis installation process installs Apache version 1.3, and all the configurationexamples here have been tested against it. If you would rather install Apache 2.0, itis available in the apache2-mpm-prefork package and uses libapache2-mod-php4instead of the php4 package mentioned later in this chapter. The server should automatically start once the installation is finished, which meansthat you re now ready to install PHP. Installing PHPNow you re ready to install and test the PHP module in Apache. This is the mostcommon method for installing PHP but introduces some security concerns on multi- user systems because all PHP scripts will be run as the same user as the Apachedaemon. Be sure to read the Security section of the PHP manual at http://php.net/ manual/en/security.phpbefore granting other users access to manipulate PHPfiles on your server. The PHP Apache module is contained in the php4 package, which is installed usingAPT. The following lines download and install the module and the mysql extensions, configure Apache to load the module automatically, and instruct Apache to reloadits configuration: # apt-get install php4 php4-mysql# apache-modconf apache enable mod_php4Replacing config file /etc/apache/modules.conf with new version# apachectl restartDon t worry if the second line does not print out a message as this example shows. That simply means that the module has already been configured. At this point, Apache should be ready to process HTTP requests, complete withprocessing of PHP files. To test it, create a file named /var/www/info.phpcontain- ing a call to the phpinfo()function: # cat > /var/www/info.php ^D# chmod 644 /var/www/info.phpThe ^Dmeans that you should press Ctrl+D on your keyboard. This tells the catcommand that you are at the end of the input. Now try opening the page by goingto http://your server s address/info.php. You should see a page full ofinformation about your Apache and PHP installation, as shown in Figure 23-1. Note32_
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.