首页 > 通过 passenger-install-nginx-module 安装的 nginx 和直接安装的 nginx 有什么区别?

通过 passenger-install-nginx-module 安装的 nginx 和直接安装的 nginx 有什么区别?

系统中的 nginx 是这样安装的

sudo apt-get install nginx

安装了passenger后

gem install passenger

还需安装nginx module才能在nginx中配置使用它。在安装时

passenger-install-nginx-module

提示

Automatically download and install Nginx?

Nginx doesn't support loadable modules such as some other web servers do,
so in order to install Nginx with Passenger support, it must be recompiled.

Do you want this installer to download, compile and install Nginx for you?

 1. Yes: download, compile and install Nginx for me. (recommended)
    The easiest way to get started. A stock Nginx 1.4.4 with Passenger
    support, but with no other additional third party modules, will be
    installed for you to a directory of your choice.

 2. No: I want to customize my Nginx installation. (for advanced users)
    Choose this if you want to compile Nginx with more third party modules
    besides Passenger, or if you need to pass additional options to Nginx's
    'configure' script. This installer will  1) ask you for the location of
    the Nginx source code,  2) run the 'configure' script according to your
    instructions, and  3) run 'make install'.

Whichever you choose, if you already have an existing Nginx configuration file,
then it will be preserved.

【问题1】这样再次安装nginx的话,和原来的版本没有冲突吗?

直接安装的nginx的启动方法是

sudo service nginx start
sudo service nginx restart
sudo service nginx stop

通过 passenger-install-nginx-module 安装的nginx的启动方法是

sudo nginx
sudo nginx -s reload
sudo nginx -s stop

【问题2】为什么会有这样的区别呢?

【问题3】在已经存在nginx的系统中,有其它方式安装passenger的nginx module吗?


  1. 这两种启动方式本身来说,对于nginx没太大区别,只是前者使用系统统一的service脚本来启动的。但是基于你的安装方式,我不太确定两者是否使用的同一个nginx安装。判断方式:查看一下 /etc/init.d/nginx 这个脚本的内容,看看大概22行左右,看看nginx路径设置是多少,是否和你第二种直接启动的nginx是一个路径。另外看看NGINX_CONF_FILE路径是否一致

  2. 没有为什么。你可以不使用service方式,直接nginx命令操作,但是前者更方便,管理上更统一。Linux开机自动启动一般也会调用service脚本。

  3. 可以,但是还是必须经过重新编译的过程。但是你需要知道前一次安装nginx的源代码在哪里(自己编译安装的好说;你用apt-get安装的话,我就不知道会不会保留源代码了),知道源代码位置的话,在你上面节选的“Automatically download and install Nginx?”的时候,选择2. No: I want to customize my Nginx installation.,然后安装脚本会让你选择之前源代码位置,增加之前configure的参数(nginx -V可以看到),根据提示再来一遍就可以了。

你根据1的判断,两个nginx要是实际路径是一个的话,就没关系了,启动的话还是建议直接用service脚本。


你多看看文档,这样的问题没有必要问得。

【热门文章】
【热门文章】