官术网_书友最值得收藏!

Running Redmine with Phusion Passenger

Phusion Passenger is a Ruby application server that was originally designed to run web applications (such as Redmine) that were built on the Ruby on Rails framework. Nowadays it has evolved, and besides Ruby applications, it supports Python and Node.js, making it a good candidate for various use cases.

This recipe is written for the Ubuntu 14.04 server.

Getting ready

Make sure that you have Apache and passenger installed:

sudo apt-get install apache2 libapache2-mod-passenger

How to do it…

To configure Passenger, perform the following steps:

  1. Open /etc/apache2/mods-available/passenger.conf with your favourite editor, or use nano:
    nano /etc/apache2/mods-available/passenger.conf
    
  2. Add the following line: PassengerDefaultUser www-data.
  3. So, your passenger.com will look something like this:
    <IfModule mod_passenger.c>
      PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
      PassengerDefaultRuby /usr/bin/ruby
      PassengerDefaultUser www-data
    </IfModule>

    Tip

    If you are using a different Ruby version installed via RVM, update the paths accordingly. Also replace www-data with your user.

    Please keep in mind that PassengerDefaultUser can be entered in your virtual server's config file, which you may need to edit manually for installations on shared hosting.

  4. Create a symbolic link to the Redmine public folder from a web server's root folder like this:
    sudo ln -s /usr/share/redmine/public /var/www/html/redmine
    
  5. This link assumes that you installed Redmine through apt-get. If this is not the case and you installed it somewhere else such as /home/user/redmine, then you must adjust your links according to your Redmine installation and www root, which may look something like this (for example):
    ln –s /home/user/redmine/public /home/user/public_html/redmine
    
  6. Make sure that passenger is enabled in Apache:
    sudo a2enmod passenger
    
  7. Modify /etc/apache2/sites-available/000-default.conf by typing the following:
    sudo nano /etc/apache2/sites-available/000-default.conf
    
  8. Add the following content near other Directory sections; if there are none, just make sure it's added before closing the </VirtualHost> line:
    <Directory /var/www/html/redmine>
        RailsBaseURI /redmine
        PassengerResolveSymlinksInDocumentRoot on
    </Directory>
  9. Install bundler by typing the following:
    sudo gem update && sudo gem install bundler
    
  10. Finish the installation and restart Apache:
    sudo touch /usr/share/redmine/Gemfile.lock
    sudo chown www-data:www-data /usr/share/redmine/Gemfile.lock
    sudo service apache2 restart
    

After restarting Apache, your Redmine installation should be ready to access by going to http://your_server/redmine.

How it works…

First, you installed Apache web server and Phusion Passenger as a Ruby application server, which runs as an Apache module. Then you edited Apache's configuration file for Passenger by adding the default user to be www-data. After this, we created a symbolic link from Redmine's public directory to the web server's root directory. Then, we edited the virtual server's config to serve this particular directory with two Redmine-related configs – RailsBaseURI/redmine, —which tells Ruby on Rails to access Redmine via the /redmine subfolder, and PassengerResolveSymlinksInDocumentRoot tells Passenger to follow symlink to find a Rails application through the symlink path. Instead of this, you could have written the following:

PassengerAppRoot /usr/share/redmine/

Redmine would work the same way.

There's more…

The best way to run Redmine or any other web-exposed software is to run it as a restricted user from its home directory and adjust Apache or any other web server to serve data from this directory. Running Redmine as a subdomain such as http://redmine.yoursite.com, is done by creating an ordinary subdomain, and an Apache virtual host file for this subdomain with the settings that are provided in this recipe.

See also

If you stumble upon an error such as 403 (forbidden), error 500, or if you see Ruby code on the screen or the Passenger error screen, but you have followed the preceding steps exactly, refer to Troubleshooting Apache installations section in Chapter 9, Troubleshooting.

If you need to run Redmine as sub-uri, then take a look at http://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_in_a_sub-URI.

主站蜘蛛池模板: 肥乡县| 广河县| 阆中市| 南通市| 句容市| 保定市| 青海省| 曲水县| 南岸区| 龙海市| 金山区| 临夏市| 东方市| 利辛县| 行唐县| 英德市| 漠河县| 楚雄市| 苏尼特左旗| 望都县| 尼勒克县| 开江县| 东台市| 凤山县| 海城市| 台州市| 武胜县| 称多县| 宜都市| 柯坪县| 安平县| 柳河县| 东乌珠穆沁旗| 洪雅县| 江永县| 成安县| 阳泉市| 哈尔滨市| 济源市| 新邵县| 鄢陵县|