How i can create two differet sites on apache 2.2 / windows server - hosts

In my case, all domains redirect to memberspage.com when I enter domain names in the browser.
In httpd.conf i use:
Listen 80
Listen 81
In httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin admin#gmail.com
ServerName memberspage.com
ServerAlias www.memberspage.com
DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/memberspage.com/"
<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/memberspage.com/">
Options Indexes FollowSymLinks
AllowOverride All
#Require all granted
</Directory>
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>
</VirtualHost>
<VirtualHost *:81>
ServerAdmin admin#gmail.com
ServerName mysite2.com
ServerAlias mysite2.com
DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/mysite2.com/"
<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/mysite2.com/">
Options Indexes FollowSymLinks
AllowOverride All
#Require all granted
</Directory>
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>
</VirtualHost>
And in hosts:
127.0.0.1 memberspage.com
127.0.0.1 mysite2.com

Related

apache showing directory structure of my rails app when using a directory setup for multiple rails app

I have this on my httpd.conf
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.42/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.42
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.1.1/ruby
RackEnv development
<VirtualHost *:3000>
ServerName [ip]
DocumentRoot /var/www/html/apps
<Directory /var/www/html/apps>
AllowOverride all
Options -MultiViews
</Directory>
RackBaseURI /app1
<Directory /var/www/html/apps/app1/public>
AllowOverride all
Options -MultiViews
</Directory>
RackBaseURI /app2
<Directory /var/www/html/apps/app2/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
Accessing [ip]:3000/app1 or [ip]:3000/app2 just shows the directory structure and not running the rails app. But if I try using with just a single project like below
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.42/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.42
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.1.1/ruby
RackEnv development
<VirtualHost *:3000>
ServerName [ip]
DocumentRoot /var/www/html/apps/app1/public
<Directory /var/www/html/apps/app1/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
Accessing [ip]:3000 works just fine.

Apache passenger overriding all domains

I recently installed passenger apache module on my apache2 server so as to be able to serve my ruby on rails app.
I have installed - apache2 server, rvm, gem rails, gem passenger, passenger-install-apache2-module
I have pointed multiple domains to apps on the server on /var/www/ including the rails app on eurohacktrip.org
My problem is that all the other domains are also serving this same rails app.
At the bottom of /etc/apache2/apache2.conf
Include sites-enabled/
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.50/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.50
PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
</IfModule>
ON - /etc/apache2/sites-enabled/eurohacktrip.org
<VirtualHost *:80>
ServerName eurohacktrip.org
ServerAlias www.eurohacktrip.org
ServerAdmin webmaster#eurohacktrip.org
RailsEnv production
PassengerEnabled on
PassengerAppRoot /var/www/eurohacktrip.org/
PassengerRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
DocumentRoot /var/www/eurohacktrip.org/public
<Directory /var/www/eurohacktrip.org/public>
Options -MultiViews
AllowOverride All
# Order allow,deny
</Directory>
</VirtualHost>
ON - /etc/apache2/sites-enabled/tradesoko.com (laravel, php)
<VirtualHost *:80>
ServerAdmin webmaster#tradesoko.com
ServerName tradesoko.com
ServerAlias www.tradesoko.com
DocumentRoot /var/www/tradesoko.com/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/tradesoko.com/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
# Order allow,deny
# allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
What can I do to enable tradesoko.com?

How to Serve Rails Web App with Apache and Passenger

