I am hosting a website on my own private server (a Raspeberry Pi 3 running Raspbian, based on Ubuntu 16.04) on which I installed LAMP (following this step-by-step guide) and WordPress (following this one).

I installed WordPress in a "secondary" site, meaning that it is in a folder that is contained within my "main" site's folder. The main site location is /var/www/my-main-site/, which contains the folder /var/www/my-main-site/my-secondary-site, where all WordPress files are (below I copied the folder structures and their permissions).

The secondary site can be reached through an alias, which I configured in the /etc/apache2/sites-enabled/my-main-site.conf file as follows

<VirtualHost *:port>

    ServerAdmin my-email@mail.com
    ServerName my-public-ip:port
    Alias "/my-secondary-site" "/var/www/my-main-site/my-secondary-site"
    DocumentRoot /var/www/my-main-site/public_html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

While testing it with two sample .html files it all works: I can access my main site through my-public-ip:port and the secondary site through my-public-ip:port/my-secondary-site. After this test, I installed WordPress.

The problem is that when I try to access the secondary site to complete the WordPress configuration through the web interface I get this error


You don't have permission to access /my-secondary-site on this server.
Server unable to read htaccess file, denying access to be safe

Following step 3 from the guide I enabled .htaccess overrides by adding these lines at the end of /etc/apache2/apache2.conf

<Directory /var/www/my-main-site/>
    AllowOverride All

Following step5, I changed the permissions for my folders as follows (note that my-user is the user I use to connect through ssh, which has root privileges):

drwxr-xr-x 4 my-user www-data 4096 May  1 11:48 my-main-site
/* which contains these two folders*/
---> drwxr-xr-x 2 my-user www-data 4096 May  1 11:01 public_html
---> drwxr-sr-x 5 my-user www-data 4096 May  1 14:22 my-secondary-site

/* files and folders in /var/www/my-main-site/my-secondary-site
      ---> -rw-r--r--  1 my-user www-data   147 May  1 11:50 index.html
      ---> -rw-r--r--  1 my-user www-data   418 Sep 25  2013 index.php
      ---> -rw-r--r--  1 my-user www-data 19935 Jan  6 20:32 license.txt
      ---> -rw-r--r--  1 my-user www-data  7415 Mar 18 17:13 readme.html
      ---> -rw-r--r--  1 my-user www-data  5438 Mar 18 16:07 wp-activate.php
      ---> drwxr-sr-x  9 my-user www-data  4096 Apr  3 22:19 wp-admin
      ---> -rw-r--r--  1 my-user www-data   364 Dec 19  2015 wp-blog-header.php
      ---> -rw-r--r--  1 my-user www-data  1627 Aug 29  2016 wp-comments-post.php
      ---> -rw-r--r--  1 my-user www-data  2853 Dec 16  2015 wp-config-sample.php
      ---> -rw-r--r--  1 my-user www-data  3261 May  1 12:59 wp-config.php
      ---> drwxrwsr-x  5 my-user www-data  4096 May  1 12:35 wp-content
      ---> -rw-r--r--  1 my-user www-data  3669 Aug 20  2017 wp-cron.php
      ---> drwxr-sr-x 18 my-user www-data 12288 Apr  3 22:19 wp-includes
      ---> -rw-r--r--  1 my-user www-data  2422 Nov 21  2016 wp-links-opml.php
      ---> -rw-r--r--  1 my-user www-data  3306 Aug 22  2017 wp-load.php
      ---> -rw-r--r--  1 my-user www-data 36593 Apr  3 17:22 wp-login.php
      ---> -rw-r--r--  1 my-user www-data  8048 Jan 11  2017 wp-mail.php
      ---> -rw-r--r--  1 my-user www-data 16246 Oct  4  2017 wp-settings.php
      ---> -rw-r--r--  1 my-user www-data 30071 Oct 18  2017 wp-signup.php
      ---> -rw-r--r--  1 my-user www-data  4620 Oct 24  2017 wp-trackback.php
      ---> -rw-r--r--  1 my-user www-data  3065 Aug 31  2016 xmlrpc.php

I tried to give ownership of /var/www/my-primary-site to the www-data user through sudo chown -R www-data /var/www/my-primary-site/, but the problem persisted.

I also tried changing the /etc/apache2/apache2.conf file to allow override to the whole /var/www/ folder as follows, but nothing changed.

/* From... */
<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted

/* .... to */
<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted

Any ideas?


Well, I can't say for certain if this will help, but the Alias directive looks unnecessary in this case. public-ip:port/my-secondary-site should likely be accessible without it.

Also, as a side niggle, if you are planning to give my-secondary-site an actual domain name, I would break it up into a separate virtual host when you do so.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.