您好,登錄后才能下訂單哦!
小編給大家分享一下Ubuntu Apache如何配置安裝與ROR應用,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
我使用的是 Ubuntu Apache-alternate 8.04 命令行安裝模式,下面的腳本適合 debian 系的發行版,理論上不兼容 RedHat 系的發行版。為方便起見,我將安裝 ROR 環境寫了一個 SHELL 腳本,直接執行即可方便的安裝 ROR 環境,這里使用的 RAILS 版本為 2.0.2。
請使用 sudo 前綴執行該腳本:
install_ror.sh - Copy Code#!/bin/bash INSTALL_HOME=~/ror_installer if [ -d "$INSTALL_HOME" ]; then echo INSTALL_HOME directory \"~/ror_installer\" already exist. exit 1 fi mkdir $INSTALL_HOME pushd $INSTALL_HOME # Download files apt-get -d -y install \ ruby libruby-extras \ libyaml-ruby libzlib-ruby libiconv-ruby libxml-ruby \ libdbi-ruby \ libmysql-ruby libdbd-mysql-ruby libdbd-sqlite3-ruby \ libfcgi-ruby1.8
wget -t0 -T15 http://rubyforge.org/download.php/35283/rubygems-1.1.1.tgz wget -t0 -T15 http://rubyforge.org/download.php/29353/actionmailer-2.0.2.gem wget -t0 -T15 http://rubyforge.org/download.php/29350/actionpack-2.0.2.gem wget -t0 -T15 http://rubyforge.org/download.php/29551/activerecord-2.0.2.gem wget -t0 -T15 http://rubyforge.org/download.php/29552/activeresource-2.0.2.gem wget -t0 -T15 http://rubyforge.org/download.php/29553/activesupport-2.0.2.gem wget -t0 -T15 http://rubyforge.org/download.php/29554/rails-2.0.2.gem wget -t0 -T15 http://rubyforge.org/download.php/29751/rake-0.8.1.gem
# Install ruby apt-get -y install \ ruby libruby-extras \ libyaml-ruby libzlib-ruby libiconv-ruby libxml-ruby \ libdbi-ruby \ libmysql-ruby libdbd-mysql-ruby libdbd-sqlite3-ruby \ libfcgi-ruby1.8 # Install rubygems tar xfv rubygems-1.1.1.tgz pushd rubygems-1.1.1 ruby setup.rb ln -s /usr/bin/gem1.8 /usr/bin/gem popd # Install Gem gem install rails -l --no-ri --no-rdoc # Clean popd rm -rf $INSTALL_HOME
2) 安裝 Ubuntu Apache
同樣是 SHELL 腳本安裝,請使用 sudo 前綴執行該腳本:
install_Ubuntu Apache2.sh - Copy Code#!/bin/bash # Download files apt-get -d -y install Ubuntu Apache2 libUbuntu Apache2-mod-fcgid # Install Ubuntu Apache apt-get -y install Ubuntu Apache2 libUbuntu Apache2-mod-fcgid ln -s /etc/Ubuntu Apache2/mods-available/rewrite.load /etc/Ubuntu Apache2/mods-enabled/rewrite.load
3) 配置 Ubuntu Apache
ROR 應用的 Ubuntu Apache 配置,在 /etc/Ubuntu Apache2/Ubuntu Apache2.conf 的末尾添加以下代碼:Ubuntu Apache2.conf - Copy CodeInclude /etc/Ubuntu Apache2/httpd.conf修改 httpd.conf 為以下內容:
httpd.conf - Copy CodeDefaultInitEnv RAILS_ENV production Alias "/redmine" "/var/www/redmine/public/" <Directory "/var/www/redmine/public/"> Options Indexes ExecCGI FollowSymLinks AllowOverride all Order Deny,Allow Allow from All </Directory> <Location /redmine/> AddHandler fcgid-script .fcgi FCGIWrapper "/usr/bin/ruby /var/www/redmine/public/dispatch.fcgi" .fcgi RewriteEngine on RewriteBase /redmine RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.fcgi?$1 [QSA,L] </Location>
4) 配置 ROR 應用
配置 ROR 應用,這里為方便期間,直接使用 sqlite3,ROR 程序為 redmine。請使用 sudo 前綴執行該腳本:
install_app.sh - Copy Code#!/bin/bash INSTALL_HOME=~/install_redmine if [ -d "$INSTALL_HOME" ]; then echo INSTALL_HOME directory \"~/install_redmine\" already exist. exit 1 fi mkdir $INSTALL_HOME # Download files pushd $INSTALL_HOME wget -t0 -T15 http://rubyforge.org/download.php/36468/redmine-0.7.1.tar.gz popd # Install redmine tar xfv $INSTALL_HOME/redmine-0.7.1.tar.gz -C /var/www/ mv /var/www/redmine-0.7.1 /var/www/redmine cp /var/www/redmine/public/dispatch.fcgi.example /var/www/redmine/public/dispatch.fcgi #---- begin database.yml ---- declare -x START_NO=$LINENO; if [ 0 -eq 1 ]; then production: adapter: sqlite3 database: db/production.sqlite3 timeout: 5000 development: adapter: sqlite3 database: db/development.sqlite3 timeout: 5000 test: adapter: sqlite3 database: db/test.sqlite3 timeout: 5000 fi; declare -x END_NO=$LINENO #---- end database.yml ---- awk '{if(NR > ENVIRON["START_NO"] && NR < ENVIRON["END_NO"]) {print}}' \ $0 > /var/www/redmine/config/database.yml pushd /var/www/redmine rake db:create RAILS_ENV="production" rake db:migrate RAILS_ENV="production" #Load redmine's default data echo en > loc rake redmine:load_default_data RAILS_ENV="production" < loc rm -f log/production.log rm -f public/.htaccess popd # Clean rm -rf $INSTALL_HOME
注:如果在 Linux 下部署,并使用 SQLite3 數據庫時,***次訪問 redmine 無法創建匿名用戶,訪問時會發生 500 錯誤,這是屬于 redmine 的問題,要解決此問題,執行以下命令:交互式命令 - Copy Codesudo apt-get install sqlite3
cd /var/www/redmine/db
sudo sqlite3 production.sqlite3
> INSERT INTO users ("created_on", "status", "last_login_on",
"hashed_password", "language", "updated_on", "admin", "type", "firstname",
"lastname", "mail", "auth_source_id", "mail_notification", "login")
VALUES('2008-05-21 04:31:54', 0, NULL, '', '', '2008-05-21 04:31:54', 'f',
'AnonymousUser', '', 'Anonymous', '', NULL, 'f', '');> .exit
sudo Ubuntu Apache2ctl restart
ruby script/server -e production
***,重啟 Ubuntu Apache2:重啟 Ubuntu Apache2 - Copy Codesudo Ubuntu Apache2ctl restart部署看似簡單。
以上是“Ubuntu Apache如何配置安裝與ROR應用”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。