How to install PHP in the dynamic shared object mode

Source: Internet
Author: User
Tags php database
PHP is usually installed on the LinuxUnix operating system and used together with the Apache server. When installing PHP and Apache server together, you can choose from three different installation methods: static module, dynamic shared object (dynamic1_dobject, DSO), and CGI program execution file. Here, we recommend that you use dynamic PHP, which is usually installed on a Linux/Unix operating system and used together with an Apache server. When you install PHP and Apache server together, you can choose from three different installation methods: static module, Dynamic Shared Object (Dynamic Shared Object, DSO), and CG.
I program execution file.

Here I suggest you use the dynamic shared object mode to install PHP, because this installation method provides great convenience for future maintenance and upgrade. Suppose you only added the PHP database modules when installing PHP. A few days later, you decided to add the PHP encoding function modules. at this time, you only need to enter the make clean command in your system command column, and then enter the new PHP setting options, then enter the make and make install commands. then the system will generate a new PHP dynamic sharing object and install it to the appropriate directory location specified by the Apache server. Next, you only need to reactivate the Apache server. you do not need to recompile the entire Apache server.

The following basic steps allow you to install a completely new Apache server and contain the PHP dynamic loading module:

1. download the latest Apache Server source code at http://www.apache.org/dist.

2. copy the obtained files to a meaningful directory location, such as/usr/local/or/opt/, or another directory location that you think is appropriate.

3. decompress the obtained file. After unzipping, you will get some *. tar files.

4. enter the following command to unbind the *. tar file and place the file to a directory named apache _ [version:

Tar-xvf apache_{version}.tar

5. enter the cd command to switch the working directory to/usr/local/apache _ [version] (if you set *. when the tar file is removed to another directory, switch to the directory you specified)

6. enter the following command to prepare the compilation program. replace the [path] section in the following command with your own directory name, for example,/usr/local/apache [version] (do not add the last Slash !). This step activates mod_so so that the Apache server can use dynamic shared objects.

./Configure -- prefix = [path] -- enable-module = so

7. wait until the system returns to the command prompt symbol, enter make, and then wait until the system returns to the command prompt symbol.

8. enter the make install command.

At this time, the compilation program will generate the directories and files to be used at the end, and return to the command prompt symbol after completion.

Next, you can start to install PHP:

1. go to the PHP official website: http://www.php.net/downloads.php to download the latest version of the PHP original program code.

2. Place the obtained files to a meaningful directory location, such as/usr/local/or/opt/, or another directory location that you think is appropriate.

3. decompress the obtained file. After unzipping, you will get some *. tar files.

4. enter the following command to unbind the *. tar file and place the file to a directory named php-[version:

Tar-xvf php-[version]

5. enter the cd command to switch the working directory to/usr/local/php-[version] (if you set *. to extract the tar file to different directories, switch to the directory you specified ). Now you can start compiling PHP dynamic shared objects. there is only one really required setting option: -- with-apxs (this is a file in the bin directory of the Apache server installation location ). However, we recommend that you add MySQL-related modules in PHP.

./Configure -- with-mysql =/[path to mysql] -- with-apxs =/[path to apxs]

6. wait until the system returns to the command prompt symbol, enter the make command, and then wait until the system returns to the command prompt symbol before entering the make install command.

Next, compile the program to generate the PHP dynamic sharing object we will use. place it in the directory where Apache is used to place the dynamic sharing object, and modify the Apache server configuration file httpd for you. some parts of the conf, and the system will return to the command prompt symbol again. After you return to the command prompt symbol, you must go back and modify the httpd. conf file. some settings must be modified:

1. Find out the ServerAdmin line, add your email mailbox, that is, to change the line to: ServerAdmin you@yourdomain.com

2. find the row ServerName and set the server name, for example, ServerName localhost

3. find the following settings:

# And for PHP 4.x, use:
#
# AddType application/x-httpd-php. php
# AddType application/x-httpd-php-source. phps

You must modify the value here, remove the # symbol before the AddType line (here the # symbol represents the annotation), and add other extensions that you want to use with PHP programs, after the modification, this setting should look like (please note that. php and. phtml is the extension that you can use to differentiate PHP programs in the future ):

# And for PHP 4.x, use:
#
AddType application/x-httpd-php. php. phtml
AddType application/x-httpd-php-source. phps

Store the httpd. conf disk, input the cd command back to the previous directory, and then enter the following command to activate the Apache server:

./Bin/apachectl start

If no error message is displayed during the activation process, we can test whether the installed Apache server and PHP module are correct. Create an archive named phpinfo. php. enter the following PHP code:

<? Phpinfo ()?>

Save the Archive disk and place it in the root directory of the Apache server (the directory name is htdocs. Start your browser and enter http: // localhost/phpinfo in the address column. php. if everything is correctly installed, you should see a long web page with the complete PHP System settings displayed. This indicates that we have successfully installed the Apache server and PHP!

After the initial installation is complete, you only need to enter the make clean command under the system command prompt symbol when you want to reset the PHP module (for example, add the PHP module that is not installed) in the future, enter a new one. /configure sets the command, and then input the make and make install commands, the system will generate a new PHP dynamic sharing object. Next, you only need to reactivate the Apache server so that it can reload the newly created module. You only need a few simple steps to solve a bunch of annoying problems!

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.