Access outside of virtual hosts in /opt/lampp/htdocs

Problems with the Linux version of XAMPP, questions, comments, and anything related.

Access outside of virtual hosts in /opt/lampp/htdocs

Postby skunkbad » 04. August 2014 07:27

I am working with XAMPP 1.8.3 and Ubuntu 14.04 Desktop.

I have virtual hosts set up so that I can access multiple websites. Each website is in a subdirectory of /opt/lampp/htdocs. Here is an example:

Code: Select all
<VirtualHost *:80>
    DocumentRoot "/opt/lampp/htdocs/localhost"
    ServerName localhost
    ErrorLog "logs/localhost-error_log"
    CustomLog "logs/localhost-access_log" common
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "/opt/lampp/htdocs/bwd"
    ServerName localhost.bwd
    ErrorLog "logs/bwd-error_log"
    CustomLog "logs/bwd-access_log" common
</VirtualHost>


The point of having a virtual host for localhost is that I usually get a directory listing with PHP for /opt/lampp/htdocs. By doing this, I can create a list of links to all of the subdirectories (virtual hosts). I've been doing this for a long time on Windows, and I understand that Linux has different permissions, but even if all files and dir permissions are changed I have not had success.

The directory listing is very simple, but fails at the attempt to open:

Code: Select all
// $handle ends up being (bool) FALSE
$handle = opendir(__DIR__ . '../');


Because virtual hosts is working, and all file and dir permissions set to 777, I'm thinking the issue is for sure with Apache, but don't know what to change to get the directory listing to work.

Please advise.
skunkbad
 
Posts: 13
Joined: 17. May 2010 07:36

Re: Access outside of virtual hosts in /opt/lampp/htdocs

Postby Nobbie » 04. August 2014 12:25

skunkbad wrote:The directory listing is very simple, but fails at the attempt to open:

Code: Select all
// $handle ends up being (bool) FALSE
$handle = opendir(__DIR__ . '../');



First of all i would check (via echo) which value is assigned to __DIR__ - maybe it is totally different to your expectation. If it contains (for example) "/opt/lampp/htdoc/localhost", your opendir() function yields to "/opt/lampp/htdocs/localhost../" what definately does not exist. There may be missing a directory slash.

At next keep in mind, that not only all subdirs must have sufficient rights, you also have to grant 777 to /opt/lampp/htdocs itself and optionally to all folders above (as well /opt/lampp as /opt). This depends on your configuration, which userid is used for Apache.
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04

Re: Access outside of virtual hosts in /opt/lampp/htdocs

Postby skunkbad » 04. August 2014 15:48

Oh gosh. Please smack me upside the head. It was the slash. Thanks.
skunkbad
 
Posts: 13
Joined: 17. May 2010 07:36

Re: Access outside of virtual hosts in /opt/lampp/htdocs

Postby Nobbie » 04. August 2014 17:03

skunkbad wrote:Oh gosh. Please smack me upside the head. It was the slash. Thanks.


When we come to California next year (we spend our holiday in USA every year) i get some beers from you. I will find Temecula with my GPS. 8)
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04

Re: Access outside of virtual hosts in /opt/lampp/htdocs

Postby skunkbad » 04. August 2014 17:32

Nobbie wrote:When we come to California next year (we spend our holiday in USA every year) i get some beers from you. I will find Temecula with my GPS. 8)


Hey, sounds good. You just want to come when it is not Summer, because the temps are too hot! From July to September is ridiculous.
skunkbad
 
Posts: 13
Joined: 17. May 2010 07:36

Re: Access outside of virtual hosts in /opt/lampp/htdocs

Postby Nobbie » 04. August 2014 21:58

skunkbad wrote:You just want to come when it is not Summer, because the temps are too hot! From July to September is ridiculous.


We know, normally we come in April or Octobre, it depends. We will decide about that not before christmas.
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 72 guests