根据本教程,我一直在努力让我的vps运行我的railsapp:https://gorails.com/deploy/ubuntu/16.04
设置是创建一个部署服务器,我可以使用ssh部署rails应用程序。就像部署到Heroku一样。
此时一切似乎都在运行,没有任何错误。 Nginx展示了这一点。
deploy@localhost:~$ sudo service nginx status
[sudo] password for deploy:
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2018-04-16 21:06:26 CEST; 11h ago
Process: 1670 ExecStop=/bin/sleep 1 (code=exited, status=0/SUCCESS)
Process: 1666 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry TERM/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 1677 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 1674 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 1680 (nginx)
Tasks: 3
Memory: 7.0M
CPU: 69ms
CGroup: /system.slice/nginx.service
├─1680 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
├─1681 nginx: worker process
└─1682 nginx: worker process
Apr 16 21:06:26 localhost systemd[1]: Starting A high performance web server and a reverse proxy server...
Apr 16 21:06:26 localhost systemd[1]: Started A high performance web server and a reverse proxy server.
但是出于某种原因,当我转到我的服务器的ip-address时,浏览器中的某个原因我得到了Plesk的默认页面。我的Linux Ubuntu 16.04服务器上安装了哪个标准Web平台。
我认为/ etc / nginx / sites-enabled / default必须是问题所在。这就是现在的样子:
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name mydomain.com;
passenger_enabled on;
rails_env production;
root /home/deploy/palazon/current/public;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
然后我发现还有/ etc / nginx / sites-available / default,这通常会显示默认的nginx页面。这就是它的样子:
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
# fastcgi_pass unix:/run/php7.0-fpm.sock;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
最后这是/etc/nginx/nginx.conf显示的内容:
user deploy;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
# ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Phusion Passenger config
##
# Uncomment it if you installed passenger or passenger-enterprise
##
include /etc/nginx/passenger.conf;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
有人知道我如何继续获取Plesk默认页面。我的rails应用程序已经通过capistrano成功部署:cap production deploy
我已经看到我的所有应用文件都在服务器上。所以只有一个最后的链接丢失了,我还没能找到它。有人知道它是什么吗?
感谢您的支持。
答案 0 :(得分:0)
每次更改配置时,都必须重新启动服务,才能应用更改。 我还首选使用本地DNS和nginx的块(相当于apache的虚拟主机),因此您可以运行多个站点。
答案 1 :(得分:0)
根据Ubuntu(或Debian)Apache和Nginx配置结构,要激活域配置,您应该在/sites-enabled/
中使用它。
通常在/sites-available/
中有相同配置文件的符号链接:
# ls -la /etc/nginx/sites-enabled/
lrwxrwxrwx 1 root root 35 Sep 17 2016 example.com.conf -> ../sites-available/example.com.conf
然后,您很可能会遇到权限问题。确保nginx用户可以访问您的./public
目录。
Plesk Onyx附带Ruby on Rails,Passenger和PostgeSQL。您可以调整此指令以通过Plesk GUI执行所有操作。我建议从头开始使用以下行动计划: