如前言所述,您不能使用诸如/etc/init.d/nginx
或的初始化脚本service nginx restart
。本节教您如何控制以及如何使用已安装的Nginx。
记得在某个时候,passenger-install-nginx-module
问过您在哪里安装Nginx,并询问您“前缀”,对吗?前缀是此新Nginx的安装目录。默认情况下,安装程序选择目录/opt/nginx
。在本节中,我们假设您已安装到默认的前缀目录。如果您指定了不同的前缀,只需将/ opt / nginx替换为实际目录即可。
然后,Nginx的配置文件位于中/opt/nginx/conf
。其日志文件位于中/opt/nginx/logs
。
您可以通过运行以下命令启动Nginx:
$ sudo / opt / nginx / sbin / nginx
您可以通过使用kill
命令杀死Nginx的PID来关闭它。要找出Nginx的PID是什么,请使用ps
命令。例如:
$ ps auxw | grep nginx
root 3254 0.0 0.0 46644 1448 ? Ss 12:55 0:00 nginx: master process /opt/nginx/sbin/nginx
ubuntu 3257 0.0 0.3 49188 6332 ? S 12:55 0:00 nginx: worker process
ubuntu 7906 0.0 0.0 13772 1056 pts/1 S+ 13:26 0:00 grep --color=auto nginx
或者是
$ sudo netstat -ntpl
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 745/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1168/sshd
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 27465/postgres
这里,我们看到Nginx主进程具有PID 25817(您可以忽略工作进程),因此我们运行:
$ sudo kill PID
重新启动Nginx与关闭Nginx,然后重新启动相同。例如:
$ sudo /opt/nginx/sbin/nginx
$ / opt / nginx / sbin / nginx -t
nginx: the configuration file /opt/nginx/sbin/nginx/nginx.conf syntax is ok
nginx: configuration file /opt/nginx/sbin/nginx/nginx.conf test is successful
因为之前我的rails工程都提交到github或者bitbucket上了(如何提交至git此处不再赘述,请查阅相关文章),所以直接通过git的方式把代码下载到server上即可
$ git clone https://XXXXXX/project.git (在github或bitbucket上面就可以找到,直接复制
这样代码就下载到服务器上了,然后安装gem
$ cd project
$ bundle install
创建数据库用户
sudo -u postgres createuser -s appname
创建生产环境数据库并执行迁移
$ RAILS_ENV=production rake db:create $ RAILS_ENV=production rake db:migrate
原文:https://www.cnblogs.com/shxx/p/12110865.html