Linux-rhel6.4 编译安装PHP,Nginx与php连接
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux-rhel6.4 编译安装PHP,Nginx与php连接相关的知识,希望对你有一定的参考价值。
确定依赖包安装
gcc gcc-c++ libxml2 libxml2-devel bzip2 bzip2-devel libmcrypt libmcrypt-devel openssl openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel readline readline-devel libxslt-devel perl perl-devel psmisc.x86_64 recode recode-devel libtidy libtidy-devel
若没安装,挂载系统镜像,从Packages文件夹里面找到安装包安装,或者有yum源的话可直接yum install安装。
可利用镜像自己制作本地yum源:http://kurol.blog.51cto.com/11433546/1927721
从官网获取,编译安装
[[email protected] ~]# wget http://de2.php.net/get/php-5.5.38.tar.gz/from/this/mirror [[email protected] ~]# tar -zxvf php-5.5.38.tar.gz [[email protected] php-5.5.38]# ./configure --prefix=/usr/local/php-5.5.0 --with-config-file-path=/usr/local/php-5.5.0/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 ...... creating main/internal_functions_cli.c +--------------------------------------------------------------------+ | License: | | This software is subject to the PHP License, available in this | | distribution in the file LICENSE. By continuing this installation | | process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | the installation process at this point. | +--------------------------------------------------------------------+ Thank you for using PHP. config.status: creating php5.spec config.status: creating main/build-defs.h config.status: creating scripts/phpize config.status: creating scripts/man1/phpize.1 config.status: creating scripts/php-config config.status: creating scripts/man1/php-config.1 config.status: creating sapi/cli/php.1 config.status: creating sapi/fpm/php-fpm.conf config.status: creating sapi/fpm/init.d.php-fpm config.status: creating sapi/fpm/php-fpm.service config.status: creating sapi/fpm/php-fpm.8 config.status: creating sapi/fpm/status.html config.status: creating sapi/cgi/php-cgi.1 config.status: creating ext/phar/phar.1 config.status: creating ext/phar/phar.phar.1 config.status: creating main/php_config.h config.status: executing default commands [[email protected] ~]# make [[email protected] ~]# make install [[email protected] ~]# cd php-5.5.38 [[email protected] php-5.5.38]# cp php.ini-production /usr/local/php-5.5.0/etc/php.ini [[email protected] php-5.5.38]# cd /usr/local/php-5.5.0/etc/ [[email protected] etc]# cp php-fpm.conf.default php-fpm.conf [[email protected] etc]# cd /usr/local/php-5.5.0/sbin [[email protected] sbin]# ./php-fpm
nginx与php连接
要点:
1:Nginx 默认支持 fastcgi
2:php编译开启模块:
--enable-fpm
连接:
[[email protected] ~]# vim /usr/local/nginx/conf/nginx.conf server { listen 80; server_name localhost; location / { root html; index index.html index.php; } ....... location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
重启nginx:
[[email protected] ~]# cd /usr/local/nginx/sbin [[email protected] sbin]# ./nginx -s reload
添加php测试文件:
[[email protected] ~]# cd /usr/local/nginx/html [[email protected] ~]# touch info.php [[email protected] ~]# vim info.php
<?php phpinfo(); ?>
浏览器测试:
本文出自 “谢育政” 博客,请务必保留此出处http://kurol.blog.51cto.com/11433546/1927720
以上是关于Linux-rhel6.4 编译安装PHP,Nginx与php连接的主要内容,如果未能解决你的问题,请参考以下文章
Linux rhel 6.4 apache编译安装以及简单配置过程
无法在 Centos 6.4 上安装 php 5.5 opcache