Gitlab on Apache2 with SSL - apache

I have successfully installed Gitlab on Ubuntu 14.04 using https://about.gitlab.com/downloads/#ubuntu1404 but I am struggling to make redirect and access it through web (https://my.example.com/gitlab).
I have modified /etc/gitlab/gitlab.rbto:
external_url 'https://my.example.com/gitlab'
nginx['enable'] = false
And reconfigured with sudo gitlab-ctl reconfigure
If I uncomment:
web_server['external_users'] = ['www-data']
I get:
Recipe Compile Error in
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/default
NoMethodError
------------- undefined method `-' for nil:NilClass
Cookbook Trace:
--------------- /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/config.rb:21:in
from_file'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb:26:in
from_file'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/default.rb:18:in
`from_file'
Relevant File Content:
---------------------- /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/config.rb:
14: # See the License for the specific language governing
permissions and 15: # limitations under the License. 16: # 17:
18: Gitlab[:node] = node 19: 20: if
File.exists?('/etc/gitlab/gitlab.rb') 21>>
Gitlab.from_file('/etc/gitlab/gitlab.rb') 22: end 23: 24:
node.consume_attributes(Gitlab.generate_config(node['fqdn'])) 25:
I have tried adding various gitlab.conf to /etc/apache2/sites-available/ but https://my.example.com/gitlab does not redirect to Gitlab login page, I get 'Page not found' from Redmine service which runs on home page. Current default-ssl.conf uses DocumentRoot /var/www while Gitlab DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public. Apache2 is configured to use SSL.
UPDATE 1
I have made symlink:
sudo ln -s /opt/gitlab/embedded/service/gitlab-rails/public /var/www/gitlab
So now it can be configured in default-ssl.conf.
Alias /gitlab "/var/www/gitlab"
Does not forward to Gitlab homepage, while
Alias /gitlab "/var/www/gitlab/deploy.html"
works well. What is Gitlab home page directory? Where is index.html file?
UPDATE 2
If I add
RackBaseURI /gitlab
RailsBaseURI /gitlab
<Directory /var/www/gitlab>
Allow from all
Options -MultiViews
</Directory>
I get error after entering https://my.example.com/gitlab/
Web application could not be started
It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:
bundle install
If that didn't work, then the problem is probably caused by your application > being run under a different environment than it's supposed to. Please check > the following:
Is this app supposed to be run as the www-data user?
Is this app being run on the correct Ruby interpreter? Below you will see which Ruby interpreter Phusion Passenger attempted to use.
-------- The exception is as follows: -------
Could not find rake-10.5.0 in any of the sources (Bundler::GemNotFound)
/var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/spec_set.rb:95:in block in materialize'
/var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/spec_set.rb:88:inmap!'
/var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/spec_set.rb:88:in materialize'
/var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/definition.rb:140:inspecs'
/var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/definition.rb:185:in specs_for'
/var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/definition.rb:174:inrequested_specs'
The exception above was solved after updating Ruby.
UPDATE 3
Now I get
with
Alias /gitlab "/var/www/gitlab"
AllowEncodedSlashes NoDecode
<Directory /var/www/gitlab>
Options Indexes FollowSymLinks MultiViews
PassengerAppRoot "/var/www/gitlab"
RailsBaseURI /var/www/gitlab
AllowOverride None
Order allow,deny
allow from all
</Directory>
How to configure Gitlab and Apache2 to get Gitlab first page when entering https://my.example.com/gitlab?

It sounds like your Apache configuration is not proxying to the GitLab server on port 8080 (unicorn). There are example Apache configuration files available at https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/web-server/apache.
There's also a good post explaining the steps to use Apache with GitLab Omnibus at http://ryansechrest.com/2015/08/use-apache-instead-of-built-in-nginx-in-gitlab-ce/. It's a little over a year old, so the Apache configuration may be a little outdated. Use the guide, but substitute the Apache configuration from the gitlab-recipes link above and it should work.

