I have a Ubuntu/Apache VPS where I have a Rails app running fine. Now I want to add a 2nd Rails app and change the virtualhostso that visiting a subfolder will show the 2nd Rails app.
The Rails apps are deployed with Capistrano to:
/home/<myname>/apps/<app_1>/current
/home/<myname>/apps/<app_2>/current
The "/etc/apache2/sites-available/default" file looks like this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
RailsBaseURI /app_1
<Directory /var/www/app_1>
Options -MultiViews
</Directory>
RailsBaseURI /app_2
<Directory /var/www/app_2>
Options -MultiViews
</Directory>
</VirtualHost>
I would expect that repeating the same for the 2nd app would work, but it is not. I forgot how the contents of the public folder end up in /var/www/app_1?
When I now visit "www.mysite.com/app_2" it says:
No such file or directory - config/environment.rb
But visiting "www.mysite.com/app_1" does work. Any suggestions?
Make sure that you have a symlink from /var/www/app_2 pointing to your app in /home/yourname/apps/app_2/current
sudo ln -s /var/www/app_2 /home/yourname/apps/app_2/current
Apache only uses 1 folder as it's document root, so if you just specify 2 apps but not tell apache where to pick up the second it will use the main document root to find the document, so in this case it will route app_2 to the first app.
Try and adding a second vhost all together, the same way you would do if you had 2 different domains pointing each one to the correct folder/URL, have a look at this link.
http://httpd.apache.org/docs/2.2/vhosts/examples.html
Related
This should be a very simple question to answer for people who knows apache.
I have an Ubuntu computer which I use as my server. I have worked with apache several times before, but never experienced this issue.
My owncloud.conf file in the sites-enabled folder looks like this:
1 <VirtualHost *:80>¬
2 ServerName owncloud¬
3 DocumentRoot "~/mybook/ownCloud"¬
4 <Directory ~/mybook/ownCloud/>¬
5 Options None¬
6 Order deny,allow¬
7 Allow from all¬
8 </Directory>¬
9 </VirtualHost>
But after enabling the site and restarting apache, I'm getting this error:
AH00112: Warning: DocumentRoot [/etc/apache2/~/mybook/ownCloud] does not exist
I've been looking, and I cannot seem to find where it's set that "/etc/apache2/" should be leading default path to all set document roots of the site config files.
Does anyone know how I can remove this default setting?
Forget the comment I made regarding Mac, what you have above will not work. If you installed Apache on Ubuntu and accepted the defaults the docroot is /var/www and I am assuming you want your /mybook/ownCloud mapped to docroot. That is how you should do it because the httpd will run with group permissions to the real docroot. That can be done using an alias as I have below. Look at the bottom, but also note that I specified the correct default docroot in the beginning before I mapped anything. You can change the docroot but you will have to make sure the permissions on the new directory structure are set correctly.
I aliased your /mybook/ownCloud/ to ownCloud. Also, I have other directives that I removed from the sites-enabled code below for clarity.
BTW, I have personally never used tildes within an Apache conf file like you have above, it could be confusing during startup.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Alias /owncloud/ "/mybook/ownCloud"
<Directory "/mybook/ownCloud">
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>
EDIT:
There are other ways to configure a VHost, but this is basically how it is done. You no longer set a server wide docroot declaration in httpd.conf. The /etc/apache2/ path is the server home and in the absence of a docroot declaration in your sites-enabled it may have defaulted to Server Home when httpd started.
How do I configure Apache2 to load a page with the extensions of default files provided when a page is requested without an extension.
So for example I want http://webpage.com/page to automatically load either:
http://webpage.com/page.html OR
http://webpage.com/page.php
NOTE: I don't want any redirection or URL renaming to occur; meaning I want the address bar to still be showing http://webpage.com/page
Per CBroe's comments and his reference to apache docs httpd.apache.org/docs/2.2/content-negotiation.html#multiviews - Adding Multiviews to Options directive inside a Directory section solves this issue.
You can either add it to a Directory section like below (to affect all web applications under sites directory)
<Directory /sites>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
-OR- inside a site host definition
<VirtualHost *:80> #site.dev
ServerAdmin admin#email.com
ServerName site.dev
ServerAlias site.dev
DocumentRoot /sites/site.dev
<Directory /sites/site.dev>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
I am running Ubuntu 13.10 with Apache 2.4 and i want to make a folder which will contain all my PHP files that I am making for testing purposes. I created a Vhost for the folder and it works when i target the sepcific file in mind, in example :
http:/phptestsite/some_random_php_script.php
When i go there the code (if it works ;) ) will execute, but I want to create a list of all php files (similar to that of a ftp site/listing) when i go to
http:/phptestsite/
So that i do not have to manually type in everytime each individual php script I want to test, but just go to that vhost and click on the file.php I want to test.
Vhost conf:
<VirtualHost *:80>
DocumentRoot /home/usrnname/PHPTest/
ServerName phptest
ServerAlias phptest
<Directory />
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /home/username/PHPTest/>
Options FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
you should add Options +Indexes to list the directories
<Directory /home/username/PHPTest/>
Options FollowSymLinks MultiViews +Indexes
AllowOverride All
Require all granted
</Directory>
I have users who want to run their own Symfony projects under their home directories, but I can't get Symfony to work properly. In my Apache2 config file, I set the userdir as:
UserDir sfproject/web
But the DocumentRoot has to be:
/var/www/sfproject/web
This requirement is there because when we deploy the code to production, we don't want to change the Apache config file. And everything is going to be under that directory.
The problem is that when we go to a user directory: dev.server.com/~asdf
Symfony gives a 404 error: Empty module and/or action after parsing the URL "/index.php" (/).
I don't understand what's wrong. We want them to see their individual projects in their home directories. I looked at some other people setting up Symfony in shared hosting environments, but this is not a shared hosting environment. This is a dedicated server and I have root. Thank you for your help. Here is the relevant parts of my Apache config:
UserDir sfproject/web
<Directory "/usr/share/php/data/symfony/web/sf">
AllowOverride All
Allow from All
</Directory>
<VirtualHost *>
DocumentRoot "/var/www/sfproject/web"
DirectoryIndex index.php
<Directory "/var/www/sfproject/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /usr/share/php/data/symfony/web/sf
<Directory "/usr/data/symfony/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
I think something like the following would be closer to a solution.
<VirtualHost *>
DocumentRoot "/var/www/sfproject/web"
DirectoryIndex index.php
<Directory "/var/www/sfproject/web">
AllowOverride All
Allow from All
</Directory>
# or is the dir /usr/share/php/data/symfony/data/web/sf ?
Alias /sf /usr/share/php/data/symfony/lib/vendor/symfony/data/web/sf
<Directory "/usr/share/php/data/symfony/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
The paths from your excerpt does not look good I guess. Try it out and let us know if it works.
I installed Moveable type on a ubuntu box.
The admin section works great.
However the front page does not. The images and CSS are not displayed.
This is coming from the apache error log:
Permission denied: exec of '/var/www/mt/example/styles.css' failed
Premature end of script headers: styles.css
I think it's related to my apache config. Since i call the admin section using the localhost, but i use the example.com for the front page, which is the part that doesnt work.
This is my apache config:
NameVirtualHost *
<VirtualHost *>
ServerAdmin chris#example.com
ServerName mt.example.net
DocumentRoot /var/www/mt
Alias /mt-static /var/www/mt/mt-static
<Directory /var/www/mt/mt-static>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias / /var/www/mt/
<Directory /var/www/mt>
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *>
ServerAdmin chris#example.com
ServerName example.com
ServerAlias example.com www. example.com
DocumentRoot /var/www/example
Alias /mt-static /var/www/mt/mt-static
<Directory /var/www/mt/mt-static>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Redirect /mt.cgi http://mt.example.net/mt.cgi
</VirtualHost>
it because the directory where the css file is located (var/www/mt/example/) is a sub-directory of one which is declared to be a script in (/var/www/mt) with Options +ExecCGI
Directories inherit the options of their parents
It sounds like Apache has tried to run the .css file as an executable. The only thing which I can suggest is that you might have a css file which has an executable permission, for some reason, so Apache tries to execute it. Try
chmod a-x
on the CSS file and see if it makes a difference.
Sometimes files copied from Windows have executable set when they shouldn't.