Apache PHP is often used with Apache Web servers for Linux/unix platforms. When we install PHP in the Apache environment, you have three installation modes to choose from: Static module, dynamic module (DSO) and CGI.
I suggest you better install PHP as apached DSO, this installation mode of maintenance and upgrade are fairly simple. For example, suppose you originally installed only the PHP database support function. But after a few days you decided to add encryption to PHP. Simply type the make clean command, then add new configuration options, and then execute make and make install commands. In this way, the new PHP module will be installed to the appropriate location on Apache, you just restart Apache all OK, of course, the whole process without recompiling Apache.
The simple steps to install a new version of Apache and to install PHP as Apache DSO are as follows:
1. Download the latest version of the Apache server software from the Apache Software Foundation site.
2. Place the code file in the appropriate directory such as/usr/local/or/opt/.
3. Unzip the code file with the Gunzip command, and then you can get the corresponding *.tar file.
4. Type the following unpack command to place the above tar file in a apache_[version-shaped directory:
TAR-XVF Apache_[version].tar
5. Go to/usr/local/apache_[version] directory (or the directory you specified in the steps above).
6. Type the following configuration command, with the path you set (such as/usr/local/apache[version], and so on, pay attention to the back of the slash! Replaces the [path] parameter, and you also enable the MOD_SO parameter to allow Apache to use DSO.
./configure--prefix=[path]--enable-module=so
7. Go back to the command prompt and type make and wait for the command execution to complete and return to the command prompt state.
8. Type make install.
By this time, the compiler can create the final directory and return to the system's command prompt state.
Next Install PHP:
1. Visit the download area of the PHP home page to select the latest version of the source code link.
2. Put the downloaded file in the appropriate directory such as/usr/local/or/opt/.
3. Unzip the code file with the Gunzip command, and then you can get the corresponding *.tar file.
4. Type the following unpack command to place the above tar file in a php-[version-shaped directory:
TAR-XVF Php-[version]
5. Go to/usr/local/php-[version] directory (or the directory you specify).
Now you can compile the PHP DSO, in fact, here only need a necessary configuration options--with-apxs (a file under the Apache Bin directory)--however, for the system configuration more comprehensive, we also add to the MySQL database support.
./configure--with-mysql=/[path to MySQL]--with-apxs=/[path to APXS]
6. Go back to the command prompt and type the make command and wait until the command execution completes and return to the command prompt state.
7. Type the make install command.
At this time, the compiler will create the final DSO, and put it in the Apache module directory, but also for you to modify the Apache httpd.conf configuration file, and then the system back to the command prompt state waiting for you to enter the new instructions. You can then open the Apache httpd.conf configuration file to make some corrections:
1. Find a line with serveradmin and add your own email address as follows:
ServerAdmin you@yourdomain.com
2. Find a line that starts with servername and change the following parameters to actual values, such as:
ServerName localhost
3. Locate the following paragraph:
# and for PHP 4.x, use:
#
#AddType application/x-httpd-php. php
#AddType Application/x-httpd-php-source. Phps
Modify these configuration lines to remove some of the comments that were added to AddType under PHP 4.0, and you should add some file extensions for PHP, and the above modified lines might look like this:
# and for PHP 4.x, use:
#
AddType application/x-httpd-php. php. phtml
AddType Application/x-httpd-php-source. Phps
Save the above configuration file, return to the parent directory, type the following command to start Apache:
./bin/apachectl Start
If there are no problems during startup, you can test the installation of Apache and PHP by creating a file called Phpinfo.php that contains the following lines of code:
? Phpinfo ()?>
Save the file and place it in the Apache document root (Htdocs), and then start your Web browser, type http://localhost/phpinfo.php in the browser's address bar, and the browser will display a large number of variables and variable values for PHP and Apache systems.
If you want to reset PHP, all you need to do is execute the make clean command, then execute the./configure command with the new configuration option, and then execute make and make install. In this way, a new module appears in the Apache module directory, and you just reboot Apache to load the new module. Many of the headaches of the past have been solved now.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.