Chinaunix首页 | 论坛 | 博客
  • 博客访问: 48515
  • 博文数量: 67
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 380
  • 用 户 组: 普通用户
  • 注册时间: 2015-01-05 15:57
文章分类
文章存档

2015年(67)

我的朋友

分类: LINUX

2015-01-07 10:14:56

安装Nginx的方式有很多种,这里我们还是编译源码进行安装,使用下列命令:

$ wget 
$ tar -zxvf nginx-1.6.2.tar.gz
$ cd nginx-1.6.2
$ ./configure --prefix=/usr/local/nginx
$ make
$ sudo make install

如果安装过程中出现如下错误

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre= option.

则需要先安装pcre

$ sudo yum install pcre-devel

安装完成之后,我们的Nginx安装目录在 /usr/local/nginx 。 接下来修改nginx的配置文件(/usr/local/nginx/conf/nginx.conf),使其能够处理脚本。

worker_processes  1;

events {
  worker_connections  1024;
}
http {
  include       mime.types;
  default_type  application/octet-stream;
  sendfile        on;
  keepalive_timeout  65;
  server {
    listen       80;
    server_name  _;
    root /vagrant;

    location / {
      index  index.html index.htm index.php;
    }

    location /demo {
      index index.php;
      if (!-e $request_filename) {
          rewrite ^/demo/(.*)$ /demo/index.php?$1 last;
          break;
      }
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
      root   html;
    }

    location ~ \.php$ {
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include        fastcgi_params;
    }
  }
}

最后,启动Nginx时,需要先启动PHP-FPM。

$ sudo /usr/local/php/sbin/php-fpm
$ sudo /usr/local//sbin/nginx

对于Nginx的重启以及关闭操作,可以使用以下

$ sudo /usr/local/nginx/sbin/nginx -s [reload|rest|stop]

而PHP-FPM,则麻烦一点,需要先使用 ps -ef|grep php-fpm 获取 master process 的进程ID, 再使用 kill -USR2 :

$ ps -ef|grep php-fpm

root      6221     1  0 02:17 ?        00:00:00 php-fpm: master process (/usr/lo/php/etc/php-fpm.conf)
nobody    6222  6221  0 02:17 ?        00:00:00 php-fpm: pool www
nobody    6223  6221  0 02:17 ?        00:00:00 php-fpm: pool www
vagrant   6233  1623  0 02:18 pts/0    00:00:00  php-fpm

$ sudo  -USR2 6221

 

注意: -USR2 参数为重启, -INT 参数为关闭。

  • 本文来自:
  • 本文链接:
阅读(245) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:linux增加快捷键打开或关闭触摸板

给主人留下些什么吧!~~