Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a site which I am trying to have go to different file locations. Here is my example:
The site name is development.mysite.com if that is keyed into the address bar of the browser then goto this directory /srv/www/htdocs.mysite1 if development.mysite.com/newstuff gets keyed into the browser then goto this directory /srv/www/htdocs.newstuff.
I'm also using SSL so I am redirecting the sites from http to https which all works but I can get the two sites working.
Here is my config:
Code:
<VirtualHost *:80>
ServerName development.mysite.com
Alias /newstuff /srv/www/htdocs.newstuff
DocumentRoot /srv/www/htdocs.newstuff
DirectoryIndex index.php
ErrorLog /var/log/apache2/newstuff-error_log
CustomLog /var/log/apache2/newstuff-access_log combined
<Directory "/srv/www/htdocs.newstuff">
Options -Indexes FollowSymLinks
AllowOverride All
CheckSpelling on
Order allow,deny
Allow from all
</Directory>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
</VirtualHost>
<VirtualHost *:80>
ServerName development.mysite.com
Alias / /srv/www/htdocs.mysite1
DocumentRoot /srv/www/htdocs.mysite1
DirectoryIndex index.php
ErrorLog /var/log/apache2/mysite1-error_log
CustomLog /var/log/apache2/mysite1-access_log combined
<Directory "/srv/www/htdocs.mysite1">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
CheckSpelling on
</Directory>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
</VirtualHost>
Here is my SSL conf file as well:
Code:
<VirtualHost *:443>
ServerName development.mysite.com
Alias /newstuff /srv/www/htdocs.newstuff
DocumentRoot /srv/www/htdocs.newstuff
DirectoryIndex index.php
#RewriteEngine off
#RewriteCond %{REQUEST_METHOD} ^TRACE
#RewriteRule .* - [F]
ErrorLog /var/log/apache2/newstuff-error_log
CustomLog /var/log/apache2/newstuff-access_log combined
<Directory "/srv/www/htdocs.newstuff">
Options -Indexes FollowSymLinks
AllowOverride None
CheckSpelling on
Order allow,deny
Allow from all
</Directory>
SSLEngine on
SSLProtocol -ALL +SSLv3 +TLSv1
SSLCipherSuite ALL:!aNULL:!eNULL:!SSLv2:!LOW:!EXP:!MD5:@STRENGTH
SSLCertificateFile /etc/apache2/ssl.crt/newstuff.cer
SSLCertificateChainFile /etc/apache2/ssl.crt/newstuff.p7b
SSLCertificateKeyFile /etc/apache2/ssl.key/newstuff.key
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
SSLOptions +StdEnvVars
</Files>
<Directory "/srv/www/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
RewriteEngine on
RewriteRule ^[\w:/\%]*(\.(?!(js|ico|gif|jpg|png|css|htm|asp|pdf|swf|fla|doc|pps|ppt|class|jar|mp3))[\w\%\.]*)?$ /atrac/index.php
RewriteLog /var/log/apache2/newstuffev-rewrite.log
RewriteLogLevel 4
</VirtualHost>
<VirtualHost *:443>
ServerName development.mysite.com
Alias / /srv/www/htdocs.mysite1
DocumentRoot /srv/www/htdocs.mysite1
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
ErrorLog /var/log/apache2/mysite1-error_log
CustomLog /var/log/apache2/mysite1-access_log combined
<Directory "/srv/www/htdocs.mysite1">
Options -Indexes FollowSymLinks
AllowOverride None
CheckSpelling on
Order allow,deny
Allow from all
</Directory>
SSLEngine on
SSLProtocol -ALL +SSLv3 +TLSv1
SSLCipherSuite ALL:!aNULL:!eNULL:!SSLv2:!LOW:!EXP:!MD5:@STRENGTH
SSLCertificateFile /etc/apache2/ssl.crt/mysite1.cer
SSLCertificateChainFile /etc/apache2/ssl.crt/mysite1.p7b
SSLCertificateKeyFile /etc/apache2/ssl.key/mysite1.key
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
SSLOptions +StdEnvVars
</Files>
<Directory "/srv/www/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfDefine>
The development.mysite.com always goes to the /srv/www/htdocs.newstuff directory. I can't figure out how to get it to goto the /srv/www/htdocs.mysite1 location for that index.php file.
This alias should be set inside of your virtual host for /srv/www/htdocs.mysite1 you do not need a virtual host for your newstuff.
All you are doing is telling Apache taht when you request that folder path /newstuff on the domain that the vhost is setup for to pull the content for the folder specified.
Your aliases with / are not really doing much doesnt look like.
The problem I am seeing is that when I access development.mysite.com the browser, apache, is pulling the pages from the /srv/www/htdocs.newstuff and not /srv/www/htdocs.mysite1. If I use development.mysite.com/newstuff it uses the content in /srv/www/htdocs.newstuff but using development.mysite.com also uses the newstuff content and not the /srv/www/htdocs.mysite1 content.
Thats because you have it explictly set in as your document root in your virtual host. Change the document root for your vhost to be the actual directory you want the content to come from.
Well, that appears to work somewhat. Not sure what else I am missing but I placed all the content into one directory. Moved all of /srv/www/htdocs.newstuff into /srv/www/htdocs.mysite1 and it works. Not sure why I cannot use a different directory like I was /srv/www/htdocs.newstuff but I would just get a 403 error Access Forbidden and from what I can tell signifies a missing index page? Not sure. Can I specify both directories in the Directory portion?
<Directory "/srv/www/htdocs.newstuff"> Directory "/srv/www/htdocs.mysite1"
Options -Indexes FollowSymLinks
AllowOverride All
CheckSpelling on
Order allow,deny
Allow from all
</Directory>
Then I have the complexity of SSL certs which I have created using an internal certificate authority. Do I create two seperate entries in teh ssl-vhost.conf file or combine them again like I did in the vhost.conf file?
You can use as many Directory 'directives' as possible, however, they all must be separate! You can have multiple <Directory> directives within a <VirtualHost> directive. So:
The one thing to remember about Apache is that it is designed as a restrictive server. Meaning that it will not serve content unless explicitly told to do so, this is why you will always see the Allow from all directives.
When receiving any apache error check your /var/log/httpd/error.log file as it will give you the exact cause.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.