I had other service working on 8080 so I have changed Unicorn port to 9099.
Modified Gitlab configuration sudo nano /etc/gitlab/gitlab.rb:
external_url 'https://subdomain.example.com/gitlab'
web_server['username'] = 'apache' #'gitlab-www'
web_server['group'] = 'apache' #'gitlab-www'
nginx['enable'] = false
unicorn['listen'] = '127.0.0.1'
unicorn['port'] = 9099
Reconfigured Gitlab: sudo gitlab-ctl reconfigure
Modified Apache configuration sudo nano /etc/apache2/apache2.conf with adding:
ProxyPass /gitlab http://127.0.0.1:9099/gitlab
ProxyPassReverse /gitlab http://127.0.0.1:9099/gitlab
RequestHeader add X-Forwarded-Proto https
Reloaded it:
sudo service apache2 reload

Related

Passenger directives not working in Apache 2.4 .htaccess

I am trying to load a NodeJS App from Apache+Passenger.
OS: Centos 7 / CloudLinux release 7.9
Apache: 2.4.6 ( httpd-2.4.6-97.el7_9.cloudlinux.x86_64 )
Passenger: Phusion Passenger 6.0.7 ( passenger-6.0.7-1.el7.x86_64, mod_passenger-6.0.7-1.el7.x86_64 ) from Passenger's Yum repo
The virtual host points to /home/vhost1/public_html and the NodeJS App points to /home/vhost1/nodeapps/np1-pass/np1-pass.js
When I run this config via Passenger entries in Apache's config, the application works and is accessible from http://virtual-host/np1-pass/ .
The entry in Apache's config is as under :
<VirtualHost *:80>
ServerName virtual-host
DocumentRoot /home/vhost1/public_html
<Directory /home/vhost1>
# Relax Apache security settings
AllowOverride all
Require all granted
# MultiViews must be turned off
Options -MultiViews
</Directory>
<Directory /home/vhost1/public_html>
# Relax Apache security settings
AllowOverride all
Require all granted
# MultiViews must be turned off
Options -MultiViews
</Directory>
Alias /np1-pass /home/vhost1/nodeapps/np1-pass/public
<Location /np1-pass>
PassengerAppEnv development
Passengerapproot /home/vhost1/nodeapps/np1-pass
PassengerBaseURI "/np1-pass"
PassengerNodejs "/home/vhost1/bin/node"
PassengerAppType node
PassengerStartupFile np1-pass.js
</Location>
</VirtualHost>
What now I have been trying was to move over Passenger directives to the .htaccess file under /home/vhost1/public_html/np1-pass (of-course after removing those directives and the alias and location entry from the Apache config) so that a virtual host owner is able to fire the application without modifying Apache's config, then I get the error
PassengerAppRoot not allowed here, referer: http://virtual-host/np1-pass/
A similar .htaccess works fine for CloudLinux 7 on a cPanel server with Passenger ea-apache24-mod-alt-passenger-5.3.7-9.el7.cloudlinux.x86_64 package installed
When I was looking into various solutions, I came across two documents
https://www.phusionpassenger.com/docs/references/config_reference/apache/#passengerapproot
https://www.phusionpassenger.com/library/config/apache/reference/#passengerapproot
W.r.t. Passenger directives in the 1st link document, under the directive's context .htaccess is missing . But same is present in the 2nd link document
Now I have 2 questions
Are both documents correct or am I missing something. ?
And why the same setup is working fine on CloudLinux 7 on a cPanel server with Passenger ea-apache24-mod-alt-passenger-5.3.7-9.el7.cloudlinux.x86_64 package installed ?
Thanks
Kirti Singh
W.r.t. the question
Are both documents correct or am I missing something. ?
I can't say about that, but I found this useful link https://blog.phusion.nl/2018/01/29/passenger-5-2-0/ which states that many Passenger .htaccess directives have been disabled since Passenger 5.2.0 . But still as both links mentioned in the original question do exist, those links should have had a version prefixed or there should have been a clarification in their content.
Now w.r.t. the 2nd question
And why the same setup is working fine on CloudLinux 7 on a cPanel server with Passenger ea-apache24-mod-alt-passenger-5.3.7-9.el7.cloudlinux.x86_64 package installed ?
I can't say how CloudLinux is doing it, but I was able to run passenger directives via .htaccess by uninstalling the passenger 6.0.7 and the corresponding mod_passenger , and then by installing the old passenger version 5.1 and its corresponding mod_passenger
`yum remove passenger
yum install passenger-5.1.12-1.el7
yum install mod_passenger-5.1.12-1.el7`
This solved my problem and now I am able to load NodeJS apps via .htaccess
I hope my answer helps others who struggle with this issue.

