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