ubuntu - 通过 passenger-install-nginx-module 安装的 nginx 和直接安装的 nginx 有什么区别?
PHP中文网
PHP中文网 2017-04-22 08:55:48
0
2
806

系统中的 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吗?

PHP中文网
PHP中文网

认证0级讲师

全部回覆(2)
阿神
  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腳本。

迷茫
  • 透過 passenger-install-nginx-module,安裝的 nginx和原來是沒有衝突的,相當於在別目錄又裝了一個 nginx。

  • 之所以有這樣的差異是因為一個服務啟動腳本,一個直接是程式。

  • 已經安裝 nginx 的系統絕對可以安裝 passenger

你多看看文檔,這樣的問題沒有必要問得。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!