How to add a domain name in local with Apache?

I have a website which I used to deploy in localhost running the command: sudo /etc/init.d/apache2 start and then typing the URL: http://XXX/myfirstphpsite/src where XXX is my IP address and myfirstphpsite/src the repertory containing my website.
However, now I want to type the following URL:
http://pharaohohparis.tld instead of the last URL to deploy in local my website.
For that, I did the following:
I went to the repertory: /etc/apache2/sites-available/ and created a new file named: pharaohofparis.tld.conf in which I inserted:
<VirtualHost *:80>
ServerName pharaohofparis.tld
DocumentRoot /var/www/html/myfirstphpsite/src
<Directory /var/www/html/myfirstphpsite/src>
Options Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I actived the virtual host by typing:
sudo a2ensite pharaohofparis.tld.conf
sudo service apache2 reload
I edited the file /etc/hosts by adding the line:
127.0.0.1 pharaohofparis.tld
However, when I type the URL: http://pharaohofparis.tld, I got the DNS error "DNS_PROBE_FINISHED_NXDOMAIN". How can I fix this ?
EDIT: THE PROBLEM WAS LINUX SUBSYSTEM. THERE WAS NO PROBLEM IS A REAL UBUNTU.
As I said in my Edit above: the problem was apparently Linux Subsystem. There was no problem is a real Ubuntu.

How do I set up a web.py apache2 server on an amazon linux ubuntu 13.04 server?

Web.py is free and lightweight. Amazon also provides you with a free web service for a year. How do I set up apache2 onto my server?
*EDIT: Formatting this is impossible. I'll try to do it later. I have such a beautifully written .txt file with fantastic formatting.
I apologize if this isn't thorough. I worked through how to set it up for my very specific setup. However, some of the annoying tricks are solved and may help you on your journey to set it up!!!
I won't walk you through signing up for amazon. There are a million tutorials out there.
Make sure you have an amazon ec2 instance up and running for ubuntu 13.04. Once you're logged in and have your instance launched, get the following going
*I've omitted some numbers as they are specific to our application and don't help.
Give yourself root access
sudo su (if you do this you dont need to sudo anything)
Get Apache 2
apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert
Get Pip
apt-get install python-pip
Get web.py
pip install web.py
Get MySQL
apt-get install python-mysql.connector python-mysqldb mysql-client-core-5.5 mysql-server
set password to: whatever password you want
Get mod_wsgi
apt-get install libapache2-mod-wsgi
6.1 Check to see its working
service apache2 restart
put ip address in web browser to see if it works
enable mod_rewrite
a2enmod rewrite
SFTP (filezilla)
8.1 Giving permissions to allow filezilla in
cd /var/www
mkdir legal #this is our main directory. Name it whatever you want
chown -R ubuntu /var/www/
chmod -R 755 /var/www/
8.2 Connecting in Filezilla
Open Site manager
host: some ip like 54.213.173.233
Port: 22
Protocol: SFTP
Login Type: Normal
User: Ubuntu
Pass: empty
Edit -> Setting -> SFTP: add your key
8.3 Add all of your code Using Filezilla
9 Modifying your code:
go to your main.py
9.1 Wsgifunc()
#add these somewhere in your main file
app = web.application(urls, globals(),autoreload=False)
application = app.wsgifunc()
web.config.debug = True # Change to False
db = web.database(dbn='mysql', host='127.0.0.1', port=3306, user='user goes here', pw='pas goes here', db='')
9.2 Ensure python can find all of your files
AT THE TOP OF YOUR FILE
import os
import sys
root = os.path.join(os.path.dirname(file)+"/")
sys.path.insert(0, root)
modules = os.path.join(os.path.dirname(file)+"/server/")
sys.path.insert(1, modules)
os.chdir(root)
os.environ["SCRIPT_NAME"] =''
os.environ["REAL_SCRIPT_NAME"] = ''
Configuration of apache
cd /etc/apache2/sites-available
10.1 Changing the default file
vim default
change everything to:
*our main folder is called /legal. In it we have our icons and favicons and such in /static. Change these accordingly
ServerAdmin webmaster#localhost
DocumentRoot /var/www/legal/
DirectoryIndex main.py
WSGIScriptAlias / /var/www/legal/
Alias /static /var/www/legal/static/
Options FollowSymLinks
AllowOverride None
Options +Indexes +FollowSymLinks +MultiViews
#changed from non to FileInfo
AllowOverride FileInfo Options
Order allow,deny
allow from all
#ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
#
# AllowOverride None
# Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
# Order allow,deny
# Allow from all
#
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel info
CustomLog ${APACHE_LOG_DIR}/access.log combined
10.2 Test to see if there are errors
apachectl configtest
10.3 Monitor For errors when messing with config files (optional)
tail -f /var/log/apache2/error.log
and
11 Creating a .htaccess file
cd /var/www/legal #this is where our main file is located
vim .htaccess
Then add:
SetHandler wsgi-script
Options +ExecCGI +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^favicon.ico$
RewriteCond %{REQUEST_URI} !^(/.*)+main.py/
RewriteCond %{REQUEST_URI} !^(/.)+.(css|png|js|jpg|ttf|otf|gif|ico)$
RewriteRule ^(.)$ main.py/$1 [PT]
#for reals, it never copies correctly... just a heads up
12 Setting up the database
cd /var/www/legal/server/subapplications
mysql -u root -p'whatever password you want'
12.1 create the database in sql
create database intravires;
###do whatever you need to do here
quit
13 Restart
service apache2 restart
13.1 If broken,Check the logs:
tail -f /var/log/apache2/error.log
14 Profit!

Apache/xampp command line start error: AH00436: No installed service named "Apache2.4"

I installed Apache server on Windows 7 Pro with Xampp distribution. Apache starts fine from the XAMPP Control Panel, but I want to be able to control it from a command prompt. When I try to start it from the command prompt, I am getting the following error:
C:\>httpd -k start
[Fri Jun 14 13:21:59.055815 2013] [mpm_winnt:error] [pid 6344:tid 144] (OS 2)The system cannot find the file specified. : AH00436: No installed service named "Apache2.4".
I tried to change the Listen port in httpd.conf. It does not change anything. Any clues ?
Thanks.
I had absolutely the same problem with the "AH00436: No installed service named “Apache2.4”" after I downloaded Apache 2.4 for Windows and tried to start it the first time.
The solution was very very simple. You get the error message when you manually try to start the webserver by "httpd -k start", but no service was defined yet.
just do a "httpd -k install" and the windows service is added to the registry. after that, the "httpd -k start" works without error message.
I have just got a similar error message when running the same command, but in my case I had just installed wamp from http://www.wampserver.com/en/
C:\wampserver\bin\apache\apache2.4.9\bin>httpd -k start [Mon Sep 29
14:27:05.203039 2014] [mpm_winnt:error] [pid 10720:tid 424] (OS 2)The
system cannot find the file specified. : AH00436: No installed
service named "Apache2.4".
I found that when I used the "-n" switch in the command line
to include the name of the Apache web server service then it would work.
C:\wampserver\bin\apache\apache2.4.9\bin>httpd -n wampapache64 -k
start
So it seems to me that unless the name of the service is included using the
"-n" switch in the command line it is assumed that the name of the service
to start is "Apache2.4".
In my case I did not have a service called Apache2.4, so the command failed.
I do have a service called wampapache64 though, so when I specified that
service name in the command line it ran without error.
I resolved the problem by installing the apache service. For apache, when i went to Apache -> Service, i couldn't even start the service, because those lines were disabled... so i installed the service, the line below the horizontal rule line.
Apparently, my apache didn't have allowed access on my computer... (That's when a window popped-up after installing the service asking to "Allow access" for apache on the computer)
Hope this helps.
Update
I'm using wamp, not xampp.
Any action triggered by the option -k (they are called signals), needs the Apache service to exist in Windows services list.
Therefore, if you see this error message, there are only two possible causes:
Your Apache service does not exist
Then just create it with
httpd.exe -h install
Now you should be able to send the restart signal
httpd.exe -k restart
Your Apache service has a custom name
If the service exists, but has a custom name such as "My Awesome Apache Service", then you have to specify that name when you want to send it any signal.
So, if you have installed it with
httpd.exe -k install -n "My Awesome Apache Service"
you have to restart it with
httpd.exe -k restart -n "My Awesome Apache Service"
Here is the solution for your above Error:
Please change the ServerRoot and DocumentRoot directives in httpd.conf file from default path (c:\Apache24) to the zip installation path (current apache24 zip extraction path)
ServerRoot "D:\httpd-2.4.4-win32\Apache24"
DocumentRoot "D:\httpd-2.4.4-win32\Apache24\htdocs"
After that restart the server and try to open the default page
http://example.com:
Please let me know your status on this
Thanks,
Amarnath Polu & Bhaskar
I had the same problem and resolved it in two steps:
First of all, be sure that Apache 2.4 is installed as a service. You can do this by executing Xampp Control Panel as Administrator and clicking the icon in "service" column.
By default, Apache uses 2 ports: 80 and 443. You must be sure these ports are free. In my case, I had in use 443 port (SSL). You can change this by modifiying the Listen port in "conf/httpd.conf" (for standard port) and "conf/extra/httpd-ssl.conf" (for SSL port).
Good Luck!
Greetings.
If you have Skype installed, make sure it uses "alternate ports" as it will take up port 80. If you quit Skype and try to start Wamp, it might work. This was my issue when trying to manually start the httpd-service and getting this error.
The same problem happened to me. When I check using httpd.exe -e warn it showed the error.
Only one usage of each socket address (protocol/network address/port)
is normally permitted : AH00072: make_sock: could not bind to address
[::]:80
Only one usage of each socket address (protocol/network address/port)
is normally permitted : AH00072: make_sock: could not bind to address
0.0.0.0:80
So the error in my case was multiple Listen entries along with Listen 80 in httpd.config. I just comment #Listen 80 and restart the service and problem is solved.
If you don't have VMware ou Skype , follow those steps :
1) in Xampp control panel -> config -> Apache(httpd.conf)
Listen 80
ServerName localhost:80
<Directory />
AllowOverride none
Require all denied
</Directory>
<Directory "C:/xampp/htdocs">
...
Require all granted
</Directory>
<Files ".ht*">
Require all denied
</Files>
<Directory "C:/xampp/cgi-bin">
AllowOverride All
Options None
Require all granted
</Directory>
2) in Xampp control panel -> config -> Apache(httpd-ssl.conf)
Listen 443
<VirtualHost _default_:443>
ServerName localhost:443
3) in Xampp control panel -> config -> Apache(httpd-xampp.conf)
<Directory "C:/xampp/php">
AllowOverride None
Options None
**Require all denied**
<Files "php-cgi.exe">
**Require all granted**
</Files>
</Directory>
<IfModule alias_module>
Alias /licenses "C:/xampp/licenses/"
<Directory "C:/xampp/licenses">
Options +Indexes
<IfModule autoindex_color_module>
DirectoryIndexTextColor "#000000"
DirectoryIndexBGColor "#f8e8a0"
DirectoryIndexLinkColor "#bb3902"
DirectoryIndexVLinkColor "#bb3902"
DirectoryIndexALinkColor "#bb3902"
</IfModule>
**Require all granted**
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
AllowOverride AuthConfig
**Require all granted**
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
Alias /webalizer "C:/xampp/webalizer/"
<Directory "C:/xampp/webalizer">
<IfModule php7_module>
<Files "webalizer.php">
php_admin_flag safe_mode off
</Files>
</IfModule>
AllowOverride AuthConfig
**Require all granted**
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
</IfModule>
4) Find cmd.exe and right click to select run as administrator
5) Type cd C:\xampp\apache\bin (installation path for Xampp)
6) Type httpd -k install
7) Type httpd -k start
8) Start Apache
Solution was pretty straightforward, I had Apache for x86 and PHP for x64, when I reinstalled PHP for x86, this error vanished.
Don't mix Apache and PHP version for different platforms.
For this to work with XAMPP Apache needs to be run as a service.
Open XAMPP control panel (Make sure to "Run as administrator").
Stop Apache.
Click the red cross on the Service column of Apache (so that it becomes a green tick).
Start Apache.
Bonus:
When you do this Apache will start every time you start your PC. If you want to start it manually (as it was before), change Startup Type in service.msc (search bar -> Services) from Automatic to Manual.

How to boot multiple Rails apps on Apache2 with a shared Passenger gem?

I'm attempting to configure Apache V2 to handle two Rails (3.2.2) applications at the same time using VirtualHost directives. I'm doing this on a local laptop. (Ubuntu, Ruby 1.9.2, and Passenger 3.0.12.)
Used the deployment instructions in "Agile Web Development .... Rails", V4. The first simple application booted up w/o problem.
I then created a 2nd simple app with very similar characteristics. Edited /etc/apache2/apache2.conf with a second VirtualHost directive, and edited /etc/hosts to map the 2nd named URL to the same 127.0.0.1 address.
Restarting Apache blows up as shown below:
apache2: Syntax error on line 240 of /etc/apache2/apache2.conf: Cannot load /home/bubby/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.12/ext/apache2/mod_passenger.so into server: /home/bubby/.rvm/gems/ruby-1.9.2-p180/gems/passenger 3.0.12/ext/apache2/mod_passenger.so: cannot open shared object file: No such file or directory
Both apps were bundled with Passenger. "locate mod_passenger.so" returns the correct location. Is there a better way to do this?
does the file
/home/bubby/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
really exist and it's readable for apache?
This is how i setup multiple virtualhosts with passenger:
user#debian:# cat /etc/apache2/mods-enabled/passenger.conf
<IfModule mod_passenger.c>
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p125/ruby
</IfModule>
user#debian:# cat /etc/apache2/mods-enabled/passenger.load
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
user#debian:# cat /etc/apache2/sites-enabled/site1
<VirtualHost *:80>
ServerName site1
RailsEnv development
DocumentRoot /var/www/site1/public
<Directory /var/www/site1/public>
Options None
AllowOverride None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
user#debian:# cat /etc/apache2/sites-enabled/site2
<VirtualHost *:80>
ServerName site2
RailsEnv development
DocumentRoot /var/www/site2/public
<Directory /var/www/site2/public>
Options None
AllowOverride None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Surely.
For production, install rvm in system wide mode instead of user mode, by adding sudo to the install command. In development you can stay with user mode.
Install the passenger gem in the global gemset for your specified ruby. Do the same with gems that will be user by more than one application (remember version requirement for each gem)
after running the install apache-passenger-mod command in the server copy the resulting mod loading
Then to get the correct gemset to load add this file to your config folder
# setup_load_path.rb
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
# RVM.use_from_path! File.dirname(File.dirname(__FILE__))
# edit this line according to you ruby version
RVM.use!('1.9.2#YOUR_GEMSET')
rescue LoadError
# RVM is unavailable at this point.
raise "RVM ruby lib is currently unavailable."
end
end
# Select the correct item for which you use below.
# If you're not using bundler, remove it completely.
#
# # If we're using a Bundler 1.0 beta
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'
#
# # Or Bundler 0.9...
# if File.exist?(".bundle/environment.rb")
# require '.bundle/environment'
# else
# require 'rubygems'
# require 'bundler'
# Bundler.setup
# end
After that just make apache point to the correct public directory
DocumentRoot /var/www/app/public
<Directory /var/www/app/public>