###### #Redhat6.5 source code compilation installation php########
Lab Environment:
ip:172.25.8.3
(Nginx, MySQL service is installed and can be used normally)
Experimental content:
1. Installation package
php-5.6.20.tar.bz2
RE2C-0.13.5-1.EL6.X86_64.RPM # #PHP的词法解释器re2c
LIBMCRYPT-2.5.8-9.EL6.X86_64.RPM # #提供mcrypt, MCrypt is an important encryption support extension library in PHP
LIBMCRYPT-DEVEL-2.5.8-9.EL6.X86_64.RPM # #lib库
"-devel generally refers to the corresponding development library: generally including header files, static libraries, dynamic libraries, these are necessary for development." Not with-devel general do not install header files and static libraries, dynamic libraries to install, for other programs run when the link "
2. Installation process
Yum Install-y libmcrypt-2.5.8-9.el6.x86_64.rpm
Yum Install-y libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
Yum Install-y re2c-0.13.5-1.el6.x86_64.rpm
Tar jxf php-5.6.20.tar.bz2 # #进行解压
cd/root/desktop/php-5.6.20 # #进入目录
./configure--prefix=/usr/local/lnmp/php \ ##./cofigure--help can choose to install the module
>--WITH-CONFIG-FILE-PATH=/USR/LOCAL/LNMP/PHP/ETC \
>--with-openssl
>--with-snmp
>--WITH-GD--with-zlib \
>--with-curl \
>--with-libxml-dir \
>--with-png-dir \
>--with-jpeg-dir \
>--with-freetype-dir \
>--with-gettext \
>--without-pear
>--WITH-GMP \
>--enable-inline-optimization \
>--enable-soap
>--enable-ftp \
>--enable-sockets \
>--enable-mbstring \
>--with-mysql \
>--with-mysqli \
>--with-pdo-mysql \
>--ENABLE-MYSQLND \
>--ENABLE-FPM \
>--with-fpm-user=nginx \
>--with-fpm-group=nginx \
>--with-mcrypt \
>--with-mhash \
# #编译过程中缺什么安装什么, then continue compiling
# #这是此次编译中提示缺少的内容:
Yum Install-y libxml2-devel
Yum install-y curl-devel (libcurl-devel-7.19.7-37.el6_4.x86_64 installed)
Yum Install-y libjpeg-turbo-devel-1.2.1-1.el6.x86_64
Yum Install-y libpng-devel-1.2.49-1.el6_2.x86_64
Yum Install-y freetype-devel.x86_64
Yum Install-y net-snmp-devel.x86_64
If the name of the package is not explicitly installed according to the hint name, use the command: Yum serch hint name. For example: Yum search jpeg can be searched to Libjpeg-turbo-devel "
Make;make Install # #make进行编译 make install build file to System
3.php configuration file
cd/usr/local/lnmp/php # #进入目录
cp/usr/local/lnmp/php/etc/php-fpm.conf.default/usr/local/lnmp/php/etc/php-fpm.conf# #备份php-fpm.conf.default File
Cp/root/php-5.6.20/php.ini-production/usr/local/lnmp/php/etc/php.ini # #备份php. ini file
Vim/usr/local/lnmp/php/etc/php.ini # #编辑PHP引擎配置文件php. ini
TimeZone = Asia/shanghai # #设置时区, in 925 rows
Pdo_mysql.default_socket =/usr/local/lnmp/mysql/data/mysql.sock # #指定mysql. sock file, in 1001 rows
Mysql.default_socket =/usr/local/lnmp/mysql/data/mysql.sock # #指定mysql. sock file, in 1150 rows
Mysqli.default_socket =/usr/local/lnmp/mysql/data/mysql.sock # #指定mysql. sock file, in 1209 rows
Vim/usr/local/lnmp/php/etc/php-fpm.conf # #编辑PHP服务配置文件php. conf (fastcgi mode)
PID = run/php-fpm.pid # #这是安装目录中的var/run/php-fpm.pid, remove the semicolon, in 25 rows
CP/ROOT/PHP-5.6.20/SAPI/FPM/INIT.D.PHP-FPM/ETC/INIT.D/PHP-FPM # #作为系统启动脚本, using the Start PHP service
chmod +X/ETC/INIT.D/PHP-FPM # #给脚本执行权限
/ETC/INIT.D/PHP-FPM Start # #启动php服务
"Added Inx user, useradd-u 900-d/usr/local/lnmp/nginx nginx"
4. Modify Nginx configuration file, support PHP program request access
vim/usr/local/lnmp/nginx/conf/nginx.conf # #编辑nginx配置文件
Location/{
Index index.html index.htm index.php;} # #index后添加index. php files
Location ~ \.php$ {# #去掉注释, in 65 rows
root HTML;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename/scripts$fastcgi_script_name;# #脚本文件请求的路径
Include fastcgi.conf;
}
Location ~ \.php$ {
Inclide fastcgi.conf # #修改参数为fastcgi. conf
NGINX-T # #查看nginx服务是否配置成功
Nginx # #启动nginx服务
vim/usr/local/lnmp/nginx/html/index.php # #编辑index. php Add the following:
<?php
Phpinfo ()
?>
5. Test whether the PHP parsing request is OK
Browser access 172.25.8.3/index.php can display PHP configuration information
6. Test PHP connection to MySQL connection
vim/usr/local/lnmp/nginx/html/test_mysql.php # #编辑测试网页
<?php
$link _id=mysql_connect (' localhost ', ' root ', ' Redhat ') ormysql_error ();
if ($link _id) {
echo "MySQL is ok!";
}else{
Echo mysql_error;
}
?>
7. Browser Access 172.25.8.3/test_mysql.php show MySQL is ok!
This article from the "12148275" blog, reproduced please contact the author!
Linux Learning Notes-source code compile and install PHP