• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
导航菜单
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx
您的位置:首页 > 服务器 >windows > nginx+php编译安装

nginx+php编译安装

作者:网友 字体:[增加 减小] 来源:互联网

本文主要包含nginx源码编译安装,nginx编译安装,nginx 1.8.0编译安装,linux下编译安装nginx,centos nginx编译安装等服务器相关知识,网友希望可以进行参考

1.系统环境

centos6.3_x64

nginx: 1.1.5

php:php-5.4.14

############################################

2.环境安装

#yum 安装系统环境所需要的软件包

yum -y install yum-fastestmirror ntp

yum -y install patch make flex bison tar

yum -y install libtool libtool-libs kernel-devel

yum -y install libjpeg libjpeg-devel libpng libpng-devel

yum -y install libtiff libtiff-devel gettext gettext-devel

yum -y install libxml2 libxml2-devel zlib-devel net-snmp

yum -y install file glib2 glib2-devel bzip2 diff* openldap-devel

yum -y install bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs

yum -y install e2fsprogs-devel krb5 krb5-devel libidn libidn-devel

yum -y install openssl openssl-devel vim-minimal unzip

# 安装PHP支持GD库模块

yum -y install freetype freetype-devel png jpeg zlib gd php-gd*

# 安装PHP 5.* 组件

yum -y install libiconv libevent mhash mcrypt

# 安装MYDSQL所需要系统库相关库文件

yum install -y gcc gcc-c++ gcc-g77 autoconf automake fiex* ncurses-devel libmcrypt* libtool-ltdl-devel*

# 安装NGINX 组件

yum -y install pcre*

####################################

3.PHP安装

php和nginx的整合是通过php-FastCGI

FastCGI 是一个可伸缩、高速的在web server和脚本语言间通迅的接口。被许多脚本语言所支持,包括 php多数流行的web server都支持 FastCGI。

正常情况下,nginx和php直接是完全不认识的,我们就是通过php-fastcgi将二者整合。

php5.3.0之前的版本,php-FastCGI 是需要单独安装的。但是在这之后,php-FastCGI 就整合在了php的源码包中,不必再去单独安装。在这里我用的就是php5.3.8的版本,内置了php-fpm ,编译时开启,并且编译后存在 php-cgi 文件了。

注意:PHP编译支持php-fpm功能就不能编译支持apache的apxs模块功能,不然报错。


tar jxf php-5.4.14.tar.bz2 && cd php-5.4.14

./configure '--prefix=/usr/local/php' '--with-iconv' '--with-mysql' '--with-mysqli' '--with-gd' '--with-zlib' '--with-jpeg-dir=/usr/lib64' '--with-png-dir' '--with-freetype-dir=/usr/lib64' '--with-curl=/usr/bin' '--with-openssl' '--with-openssl-dir=/usr' '--with-xsl=/usr' '--with-xmlrpc' '--enable-exif' '--enable-cli' '--enable-calendar' '--with-mhash' '--enable-mbstring' '--enable-mbregex' '--enable-soap' '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--enable-zip' '--enable-ftp' '--with-pear' '--disable-debug' '--with-bz2' '--with-mcrypt' '--with-mhash' --disable-cgi --enable-bcmath --enable-libxml --with-libxml-dir --with-gettext --enable-pcntl --enable-inline-optimization --disable-ipv6 --enable-fpm --enable-ftp --enable-gd-native-ttf

make && make install

cp php-5.4.14/php.ini-production /usr/local/php/lib/php.ini

# cd /usr/local/php/etc/ # 切换到安装目录下的配置文件目录

# cp php-fpm.conf.default php-fpm.conf

# vi php-fpm.conf

启用如下几行,即去掉前面的分号(;)

pid = run/php-fpm.pid
  error_log = log/php-fpm.log
  log_level = notice
  listen = 127.0.0.1:9000
  listen.allowed_clients = 127.0.0.1
  pm = dynamic
  pm.max_children = 50
  pm.start_servers = 5
  pm.min_spare_servers = 5
  pm.max_spare_servers = 35
  pm.max_requests = 500
  env[HOSTNAME] = $HOSTNAME
  env[PATH] = /usr/local/bin:/usr/bin:/bin
  env[TMP] = /tmp
  env[TMPDIR] = /tmp
  env[TEMP] = /tmp

wq保存退出

# /usr/local/php/sbin/php-fpm 启动PHP)

# netstat -antpl (如果看到9000端口,PHP-FPM配置成功)

###########################################################

4.nginx安装

wget -c http://nginx.org/download/nginx-1.1.5.tar.gz

tar zxf nginx-1.1.5.tar.gz && cd nginx-1.1.5

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre --http-client-body-temp-path=/tmp/nginx_client --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --http-uwsgi-temp-path=/tmp/nginx/uwsgi --http-scgi-temp-path=/tmp/nginx/scgi

make && make install

NGINX 配置文件设置:这个配置只是让NGX和PHP关联起来

/usr/local/nginx/conf/nginx.conf

user nginx nginx ; nginx 用户需要新建,注释掉也OK的)
worker_processes 8;
#error_log logs/error.log; //默认在/usr/local/nginx/logs/error.log
error_log /var/log/5aixue_error.log; //指定日志路径
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid    logs/nginx.pid;
events {
  worker_connections 2048;
}
http {
  include    mime.types;
  default_type application/octet-stream;
  charset utf-8; //设置字符集
  sendfile    on;
  keepalive_timeout 65;
  server {
    listen    80;
    server_name test1.5aixue.com; //网站域名
    root /home/aixue/public_html/; //网站路径
    index index.php index.html index.htm ; //index.php 一定要放在前面
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  location ~ \.php$ {
    #  root      html;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
     # include    fastcgi_params;
      include    fastcgi.conf;
    }
    location /
    {
    if (!-e $request_filename) {
        rewrite ^/(.*)$ /index.php last;
        }
    }
}
}

5.测试启动nginx

mkdir -p /tmp/nginx/proxy

cd /usr/local/nginx/sbin

./nginx -t 检测

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

./nginx 启动nginx


在/home/aixue/public_html/ 中编写Index.php文件

<?

phpinfo();

?>

打开浏览器 http://IP/index.php,能浏览,安装成功了。


分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • nginx+php编译安装

相关文章

  • 企业里实现代码自动部署、回滚的解决方案——Caphub
  • windows 2008安装PHP5图文详解
  • 大数据环境下的磁盘脚本思考和实现
  • ⑨④-如果不发展就可能面临生存窘境
  • 配置和工具提升Windows 2003系统安全
  • Windows Server 2008 CA 配置 HTTPS 绑定方法
  • Mysql 之配置文件my.cnf
  • LAMP的web站点搭建(一)
  • 基于Drbd+Corosync构建高可用Mysql服务器
  • 灵活运用eXeScope打造Windows 2000外观

文章分类

  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx

最近更新的内容

    • 集成iSCSI和FC存储的五种常见方法
    • 自动化代码部署、代码回滚、命令执行软件之capistrano
    • ESC键功能:你可能不知道的五个妙用
    • Apache日志中“指定的网络名不再可用”解决办法
    • 无法打开登录所请求的数据库DbName的解决方法
    • 真正彻底卸载ie8的某些加载项
    • 远程桌面服务中的“IP虚拟化”及其作用
    • 如何安全有效的保护iis服务正常运行
    • 详解Windows切至Linux的7大障碍
    • Windows 2008 R2下Exchange 2010的安装准备

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有