How to correctly configure the PHP environment in Linux

Source: Internet
Author: User

If you want to use Linux to configure the PHP environment. There are a lot of materials on the Internet. Here we will explain how to configure the PHP environment in Linux in step 3 of the application. This article will introduce you in detail how to configure the PHP environment in Linux and play a role in learning how to configure the PHP environment in Linux.

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. The differences are as follows ):
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. Of course, you can register it after installation ). What is actually used is not compiled into the kernel, but compiled into a dynamic shared object (DSO) separately ), as long as the DSO module is called from outside Based on the registered Module name, for example, libphp5.so. This is in 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

 
 
  1. ./configure --prefix=/opt/apache2   
  2. --enable-rewrite  
  3. --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, all apache standard modules except so are compiled into DSO modules. 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. This is the only module that cannot be used as a DSO outside of core, 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

The above is how to configure the PHP environment in Linux.

  1. Configuration notes: configure the DNS server in Linux
  2. How to display Chinese Characters in RedHat Linux 5
  3. How to disable SELinux in Redhat Enterprise Linux
  4. Install the KDE package in Linux
  5. Redhat Linux Remote Desktop configuration

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.