Official reference address Software: (Red is required) Httpd 2.2.14 PHP 5.2.17 Installation steps:
Build and install Apache. For more details about how to build Apache, see the Apache installation documentation.
CD httpd-2_x_NN ./Configure -- enable-so Makemake install
Others (
./Configure -- prefix =/usr/local/Apache-2.2.15 -- enable-so -- enable-mod-shared = most -- With-MPM = worker
[Root @ test-AS4] # Make
[Root @ test-AS4] # make install
# -- Prefix = <install_path> indicates that the compiled binary file is installed in the <install_path> directory and replaced with the actual installation path <install_path>, for example, -- prefix =/usr/local/Apache-2.2.15. If this configuration parameter is omitted, it is installed in the/usr/local/apache2 directory by default.
# -- Enable-so indicates that the dynamic compilation load module (DSO) supports httpd binary files. This module enables the functional modules of Apache to be compiled separately from the core and dynamically loaded during runtime. With DSO support, you only need to compile the relevant modules when upgrading and adding modules. You do not have to re-compile the entire system. The latest version of Apache compiles this module to the httpd binary file by default. If you are using an earlier version of Apache and need DSO support, you may need to explicitly specify this option.
# -- Enable-mod-shared = <module-List> indicates the module to be compiled in DSO mode. <module-List> indicates the list of module names separated by spaces, all or most, all indicates that all modules are included, and most indicates that most modules are included, such as -- enable-mod-Share = "rewrite deflate", -- enable-mod-Share = most, the effect is equivalent to multiple -- enable-<feature> = Share
# -- With-MPM = <MPM> select the Apache multiplexing module, <MPM >={ BEOs | event | worker | prefork | mpmt_os2 }, prefork is the default processing module in Unix systems. It runs a non-thread-type, pre-derived Web server. It is suitable for systems that do not have a thread security library and need to avoid thread compatibility issues, it is the best MPM for each request to be independent from each other, so that if a request fails, it will not affect other requests. Worker is a multi-path processing module that supports mixed multi-thread, multi-process processing. because it uses threads to process requests, it can process massive requests. the overhead of system resources is less than the MPM Based on processes, it also uses multiple processes, and each process has multiple threads to obtain the stability of the process-based MPM. If your system is thread-safe, I suggest using worker instead of prefork, which will improve your system performance.
)
Apache 2.x. nn has been installed in/usr/local/Apache. This installation supports the loadable module and standard MPM prefork. Then, run the following command to start the Apache server:
/Usr/local/apache2/bin/apachectl start
If the installation succeeds, you can stop the Apache server and continue to install PHP:
/Usr/local/apache2/bin/apachectl stop
-
Now you need to configure and build PHP. Various parameters can be used to customize PHP, for example, which extended feature packages are supported. Use the./configure -- Help Command to list all currently available parameters. In this example, an example of configuration on Apache 2 supported by MySQL is provided.
If you follow the instructions aboveSource codeAfter Apache is built, the following example correctly matches the path of apxs. If Apache is installed in other ways, you need to adjust the apxs path accordingly. Note: In some release versions, you may change apxs to apxs2.
CD ../PHP-nn./Configure -- with-apxs2 =/usr/local/apache2/bin/apxs-- With-mysqlmakemake install
If you decide to change the configuration option after installation, repeat the last three steps configure, make, and make install, and then restart Apache to make the new module take effect. Apache does not need to be re-compiled.
Note that, unless explicitly indicated, the "make install" command will install pear and various PHP tools such as phpize and php cli.
Configure PHP. ini
Cp php. ini-development/usr/local/lib/PHP. ini
You can edit PHP. ini to set the PHP runtime options. To place the file in another location, add the -- with-config-file-Path =/path option in Step 10.
If php. ini-production is selected, be sure to read the change list, which affects PHP Execution.
-
Edit the httpd. conf file to call the PHP module. The path to the right of the loadmodule expression must point to PhP in the system. The above make install command may have completed these, but it is necessary to check.
Loadmodule php5_module modules/libphp5.so
Tell Apache to parse a specific extension into PHP. For example, ask Apache to parse the extension. php into PHP. In order to avoid potential danger, the example uploads and creates a file named exploit.php.jpg and runs it as PHP. We will not use the Apache addtype command to set it. For the following example, you can simply interpret the required extension as PHP. We will demonstrate how to add. php.
<Filesmatch \. php $> sethandler application/X-httpd-php </filesmatch>
Or, you want. PHP ,. phP2 ,. php3 ,. phP4 ,. phP5 ,. phP6, and. all phtml files are run as PHP files. We don't need to set them any more. We just need to follow the following steps:
<Filesmatch "\. Ph (P [2-6]? | TML) $ "> sethandler application/X-httpd-php </filesmatch>
Then, the. PHPs file can be processed by the PHP source code filter so that it can highlight the source code During display. The settings are as follows:
<Filesmatch "\. PHPs $"> sethandler application/X-httpd-PHP-source </filesmatch>
Mod_rewrite also helps to highlight the source code of. php files that do not need to be run without renaming them to. PHPs files:
Rewriteengine onrewriterule (. * \. php) S $1 [H = application/X-httpd-PHP-source]
Do not start the PHP source code filter on the system that officially produces and operates, because it may leak system secrets or embedCode.
-
- Start the apache service as follows:
/Usr/local/apache2/bin/apachectl start
Red Hat installation error:
/Home/jjdai/work/zhupiter/php-5.2.0/EXT/iconv. C: 2419: Undefined reference to 'libiconv _ open'
Collect2: LD returned 1 exit status
Make: *** [SAPI/CLI/PHP] Error 1
Reference address:
Http://hi.baidu.com/ostech/blog/item/a63f9b0dabed1ae7ab6457d0.html
Solution:
# Wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
# Tar-zxvf libiconv-1.13.1.tar.gz
# Cd libiconv-1.13.1
#./Configure -- prefix =/usr/local/libiconv
# Make
# Make install
Check PHP again
./Configure -- With-curl -- with-apxs2 =/usr/local/apache2/bin/apxs -- enable-sockets -- With-iconv =/usr/local/libiconv
Refer:
#. /Configure -- With-mysql =/backup/MySQL -- With-FreeType-dir -- With-JPEG-dir -- With-PNG-dir -- With-zlib -- With-curl --- GD -- enable-Gd-native-TTF
-- with-apxs2 =/usr/local/Apache/bin/apxs -- enable-sockets -- With-iconv =/usr/local/libiconv
# make
# make install
Another solution is to remove the iconv module and compile PHP normally, as shown below:
Too many makefile is about 77 rows long:
Extra_libs =...-lcrypt
Add-liconv at the end, for example:
Extra_libs =...-lcrypt-liconv
Run make again.
Last method: Provided by tonyty163:
# Make zend_extra_libs = '-liconv'
# Make install
Pay attention to PhP. ini Permissions
Mysql-devel-5.1.47-4.el6.x86_64
Mysql-server-5.1.47-4.el6.x86_64
Mysql-libs-5.1.47-4.el6.x86_64
Mysql-connector-odbc-5.1.5r1144-7.el6.x86_64
Mysql-5.1.47-4.el6.x86_64