Linux-rhel6.4 编译安装PHP,Nginx与php连接
发表于:2026-10-31 作者:千家信息网编辑
千家信息网最后更新 2026年10月31日,确定依赖包安装gcc gcc-c++ libxml2 libxml2-devel bzip2 bzip2-devel libmcrypt libmcrypt-devel openssl openssl
千家信息网最后更新 2026年10月31日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
从官网获取,编译安装
[root@kurolz ~]# wget http://de2.php.net/get/php-5.5.38.tar.gz/from/this/mirror [root@kurolz ~]# tar -zxvf php-5.5.38.tar.gz[root@kurolz 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.specconfig.status: creating main/build-defs.hconfig.status: creating scripts/phpizeconfig.status: creating scripts/man1/phpize.1config.status: creating scripts/php-configconfig.status: creating scripts/man1/php-config.1config.status: creating sapi/cli/php.1config.status: creating sapi/fpm/php-fpm.confconfig.status: creating sapi/fpm/init.d.php-fpmconfig.status: creating sapi/fpm/php-fpm.serviceconfig.status: creating sapi/fpm/php-fpm.8config.status: creating sapi/fpm/status.htmlconfig.status: creating sapi/cgi/php-cgi.1config.status: creating ext/phar/phar.1config.status: creating ext/phar/phar.phar.1config.status: creating main/php_config.hconfig.status: executing default commands[root@kurolz ~]# make[root@kurolz ~]# make install[root@kurolz ~]# cd php-5.5.38[root@kurolz php-5.5.38]# cp php.ini-production /usr/local/php-5.5.0/etc/php.ini[root@kurolz php-5.5.38]# cd /usr/local/php-5.5.0/etc/[root@kurolz etc]# cp php-fpm.conf.default php-fpm.conf[root@kurolz etc]# cd /usr/local/php-5.5.0/sbin[root@kurolz sbin]# ./php-fpm
Nginx与php连接
要点:
1:Nginx 默认支持 fastcgi
2:php编译开启模块:
--enable-fpm
连接:
[root@kurolz ~]# 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:
[root@kurolz ~]# cd /usr/local/nginx/sbin[root@kurolz sbin]# ./nginx -s reload
添加php测试文件:
[root@kurolz ~]# cd /usr/local/nginx/html[root@kurolz ~]# touch info.php[root@kurolz ~]# vim info.php
浏览器测试:
将pid文件存于var/run中
[root@kurolz ~]# vim /usr/local/php-5.5.0/etc/php-fpm.confpid = run/php-fpm.pid
配置开机启动php-fpm
并可用service php-fpm [start | restart | stop]开启、重启、关闭
[root@kurolz ~]# vim /etc/init.d/php-fpm
将下列脚本写入/etc/init.d/php-fpm中,12-15行的路径自己修改
#!/bin/sh # # php-fpm - this script starts and stops the php-fpm daemin # # chkconfig: - 85 15 # processname: php-fpm # config: /usr/local/php/etc/php-fpm.conf set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="php-fpm daemon" NAME=php-fpm DAEMON=/usr/local/php-5.5.0/sbin/php-fpm CONFIGFILE=/usr/local/php-5.5.0/etc/php-fpm.conf PIDFILE=/usr/local/php-5.5.0/var/run/php-fpm.pid SCRIPTNAME=/etc/init.d/php-fpm # If the daemon file is not found, terminate the script. test -x $DAEMON || exit 0 d_start(){ $DAEMON -y $CONFIGFILE || echo -n " already running" } d_stop(){ kill -QUIT `cat $PIDFILE` || echo -n " no running" } d_reload(){ kill -HUP `cat $PIDFILE` || echo -n " could not reload" } case "$1" in start) echo -n "Starting $DESC: $NAME" d_start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" d_stop echo "." ;; reload) echo -n "Reloading $DESC configuration..." d_reload echo "Reloaded." ;; restart) echo -n "Restarting $DESC: $NAME" d_stop # Sleep for two seconds before starting again, this should give the nginx daemon some time to perform a graceful stop sleep 2 d_start echo "." ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload)" >&2 exit 3 ;; esac exit 0赋予php-fpm任何用户可执行权限
[root@kurolz ~]# chmod a+w /etc/init.d/php-fpm
设置开机启动
[root@kurolz ~]# chkconfig php-fpm on
文件
编译
镜像
测试
文件夹
权限
模块
浏览器
用户
系统
脚本
要点
路径
制作
支持
浏览
配置
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
互联网加科技
互联网科技有限公司经营范围
互联网通讯科技
互联网 科技公司
苏州互联网科技贷款公司
时间互联网络科技
伴你行互联网科技有限公司
深圳期待互联网科技
互联网 科技馆
汉立互联网科技有限公司联系电话
湖南洣水互联网科技有限公司扣款
宝灵互联网科技有限公司
米聚互联网科技南京有限公司排面
华夏恒生互联网科技013171
互联网在线教育科技创业
徐州市互联网科技有限公司
信承诺互联网科技有限公司
互联网科技接地气
玉溪新华互联网科技怎么选
亚光科技低轨卫星互联网
苏州找大状互联网科技有限公司
今日互联网科技
与互联网科技公司
互联网科技集团
亿策互联网科技
安徽鑫晟辉互联网科技
凡科互联网科技
黑科技闪耀互联网之光
消费医药和互联网科技
互联网科技创业计划的风险分析