CentOS 7 下PHP 5.6.19编译安装详解

详解CentOS 7 下PHP 5.6.19编译安装全过程,希望对你有用。 0x01  前言

在php官网下载php-5.6.19.tar.gz源代码(php7虽然说性能提升很大,但是小菜菜还是先用着这个先吧),解压后根目录有个INSTALL文件,里面有安装教程了,目录如下:

Installing PHP
__________________________________________________________________

* General Installation Considerations
* Installation on Unix systems
+ Apache 1.3.x on Unix systems
+ Apache 2.x on Unix systems
+ Lighttpd 1.4 on Unix systems
+ Sun, iPlanet and Netscape servers on Sun Solaris
+ CGI and command line setups
+ HP-UX specific installation notes
+ OpenBSD installation notes
+ Solaris specific installation tips
+ Debian GNU/Linux installation notes
* Installation on Mac OS X
+ Using Packages
+ Using the bundled PHP
+ Compiling PHP on Mac OS X
* Installation of PECL extensions
+ Introduction to PECL Installations
+ Downloading PECL extensions
+ Installing a PHP extension on Windows
+ Compiling shared PECL extensions with the pecl command
+ Compiling shared PECL extensions with phpize
+ php-config
+ Compiling PECL extensions statically into PHP
* Problems?
+ Read the FAQ
+ Other problems
+ Bug reports
* Runtime Configuration
+ The configuration file
+ .user.ini files
+ Where a configuration setting may be set
+ How to change configuration settings
* Installation
__________________________________________________________________

对应你当前的系统,查看相应的内容,当前我的环境应该参考Apache 2.x on Unix systems这部分

Apache 2.x on Unix systems

This section contains notes and hints specific to Apache 2.x installs
of PHP on Unix systems.
Warning

We do not recommend using a threaded MPM in production with Apache 2.
Use the prefork MPM, which is the default MPM with Apache 2.0 and 2.2.
For information on why, read the related FAQ entry on using Apache2
with a threaded MPM

The » Apache Documentation is the most authoritative source of
information on the Apache 2.x server. More information about
installation options for Apache may be found there.

The most recent version of Apache HTTP Server may be obtained from
» Apache download site, and a fitting PHP version from the above
mentioned places. This quick guide covers only the basics to get
started with Apache 2.x and PHP. For more information read the » Apache
Documentation. The version numbers have been omitted here, to ensure
the instructions are not incorrect. In the examples below, 'NN' should
be replaced with the specific version of Apache being used.

There are currently two versions of Apache 2.x - there's 2.0 and 2.2.
While there are various reasons for choosing each, 2.2 is the current
latest version, and the one that is recommended, if that option is
available to you. However, the instructions here will work for either
2.0 or 2.2.
1. Obtain the Apache HTTP server from the location listed above, and
unpack it:
gzip -d httpd-2_x_NN.tar.gz
tar -xf httpd-2_x_NN.tar

2. Likewise, obtain and unpack the PHP source:
gunzip php-NN.tar.gz
tar -xf php-NN.tar

3. Build and install Apache. Consult the Apache install documentation
for more details on building Apache.
cd httpd-2_x_NN
./configure --enable-so
make
make install

4. Now you have Apache 2.x.NN available under /usr/local/apache2,
configured with loadable module support and the standard MPM
prefork. To test the installation use your normal procedure for
starting the Apache server, e.g.:
/usr/local/apache2/bin/apachectl start

and stop the server to go on with the configuration for PHP:
/usr/local/apache2/bin/apachectl stop

5. Now, configure and build PHP. This is where you customize PHP with       这里开始就是php的安装,上面说的都是apache
various options, like which extensions will be enabled. Run
./configure --help for a list of available options. In our example
we'll do a simple configure with Apache 2 and MySQL support.
If you built Apache from source, as described above, the below
example will match your path for apxs, but if you installed Apache
some other way, you'll need to adjust the path to apxs accordingly.
Note that some distros may rename apxs to apxs2.
cd ../php-NN
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
make
make install

If you decide to change your configure options after installation,
you'll need to re-run the configure, make, and make install steps.         如果需要改变设置就重新安装
You only need to restart apache for the new module to take effect.
A recompile of Apache is not needed.
Note that unless told otherwise, 'make install' will also install
PEAR, various PHP tools such as phpize, install the PHP CLI, and
more.
6. Setup your php.ini
cp php.ini-development /usr/local/lib/php.ini

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/d0533cba5563c353963c0f275430753d.html