Build a php environment, you need to install the web container.
Installing PHP
Currently, PHP is relatively stable versions 5.6 and 7.1 is recommended to install both versions of PHP.
The installation PHP5.6 version.
1, into the storage source package directory: cd /usr/local/src
Download the installation file PHP5.6: wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
or
wget http://cn2.php.net/distributions/php-5.6.39.tar.bz2
2, extracting archive file: tar -zvxf php-5.6.39.tar.gz
unpack command bz2 files, tar -xvf
3, into the installation directory:cd php-5.6.39
4, mounted reliance
yum -y install gcc gcc-c++ make automake autoconf
yum -y install libxml2-devel openssl-devel pcre-devel sqlite-devel bzip2-deve llibcurl-devel freetype-devel gd-devel readline-devel libmcrypt-devel libcurl-devel libxslt libxslt-devel
5, installed php, initialize:
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif //安装PHP
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/php.d --with-curl=/usr/local/lib --with-freetype-dir=/usr/lib64 --with-gd --with-gettext --with-iconv-dir=/usr/local/lib --with-jpeg-dir=/usr/lib64 --with-kerberos --with-libdir=lib64 --with-libxml-dir=/usr/lib64 --with-mcrypt --with-mhash --with-mysql --with-mysqli --with-openssl --with-pcre-regex=/usr --with-pdo-mysql=shared --with-pdo-sqlite=shared --with-pear=/usr/local/lib/php --with-png-dir=/usr/lib64 --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip --disable-rpath
With this installation is completed without error checking
echo $? //安装完成没有错误用这个检查
【Note】
--prefix:指定安装目录。
--with-apxs2:Apache的工具,指定工具的地址,可以帮我们自动配置一些模块,不用人工干涉。
--with-config-file-path:指定配置文件的路径。
--with-mysql:指定mysql路径。
6, compile and install
make
make install
echo $?
7, vim /usr/local/php52/etc/php-fpm.conf
the 127.0.0.1:9000 into 127.0.0.1:9052
will replace nobody www.
8, see the php installation information
/usr/local/php/bin/php -i
Loaded modules (both static)
/usr/local/php/bin/php -m
PHP as apache module is present, viewing module
/usr/local/apache2.4/bin/httpd -M
ls -l /usr/local/apache2.4/modules/libphp5.so //模块文件
Explanation:
php5_module (Shared): This description is PHP extension module httpd as a form of existence, that if apache To execute php script, it will need to rely on the aid of this module file, if you could remove the .so file, that apache not support php, this module is very important.
9, the httpd configuration files on more than one line php module, the module is commented out of no use, if you want to use, remove the # sign on it, whenever they were taken:
//这是apache的配置文件
vim /usr/local/apache2.4/conf/httpd.conf
10, reference copy php configuration file to the configuration file directory php:
//查看php的一些配置信息,包括编译参数。
/usr/local/php/bin/php -i |less
//查看模块下有没php.ini文件
ls /usr/local/php/etc
//需要到源码包的参考文件复制到php的配置文件目录下
cp php.ini-production /usr/local/php/etc/php.ini
//查看php.ini是否有加载php.ini文件模块,如下图
/usr/local/php/bin/php -i |less
Configuring apache support php
editor /usr/local/apache/conf/httpd.conf, add the following line:
AddType application/x-httpd-php .php .htm .html
In / usr / local / apache / htdocs / add a php file: index.php
<?php
phpinfo()
?>
Restart apache: / usr / local / apache / bin / apachectl -k restart, access the browser: ip address /index.php
can see phpinfo page, the configuration was successful