Install and configure Apache in Redhat Linux 9.0 and support PHP MySQL

Source: Internet
Author: User
Tags php mysql

Configure a PHP environment in RedHat Linux 9.0. I read a lot of materials online, but most of them are similar (./configure> make install. But I still don't know why.


I have collected a lot of data here. To explain in detail how to do it. Why!

These are basic things that I can use to facilitate future learning! If there are any mistakes, please let us know! Some additional welcome messages are provided.



My environment is Red Hat linux 9.0 + httpd-2.2.4 + PHP-5.2.4 + mysql-5.0.22 here mysql installation is not much said, focus on learning Apache compilation installation. (the relevant source code is prepared before installation, and the libxml2 package may need to be upgraded according to the installed version)

Install Apache
Apache compilation and installation can be divided into dynamic compilation and installation or static compilation and installation concepts (personal understanding ):
Static compilation and installation refers to directly compiling a module (such as a PHP module) into the Apache kernel. When apahce is used, it can be used directly.
Dynamic compilation and installation refers to registering a module (such as a PHP module) name in the kernel (you can also register it after installation ). What is actually used is not compiled into the kernel, but compiled into a dynamic shared object (DSO) separately ), you can call this DSO module from the outside Based on the registered Module name at the time of use (for example, libphp5.so is the dso linux of PHP5. so file and Windows. dll ).

Differences in configuration during dynamic and static Compilation
During static compilation, all modules to be used must be statically compiled into Apache.
For example
./Configure -- prefix =/opt/apache2
-- Enable-rewrite
-- Enable-ssl
Dynamic compilation is only several shared ones (shared refers to compiling this module into dynamic)
/Configure -- prefix =/opt/apache2 -- enable-so -- enable-mod-shared = [most | all]

You have noticed that -- enable-so is equivalent to-enable-module = so in the old version, the-enable-mod-shared = most is equivalent to the previous -- enable-shared = max version. /coufigure-h to view configuration parameters

-- Enable-so parameter specifies the so module to be started. The so module is the apache core module used to extract DSO support.
-- Enable-mod-shared = [most | all] When compiling apache, www.linuxidc.com compiles all apache standard modules except so into the DSO module. Instead of compiling it into the apache core.
Now we know -- enable-so indicates
Let the apache core load DSO, but do not actually compile any dynamic module
-- Enable-ModuleName indicates compiling and containing the module ModuleName.
-- Enable-ModuleName = shared means to compile this module into a dynamic one.

How to dynamically compile a module
For example, -- enable-rewrite should be replaced with -- enable-rewrite = shared.
If-shared is removed, static compilation is performed.

(DSO support for independent modules of Apache is based on mod_so which can only be statically compiled into the Apache core. www.linuxidc.com is the only module other than core that cannot be used as a DSO, all other released Apache modules can be compiled into DSO independently and activated by using the compilation option "enable-module = shared" described in the installation documentation. A dso module compiled as mod_foo.so can use the LoadModule command of mod_so in httpd. conf to load the module when the server is started or restarted .)
----------------------------

Compile php
./Configure -- prefix =/opt/php5 -- with-mysql =/opt/mysql -- with-apxs2 =/opt/apache2/bin/apxs
To use the MYSQL database, install MYSQL before installing and compiling PHP.
After installation, the system defaults to php. ini should be placed in the lib folder under the PHP installation directory, cp/php source file directory/php. ini-dist/opt/php5/lib/php. ini.
Note that this is apxs2! The old version uses with-apxs. The new support program apxs (APache eXtenSion) can compile DSO-based modules outside the Apache source code tree, in this way, you do not need to recompile Apache to support other modules.
Modify httpd. conf and add one line after AddType application/x-gzip. gz. tgz
AddType application/x-httpd-php. php
Start apache
/Opt/apache2/bin/apachectl start
 

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.