I am serving eurohacktrip.org on a digitalocean vps with ubuntu12.04 and apache2.
Here is my apache virtual host file for it: /etc/apache2/sites-available/eurohacktrip.org
<VirtualHost *:80>
ServerName eurohacktrip.org
ServerAlias eurohacktrip.org
DocumentRoot /var/www/eurohacktrip.org/public
RailsEnv production
PassengerEnabled on
PassengerAppRoot /var/www/eurohacktrip.org/
PassengerRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
ServerAdmin webmaster#eurohacktrip.org
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/eurohacktrip.org/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
# Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
And I added these lines on my /etc/apache2/apache2.conf
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.40/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.40
PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
</IfModule>
And I did
service apache2 restart
But my site still doesnt work : http://eurohacktrip.org/
Strange enough It works on 3000 http://eurohacktrip.org:3000
I also had to Uncomment
gem 'therubyracer', platforms: :ruby
and ran
bundle install
but still no luck. What could be missing?
LoadModule passenger_module /home/deployer/.rvm/gems/ruby-1.8.7-p374/gems/passenger-4.0.40/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /home/deployer/.rvm/gems/ruby-1.8.7-p374/gems/passenger-4.0.40
PassengerDefaultRuby /home/deployer/.rvm/gems/ruby-1.8.7-p374/wrappers/ruby
</IfModule>
<VirtualHost *:80>
ServerName yourservername
RailsEnv production
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /home/user/apps/projects/myapp/public
<Directory /home/user/apps/projects/myapp/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
if you face any problem follow this link
http://nathanhoad.net/how-to-ruby-on-rails-ubuntu-apache-with-passenger
It turns out I simply wasn't reading the instructions from the passenger error page. I just needed to disable a gem "simple-captcha", ran bundle install and everything went back to normal. Thanks

Multiple rails apps on Phusion Passenger on Apache

I have an rails application setup on a linux server which works fine and I can access it through:
machine.mydomain.com
the passenger setup file (/etc/apache2/httpd.conf) has this section:
<VirtualHost *:80>
ServerName machine.mydomain.com
DocumentRoot /var/www/public
<Directory /var/www/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
I added a new rails app under the same directory (it will not be there indefinately, it's only for testing) under the subdirectory sss and added a new section in the file:
<VirtualHost *:80>
ServerName machine.mydomain.com/sss
DocumentRoot /var/www/sss/public
<Directory /var/www/sss/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
What am I doing wrong?
Assuming you're using rack, you have to change your httpd.conf like this:
<VirtualHost *:80>
ServerName machine.mydomain.com
DocumentRoot /var/www/public
<Directory /var/www/public>
AllowOverride all
Options -MultiViews
</Directory>
RackBaseURI /sss
<Directory /var/www/sss/public>
Options -MultiViews
</Directory>
</VirtualHost>

Rails, Apache2 on Ubuntu (karmic) deployment

I just need some clarification on a couple of files.
My site has an admin subdomain and SSL in addition to the normal *:80 details found in the virtual hosts.
My question(s): Do I need to specify a 1) ServerName and 2) DocumentRoot in: /etc/apache2/apache2.conf?
I currently enable my site from this directory: /etc/apache2/sites-available/site
Here are the contents of my site file in the above directory (/etc/apache2/sites-available/site):
<VirtualHost *:80>
ServerName www.site.com
ServerAlias www.site.com
DocumentRoot /home/user/public_html/site/current/public
RailsAllowModRewrite off
<directory "/home/user/public_html/site/current/public">
Order allow,deny
Allow from all
</directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.site.com
ServerAlias admin.site.com
DocumentRoot /home/user/public_html/site/current/public
RailsAllowModRewrite off
<directory "/home/user/public_html/site/current/public">
Order allow,deny
Allow from all
</directory>
</VirtualHost>
<VirtualHost *:443>
ServerName www.site.com
ServerAlias www.site.com
# SSL releated
SSLEngine on
SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
SSLCertificateFile /path/to/site.com.crt
SSLCertificateChainFile /path/to/bundle.crt
SSLCertificateKeyFile /path/to/site.key
# Used by rails
RequestHeader set X_FORWARDED_PROTO "https"
</VirtualHost>
Do you see anything wrong?
Looks like I was missing a DocumentRoot in my SSL VirtualHost. Fixed! (also cleaned up those aliases)

Resources