简体   繁体   中英

apache passenger multiple conf files in vhosts dirctory

I have an old bitnami server I'm trying to add an additional app to. My http.conf file contains this line:

IncludeOptional con/vhosts/*.conf

I have two files in the vhosts directory The first, called grade_review.conf, contains the following:

<VirtualHost *:80>
  RackBaseURI /grade_review
  <Directory "/opt/bitnami/apache2/htdocs/grade_review">
    Options -MultiViews
    <IfVersion < 2.3 >
    Order allow,deny
    Allow from all
    </IfVersion>
    <IfVersion >= 2.3>
    Require all granted
    </IfVersion>
  </Directory>
</VirtualHost>

That is the existing app on the server and it works fine. I can access the app at http://my_server.com/grade_review without any problems.

I added a second, called honors_review.conf, containing the following:

<VirtualHost *:80>
  RackBaseURI /honors_review
  <Directory "/opt/bitnami/apache2/htdocs/honors_review">
    Options -MultiViews
    <IfVersion < 2.3 >
    Order allow,deny
    Allow from all
    </IfVersion>
    <IfVersion >= 2.3>
    Require all granted
    </IfVersion>
  </Directory>
</VirtualHost>

After restarting apache, I can still access the first app without any problems, but I get a permission denied error when trying to access the second app at http://my_server.com/honors_review .

When I modify the first file so it contains both apps like this . . .

<VirtualHost *:80>
  RackBaseURI /grade_review
  <Directory "/opt/bitnami/apache2/htdocs/grade_review">
    Options -MultiViews
    <IfVersion < 2.3 >
    Order allow,deny
    Allow from all
    </IfVersion>
    <IfVersion >= 2.3>
    Require all granted
    </IfVersion>
  </Directory>

  RackBaseURI /honors_review
  <Directory "/opt/bitnami/apache2/htdocs/honors_review">
    Options -MultiViews
    <IfVersion < 2.3 >
    Order allow,deny
    Allow from all
    </IfVersion>
    <IfVersion >= 2.3>
    Require all granted
    </IfVersion>
  </Directory>
</VirtualHost>

. . . and restart apache, both apps work. What am I missing? Have I wrongly assumed that I could have two separate conf files for two separate apps?

You can't have two virtual hosts on the same domain, that's why the second option works (both apps in the same virtual host).

The first option doesn't work (each app has a different virtual host), and that's because they're configured to work at all domains at port 80 ( *:80 ). If you specified a ServerName (and/or ServerAlias ) for each one, they would work on the specified domain(s) and there would be no conflict. For instance, this would work if you set ServerName grade_review.my_server.com for the first virtual host and ServerName honors_review.my_server.com for the second virtual host, and supposing the subdomains are properly set.

Related to what you're trying to achieve, the second option (the one which works) makes sense and I would not change it, since you want both apps to work on the same domain but on a different prefix.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM