I’ve been trying to get my vps to run my railsapp according to this tutorial: https://gorails.com/deploy/ubuntu/16.04
The setup is to make a deploy server where I can deploy my rails app thru using ssh. Much like deploying to Heroku would go.
At this point everything seems to be running without any errors.
Nginx shows this.
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.
But for some reason in the browser when I go to the ip-address of my server I get a default page by Plesk. Which a standard web platform installed on my Linux Ubuntu 16.04 server.
I reckon that /etc/nginx/sites-enabled/default must be where the problem might be. This is how looks like now:
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;
}
}
Then I found that there’s also /etc/nginx/sites-available/default which would normally show the default nginx page. This is how it looks like:
##
# 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;
# }
#}
And finally this is what /etc/nginx/nginx.conf shows:
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;
# }
#}
Does someone know how I keep getting the Plesk default page. My rails app has already been successfully deployed thru capistrano: cap production deploy
I’ve seen that all my app files are on the server. So there’s just one final link missing and I haven’t been able to find it yet. Does someone know what it is?
Thank you for your support.
2
Answers
Every time you change configs, you must restart service, to apply changes.
I also preferencji to use local DNS and nginx’s blocks (equivalent to apache’s virtual hosts), so you can run multiple sites.
As per Ubuntu (or Debian) Apache and Nginx config structure, to activate a domain configuration, you should have it in
/sites-enabled/
.Usually there are symbolic links to the same config file in
/sites-available/
:Then you will most likely to have permissions issues. Make sure that your
./public
directory is accessible for nginx user.Plesk Onyx is shipped with Ruby on Rails, Passenger and PostgeSQL. You can adapt this instruction to perform all actions via Plesk GUI. I would suggest starting from scratch with the following action plan: