Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apache2 Allow access to subdirectory

I am currently running a Django site on Dreamhost using Passenger. I would like to run a Wordpress blog in the 'public' directory that currently holds my static files (which is where I assume it should live). Since Django currently owns all of /*, I was told I would need to add a Location entry to the httpd.conf of my apache2 server. I tried both Location and Directory and could not get them to work. The code snippet below is basically what I typed in a bunch of different ways.

<Directory /home/user/domain/public/blog/>
Order allow,deny
allow from all
</Directory>

I also tried adding AllowOverride All to try and catch the htaccess file in the blog folder but no dice. I am extremely new to messing with apache (first time), can anyone point me in the right direction to get /blog/ to show the wordpress site and not a 404 page.

like image 500
Carl W. Avatar asked Jun 26 '26 13:06

Carl W.


1 Answers

Try adding an Apache Alias directive:

Alias /blog/  /home/user/domain/public/blog/

That 'Alias' will along with your 'Directory' directive should do the trick.

Note: I have these listed before my wsgi configuration that loads django into apache. ( I dont know if that matters tho, but it might.)

Edit: In my main httpd. conf file I

LoadModule wsgi_module modules/mod_wsgi.so

I assume there are 'DocumentRoot' and 'Directory' directives in there.

Next: in my virtual host

<VirtualHost *:80>
Alias /blog/  /home/user/domain/public/blog/

<FilesMatch \.(?i:gif|jpe?g|png|ico)$>
  Order allow,deny
  allow from all
</FilesMatch>

<FilesMatch \.(?i:css|jst|js|txt|htm|html)$>
  Options Indexes FollowSymLinks MultiViews
  Order allow,deny
  allow from all
</FilesMatch>

<Directory /home/user/domain/public/blog/>
   Order allow,deny
   allow from all
</Directory>

Maybe my FilesMatch directives were actually doing the magic ( I might have missed that before)

Debugging If you cant get this going, you might want to enable more verbose httpd logging output in apache to see if you can get it to tell you what it is unhappy about. you do this by changing the 'LogLevel' directive from 'warn' to debug

LogLevel debug

now

tail -f /path/to/you/apache/error_logs
like image 199
Jeff Sheffield Avatar answered Jun 29 '26 10:06

Jeff Sheffield



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!