PHP: Installation And Configuration1. General Installation ConsiderationsTable of contents:
The following are the three main feilds were you can apply the use of PHP.
For the first and most common form, you need three things: PHP itself, a web server and a web browser. You probably already have a web browser, and depending on your operating system setup, you may also have a web server (e.g. Apache on Linux and MacOS X; IIS on Windows). You may also rent webspace at a company. This way, you don\\\\\\\\'t need to set up anything on your own, only write your PHP scripts, upload it to the server you rent, and see the results in your browser. While setting up the server and PHP on your own, you have two choices for the method of connecting PHP to the server. For many servers PHP has a direct module interface (also called SAPI). These servers include Apache, Microsoft Internet Information Server, Netscape and iPlanet servers. If PHP has no module support for your web server, you can always use it as a CGI or FastCGI processor. This means you set up your server to use the CGI executable of PHP to process all PHP file requests on the server. If you are also interested to use PHP for command line scripting (e.g. write scripts autogenerating some images for you offline, or processing text files depending on some arguments you pass to them), you always need the command line executable. With PHP you can also write desktop GUI applications using the PHP-GTK extension. This is a completely different approach than writing web pages, as you do not output any HTML, but manage windows and objects within them. From now on, this section deals with setting up PHP for web servers on Unix and Windows with server module interfaces and CGI executables. You will also find information on the command line executable in the following sections.
2. Installation on Linux systemsGetting ReadyGet ready to take the big plunge and set up your first dynamic Web site with PHP as your choice. This quick introduction will get your Linux box up and running with PHP in no time.
For starters, let\\\\\\\\'s lay out the basics: we\\\\\\\\'re going to install PHP on a Linux box, we\\\\\\\\'ll be running Apache as our Web server, and MySQL as our database. Since I\\\\\\\\'m running Red Hat Linux, I\\\\\\\\'ll run through things with that perspective, though any Linux distro shouldn\\\\\\\\'t be too far from what we\\\\\\\\'ll cover. We\\\\\\\\'ll assume you\\\\\\\\'re generally familiar with the Linux OS, and that you\\\\\\\\'ve got a basic idea on how to compile source code and install binaries. Getting the Files You\\\\\\\\'ll NeedTo do PHP right, you\\\\\\\\'ll need to grab the following:
Preparing to Install PHPOnce you\\\\\\\\'ve downloaded all of the above, you\\\\\\\\'ll need to do the following to get ready for your PHP install. The first thing to do is to install the Apache upgrade you\\\\\\\\'ve downloaded. Assuming you\\\\\\\\'re going with the RPMs, cd into the directory you\\\\\\\\'ve downloaded to and it\\\\\\\\'s a simple rpm -U apache*.rpm at the command line. Once you\\\\\\\\'ve done that, go ahead and install you\\\\\\\\'re freetype-devel package with a rpm -i freetype-devel-x.x.x.rpm and it\\\\\\\\'s two down, two to go. P>Next in line are the MySQL packages. Again, make sure you grab the MySQL-devel package, or your PHP compile will fail. If you\\\\\\\\'re in the directory where your MySQL packages are, do a rpm -i MySQL*.rpm and we\\\\\\\\'re pretty much there. There are some post installation steps needed to get MySQL configured correctly. Full instructions are available in the MySQL RPM Post Installation section. The last thing to do before you can compile your PHP source is to open up your /usr/sbin/apxs file in your favorite text editor, and head down to line 81. Somewhere around that point you\\\\\\\\'ll find a line that starts with my $CFG_LIBEXECDIR = Make sure that this is set to /usr/lib/apache so that the whole line reads my $CFG_LIBEXECDIR =\\\\\\\\'/usr/lib/apache\\\\\\\\' If you\\\\\\\\'re apxs file doesn\\\\\\\\'t have this problem, obviously, you can skip this step. Compile and Configure
Installing the PHP SourceOk, now that all that\\\\\\\\' s done, we\\\\\\\\' re finally ready to compile and install the PHP source itself. First, unzip the PHP source by doing a tar zxvf php-x.x.xx.tar.gz Then, cd into the source directory and do a ./configure --with-apxs=/usr/sbin/apxs --with-mysql for a standard MySQL-based setup. If you want to configure PHP with additional options, a ./configure --help will give you a list of what\\\\\\\\' s available. The do the compile and install with make make install Post Compilation SetupA quick edit of a couple of Apache config files is all that\\\\\\\\' s needed to alert Apache to PHP. First, open up /etc/httpd/conf/httpd.conf and add the following lines LoadModule php3_module libexex/libphp3.so AddModule mod_php3.c Make sure to check the LoadModule and AddModule sections of the conf file to make sure these lines aren\\\\\\\\' t already there -- doubles are bad. Next, edit the /etc/httpd/conf/srm.conf and add the following lines AddType application/x-httpd-php3 .php3 AddType application/x-httpd-php3-source .phps to tell Apache to use PHP on any file with a .php3 extension. Last up -- restart Apache and you should be good to go /etc/rc.d/init.d/httpd restart That\\\\\\\\' s it, now you\\\\\\\\' ve got PHP installed, and you\\\\\\\\' re ready to rock! If you\\\\\\\\' re having trouble, head on over to the PHP Forum and ask away ... :)
3. Installation on Windows systems
My file was named: php-5.0.3-Win32.zip The configuration fileThe configuration file (called php3.ini in PHP 3, and simply php.ini as of PHP 4) is read when PHP starts up. For the server module versions of PHP, this happens only once when the web server is started. For the CGI and CLI version, it happens on every invocation. php.ini is searched in these locations (in order):
If php-SAPI.ini exists (where SAPI is used SAPI, so the filename is e.g. php-cli.ini or php-apache.ini), it\\\\\\\\'s used instead of php.ini. SAPI name can be determined by php_sapi_name().
The php.ini directives handled by extensions are documented respectively on the pages of the extensions themselves. The list of the core directives is available in the appendix. Probably not all PHP directives are documented in the manual though. For a complete list of directives available in your PHP version, please read your well commented php.ini file. How to change configuration settingsRunning PHP as an Apache moduleWhen using PHP as an Apache module, you can also change the configuration settings using directives in Apache configuration files (e.g. httpd.conf) and .htaccess files. You will need "AllowOverride Options" or "AllowOverride All" privileges to do so. With PHP 4 and PHP 5, there are several Apache directives that allow you to change the PHP configuration from within the Apache configuration files. For a listing of which directives are PHP_INI_ALL, PHP_INI_PERDIR, or PHP_INI_SYSTEM, have a look at the List of php.ini directives appendix.
php_value
name valueSets the value of the specified directive. Can be used only with
PHP_INI_ALL and
PHP_INI_PERDIR type directives. To
clear a previously set value use none as
the value.
|