Chinaunix首页 | 论坛 | 博客
  • 博客访问: 504122
  • 博文数量: 240
  • 博客积分: 791
  • 博客等级: 军士长
  • 技术积分: 1694
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-23 18:21
文章分类

全部博文(240)

文章存档

2013年(21)

2012年(219)

我的朋友

分类: LINUX

2013-03-12 15:48:22

一、安装nginx相对较为简单,安装前确认已经安装了pcre,可通过rpm -q pcre查看本机安装版本。一般安装即可。若无安装直接yum install pcre安装下。

二、下载当前稳定版1.2.7
cd /tmp
wget 

tar -xvf nginx-1.2.7.tar.gz

cd nginx-1.2.7

三、正式安装

点击(此处)折叠或打开

  1. #安装Nginx
  2. tar -zxvf nginx-1.2.7.tar.gz
  3. cd nginx-1.2.7
  4. ./configure --user=www --group=www \
  5. --prefix=/usr/local/nginx \
  6. --sbin-path=/usr/local/nginx/sbin/nginx \
  7. --conf-path=/usr/local/nginx/conf/nginx.conf \
  8. --with-http_stub_status_module \
  9. --with-http_ssl_module \
  10. --with-pcre \
  11. --lock-path=/var/run/nginx.lock \
  12. --pid-path=/var/run/nginx.pid
  13. 编译完成没错误后,执行以下命令
  14. make && make install && cd ../
四、更改nginx配置信息

点击(此处)折叠或打开

  1. #更改配置
  2. vi /usr/local/nginx/conf/nginx.conf

  3. #修改一些参数,别直接替换文件,这只是一部分
  4. user www

  5. events {
  6.     use epoll;
  7.     worker_connections 1024;
  8. }
  9. listen 80;
  10. server_name localhost;
  11. index    index.html index.htm index.php;
  12. root      /var/www/html;

  13. location ~ .*\.(php|php5)?$ {
  14.             fastcgi_pass 127.0.0.1:9000;
  15.             fastcgi_index index.php;
  16.             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  17.             include fastcgi_params;
  18.         }

  19. #注意这里
  20. #$document_root$fastcgi_script_name;
  21. #检测配置文件
  22. /usr/local/nginx/sbin/nginx -t

  23. #提示表示成功
  24. #nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
  25. #nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

  26. #开启Nginx
  27. /usr/local/nginx/sbin/nginx
  28. #平滑重启Nginx
  29. /usr/local/nginx/sbin/nginx -s reload

  30. #添加开机启动
  31. vi /etc/rc.d/rc.local
  32. #最后一行加入
  33. /usr/local/nginx/sbin/nginx &
五、测试nginx及php是否可用

点击(此处)折叠或打开

  1. vi /var/www/html/index.php
  2. #新建index文件,输入
  3. <?php
  4. phpinfo();
  5. ?>
如果出现phpinfo界面,查看显示信息无异常,说明nginx跟php配置都成功。

这样就完成了nginx的安装配置。下一步就该进行zend安装了。
cd打开,有好的建议可提供~
阅读(1461) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~