DSO Dynamic loading PHP module to Apache server

Source: Internet
Author: User

PHP is often used with Apache on the Linux/unix platform, with three installation options available when installing PHP: static mode, dynamic mode (DSO), CGI binary mode.
  
Because it is easy to maintain and upgrade, I strongly recommend that you install PHP in DSO mode. For example, if you installed PHP to support only the database at initial installation, and then you want to install a module that supports encryption, just run "make clean", add new configuration options, and then run "make" and "Make install". A new PHP module will be installed in the appropriate location in Apache, and then re-launch Apache without recompiling Apache.
  
The following steps will install a completely new Apache and install it in the DSO mode:
  
1, from the Apache Software Foundation to get the latest version of the Apache source code;
  
2. Put the obtained source code into the/usr/local/or/opt/directory, or any directory you specify;
  
3. Run Gunzip to unzip the file and get the file suffix. tar;
  
4. Run the following command to install the file into the Apache_[version] directory:
TAR-XVF Apache_[version].tar
  
5. Enter the/usr/local/apache_[version] directory (or the directory where the compressed files are installed in step 4);
  
6. Type the following command to prepare for compiling Apache, replace the [path] with your own path, for example,/usr/local/apache[version], and now set the new value of Mod_so, which will allow Apache to use the DSO module;
  
7. After returning to the prompt state, type make and wait to return to the prompt again;
  
8. Execute the "make install" command.
  
Now that Apache is installed, the system will return to the prompt state. Next we start installing PHP:
  
1. Find the latest version of the link in the download area of the PHP homepage;
  
2. Download the file to an appropriate directory, such as/usr/local/or/opt/or any directory you specify;
  
3. Run Gunzip to unzip the file and get the file suffix. tar;
  
4. Execute the following command to install the file in the Php-[version] directory:
TAR-XVF Php-[version]
  
5. Enter the/usr/local/php-[version] directory or the directory specified in step 4;
  
At this point, the preparation for installing PHP in DSO is ready, and the only configuration option that needs to be modified is WITH-APXS (this is a file in Apache's Bin directory). In order to get a higher performance, I did not install the support module for MySQL.
  
./configure--with-mysql=/[path to MySQL]--with-apxs=/[path to APXS]
  
6, return to the prompt state after the make command, waiting to return to the prompt state;
  
7. Execute the Make install command.

At this point, the system by DSO in the Apache module directory installed PHP, and the Apache httpd.conf file to make the appropriate changes to return to the prompt state. When you get back to the prompt, you also need to make some changes to the Apache httpd.conf file.
  
1. Find a line containing serveradmin and add your email address as follows:
ServerAdmin
[email protected]
  
2. Find the line beginning with servername and change it to a real value, for example:
ServerName localhost
  
3. Find the following subsections:
# and for PHP 4.x, use:
#
#AddType application/x-httpd-php. php
#AddType Application/x-httpd-php-source. Phps
  
Modify the contents of these lines so that PHP 4.0 's AddType no longer becomes a comment, and add the file suffix name that you want to use in PHP, and the above content becomes as follows:
# and for PHP 4.x, use:
#
AddType application/x-httpd-php. php. phtml
AddType Application/x-httpd-php-source. Phps
  
To save the file, go back to the top level directory and execute the following command to restart Apache:
./bin/apachectl Start
  
If you do not see an error message at startup, you can test the installed Apache and PHP by creating a file named Phpinfo.php that contains only one line, as shown below:
    
Save this file to the Apache document root (htdocs), then open the browser, type
http://localhost/phpinfo.phpAddress, a number of variables and their values appear on the screen.
  
If you want to reconfigure PHP, you need to run the make Clean command again, then execute the./configure command with a series of options, and then the make and make install commands, a new module appears in the Apache directory module. Just restart Apache to load this new module and everything is OK.

DSO Dynamic loading PHP module to Apache server

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.