我浏览了一个教程http://craiccomputing.blogspot.com/2010/10/passenger-3-nginx-and-rvm-on-mac-os-x.html,一切正常。没有错误。
Nginx with Passenger support was successfully installed.
The Nginx configuration file (/opt/nginx/conf/nginx.conf)
must contain the correct configuration options in order for Phusion Passenger
to function correctly.
This installer has already modified the configuration file for you! The
following configuration snippet was inserted:
http {
...
passenger_root /home/alex/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.14;
passenger_ruby /home/alex/.rvm/wrappers/ruby-1.9.3-p194/ruby;
...
}
After you start Nginx, you are ready to deploy any number of Ruby on Rails
applications on Nginx.
Run Code Online (Sandbox Code Playgroud)
但是我无法启动它。
alex@ubuntu:~$ sh -x /etc/init.d/nginx start
sh: 0: Can't open /etc/init.d/nginx
sudo /etc/init.d/nginx start
sudo: /etc/init.d/nginx: command not found
Run Code Online (Sandbox Code Playgroud)
该目录opt/nginx存在并且其中有文件。Localhost:80也不起作用。
有什么建议?
d3v*_*kit 20
安装 Rails + NGINX +Passenger + RVM 设置的通常方法通常涉及将 nginx 放置在 /opt/nginx 中,但实际上它不会创建 init.d 启动文件。这篇博文展示了如何从Linode轻松获取一个:
wget -O init-deb.sh https://www.linode.com/docs/assets/660-init-deb.sh
sudo mv init-deb.sh /etc/init.d/nginx
sudo chown root:root /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
sudo /usr/sbin/update-rc.d -f nginx defaults
Run Code Online (Sandbox Code Playgroud)
对于后代,这里是 Linode 的脚本:
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO
PATH=/opt/nginx/sbin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/opt/nginx/sbin/nginx
NAME=nginx
DESC=nginx
test -x $DAEMON || exit 0
# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
. /etc/default/nginx
fi
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile /opt/nginx/logs/$NAME.pid \
--exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /opt/nginx/logs/$NAME.pid \
--exec $DAEMON
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile \
/opt/nginx/logs/$NAME.pid --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --pidfile \
/opt/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
start-stop-daemon --stop --signal HUP --quiet --pidfile /opt/nginx/logs/$NAME.pid \
--exec $DAEMON
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac
exit 0
Run Code Online (Sandbox Code Playgroud)
需要注意的一件事:如果您更改了 nginx.pid 位置(默认为 /opt/nginx/log,我将我的位置更改为 /var/run),您需要在此文件中更改它。在顶部附近,只需将其声明为变量:
PIDPATH=/var/run/$NAME.pid
Run Code Online (Sandbox Code Playgroud)
并用 $PIDPATH 替换具有 pid 路径的任何地方。(即使您保留原始路径,这也会使脚本更具可读性)。
安装nginx 的正常方法是通过apt-get(或 Synaptic 或 SW Center),并且不会在 中放置任何内容/opt,AFAIK。在这种情况下,您可以通过简单地发出以下命令来停止/启动它:
sudo service nginx start|stop|restart (etc)
Run Code Online (Sandbox Code Playgroud)
如果您nginx将其自身安装在 中/opt,我怀疑它会触及该/etc/init.d目录...
| 归档时间: |
|
| 查看次数: |
16763 次 |
| 最近记录: |