Deployment of applications using nginx + mongrel + rails + Ubuntu

Source: Internet
Author: User
Tags exit in

I know that there are many backend servers, but to correspond to Windows release, here the backend is mongrel...

Ideas:1. mongrel runs rails as a daemon

2. install and configure nginx

 

 1. mongrel runs rails as a daemon

1. Install mongrel

 
Gem 'mongrel'

2. Use nohup to run commands in the background

Write rails_env.bat and store it under/opt/. The content is

 
 
CD/workspace/svnms/usr/local/bin/rails s mongrel-P 3003-B 127.0.0.1

Then use nohup to run in the background

 
Nohup/opt/rails_svnms.bat &

AvailableJobsCommand to view the background running process

UseFN % NCommand to close the background running process

Note:After running the nohup command, when the shell prompts that the nohup is successful, you need to press any key on the terminal keyboard to return to the shell input command window, and then enter exit in the shell to exit the terminal;

 

Ii. install and configure nginx

1. Install nginx

 
Sudo apt-Get install nginx

After Ubuntu is installed, the file structure is roughly as follows:

    • All configuration files are under/etc/nginx, and each virtual host is already under/etc/nginx/sites-available.
    • ProgramFile in/usr/sbin/nginx
    • Logs are stored in/var/log/nginx.
    • The Startup Script nginx has been created under/etc/init. d /.
    • The default virtual host directory is/var/www/nginx-default (in some versions, the default virtual host directory is/var/WWW, see the configuration in/etc/nginx/sites-available)

2. Start nginx

 
Sudo/etc/init. d/nginx start

3. Configure nginx

Server {Listen 8083; SERVER_NAME liuwm-pc@grandsoft.com.cn; root/workspace/svnms/public; Location/{root/workspace/svnms/public; proxy_set_header host $ HOST: 8083; export X-real-IP $ remote_addr; export X-forwarded-for $ remote_addr; proxy_pass http: // 127.0.0.1: 3003/; proxy_set_header X-forwarded-Proto HTTPS; proxy_redirect off ;} # SSL on; ssl_certificate/var/www/SSL/server. CRT; ssl_certificate_key/var/www/SSL/server. key; ssl_client_certificate/var/www/SSL/CA. CRT; error_page 500 502 503 504/50 x.html; location =/50x.html {root HTML ;}}

 

Iii. Starting mongrel with rails and nginx

After Ubuntu is started, it will execute the script in the/etc/rc. Local file, so we can directly add the startup script in/etc/rc. Local.

Of course, you must add it to the statement before exit 0.

Add a script before exit 0.Code.

 
Nohup/opt/rails_svnms.bat & sudo/etc/init. d/nginx start

Refer:Use the nohup command to make the Linux program execute the http://www.linuxidc.com/Linux/2009-05/19963p2.htm in the background

Ubuntu nginx http://wiki.ubuntu.org.cn/Nginx

Ubuntu add Automatic startup program method http://www.linuxidc.com/Linux/2010-08/27668.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.