1024programmer Nginx UbuntuServer10.10 installation and configuration RVMRubyRails3passengerNgi

UbuntuServer10.10 installation and configuration RVMRubyRails3passengerNgi

1. Update the system as a non-root user

sudo apt-get update
sudo apt-get upgrade
2. Set the host name, if the system is installed graphically, this step can be ignored
sudo hostname your-hostname

Add 127.0.0.1 your-hostname:

sudo vim /etc/hosts

Write your-hostname in:

sudo vim /etc/hostname

Verify that hostname is set:

hostname

3. Install git &curl as non-root

The new ubuntu system needs to install these packages;

sudo apt-get install curl git

4. Install RVM

$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

add below to your .bashrc.

[[ -s “$HOME/.rvm/scripts/rvm” ]] && .
“$HOME/.rvm/scripts/rvm”

Once you edit your bashrc file execute the following to load rvm
without logging out and back in

Delete all returns in ~/.bashrc, [ -z “$PS1” ] && return
Change to [ -z “$PS1” ]

run:

source ~/.rvm/scripts/rvm

Just to be safe check wether rvm is a function, which is what it
should be.

5. Install ruby ​​1.9.2
sudo aptitude “bash functions”>install
“bash plain”>build-essential bison openssl libreadline5 libreadline5-dev curl git-core zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libmysqlclient-dev
rvm “bash functions”> install
“bash plain”>1.9.2
rvm use 1.9.2 –default
6. Install rails3
gem install rails
7. Install passenger and nginx
gem install passenger
rvmsudo passenger-install-nginx-module
This step requires some required softwares, you can follow the prompts to complete
8 test nginx
8.1 Check the installation result of nginx:
sudo vi /opt/nginx/conf/nginx.conf
Make sure the following is ruby ​​1.9.2 (starting with
“bash plain”>rvm use 1.9.2 –default keep the same) and passenger 3
http {
Passenger_root /home/leslin123/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.3;
Passenger_ruby /home/leslin123/.rvm/wrappers/ruby-1.9.2-p180/ruby;
8.2 Startup
sudo /opt/nginx/sbin/nginx
open
Welcome interface of nginx: http://localhost/
If you see: Welcome to nginx! , then congratulations!
9. Install latest version MySQL
sudo apt-get install mysql-server mysql-client
This step takes a lot of time, since the software needs to be downloaded is more than 20M
Set the corresponding password for root according to the prompt, 3344***
10. Create a rails application
In the current user directory, such as /home/les***/rorails create
rails new helloubuntu
Enter the application directory and run bundle install
At this time sqllite3 will be installed
11. Run rails server
The startup log is:
leslin123@ubuntuServerofLeslin:~/rorails/helloubuntu$ rails server
=> Booting WEBrick
=> Rails 3.0.4 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-02-26 11:28:38] INFO WEBrick 1.3.1
[2011-02-26 11:28:38] INFO ruby ​​1.9.2 (2011-02-18) [x86_64-linux]
[2011-02-26 11:28:38] INFO WEBrick::HTTPServer#start: pid=14429 port=3000
Open the directory http://localhost:3000/, you can see the rails welcome interface, but this just means that the rails configuration is successful.
Clearly, neither the desired web server nor the database is configured!
12. Configuring MySQL
rails new helloMySQL -d mysql
cd ./helloMySQL
Question:
rails server
Could not find gem ‘mysql2 (>= 0, runtime)’ in any of the gem sources listed in your Gemfile.
Solution:
bundle update
Installing mysql2 (0.2.6) with native extensions
Enter the application directory and add the root password to database.yml, otherwise the following type will appear after startup, the numberDatabase connection error;
Access denied for user ‘root’@’localhost’ (using password: NO)
rake db:create
rails server
Open the welcome interface http://0.0.0.0:3000/; Click: About your application’s environment
View related information, including: Database adaptermysql2
Ok, now there is one last item left.
13. Configure nignx server
Those who are serious can see the following tips when installing Nignx:
——————————————********** *******************************************———– —————————
——————————————–
Nginx with Passenger support was successfully installed.
The Nginx configuration file (/opt/nginx/conf/nginx.conf)
must contain the correct configuration options in order for Phusion Passenger to function correctly.
This installer has already modified the configuration file for you! The
The following configuration snippet was inserted:
http {

Passenger_root /home/leslin123/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.3;
Passenger_ruby /home/leslin123/.rvm/wrappers/ruby-1.9.2-p180/ruby;

}
After you start Nginx, you are ready to deploy any number of Ruby on Rails applications on Nginx
Press ENTER to continue.
——————————————–
Deploying a Ruby on Rails application: an example
Suppose you have a Ruby on Rails application in /somewhere. Add a server block
to your Nginx configuration file, set its root to /somewhere/public, and set
‘passenger_enabled on’, like this:
server {
listen 80;
server_name www.yourhost.com;
root /somewhere/public; # <— be sure to point to 'public'!
Passenger_enabled on;
}
And that’s it! You may also want to check the Users Guide for security and optimization tips and other useful information:
/home/leslin123/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.3/doc/Users guide Nginx.html
——————————————********** *******************************************———– —————————
Configuration: /opt/nginx/conf/nginx.conf
http {
Passenger_root /home/leslin123/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.3;
Passenger_ruby /home/leslin123/.rvm/wrappers/ruby-1.9.2-p180/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name localhost;
root /home/leslin123/rorails/helloMySQL/public; #Set app directory
Passenger_enabled on;
Rails_env development; #Set as development environment, default is production environment

#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
# root /home/leslin123/rorails/helloMySQL/public;
# index index.html index.htm;
#}

Configure Nginx as a startup item:
curl -L http://bit.ly/nginx-ubuntu-init-file > /etc/init.d/nginx
leslin123@ubuntuServerofLeslin:~$ sudo chmod +x /etc/init.d/nginx
leslin123@ubuntuServerofLeslin:~$ sudo /usr/sbin/update-rc.d -f nginx defaults
System start/stop links for /etc/init.d/nginx already exist.
leslin123@ubuntuServerofLeslin:~$ sudo /etc/init.d/nginx start
* Starting Nginx Server.
Enter the project and build scaffolding:
~/rorails/helloMySQL$ rails generate scaffold Post name:string title:string content:text
rake db:create
rake db:migrate
http://localhost/
http://localhost/posts

p; # root /home/leslin123/rorails/helloMySQL/public;
# index index.html index.htm;
#}
Configure Nginx as a startup item:
curl -L http://bit.ly/nginx-ubuntu-init-file > /etc/init.d/nginx
leslin123@ubuntuServerofLeslin:~$ sudo chmod +x /etc/init.d/nginx
leslin123@ubuntuServerofLeslin:~$ sudo /usr/sbin/update-rc.d -f nginx defaults
System start/stop links for /etc/init.d/nginx already exist.
leslin123@ubuntuServerofLeslin:~$ sudo /etc/init.d/nginx start
* Starting Nginx Server.
Enter the project and build scaffolding:
~/rorails/helloMySQL$ rails generate scaffold Post name:string title:string content:text
rake db:create
rake db:migrate
http://localhost/
http://localhost/posts

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/ubuntuserver10-10-installation-and-configuration-rvmrubyrails3passengerngi/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索