Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Ok. This is a pretty weird error:

I made a folder named 'hello' at /etc/apache2/sites-enabled/ with hello.php. Then i created an Alias that told /hello would go to /etc/apache2/sites-enabled/hello. This worked out.

Then i tried to make a VHost, which worked as well:

Alias /hello /etc/apache2/sites-enabled/hello
<VirtualHost *:80>
    ServerAdmin noobletadmin@YYYY.com
    DocumentRoot "/etc/apache2/sites-enabled/hello"
    ServerName comercial.YYYY.com
    ServerAlias ot.YYYY.com
    AddType application/x-httpd-php .php3 .php
    AddType application/x-httpd-php-source .phps
    <Directory /etc/apache2/sites-enabled/hello/>
        DirectoryIndex index.php
    </Directory>
</VirtualHost>

But then i read that sites-enabled/ was only meant for a SymLink of what is inside sites-available so I mv sites-*e/hello sites-available/hello and made a2ensite hello and that's when all hell broke loose.

Before, PHP worked fine and the "hello" worked out pretty fly - now it's just like there's no PHP there. The PHP's fine since it's a copy of the local files i have. No errors show up.. Anywhere. I tried /var/log/apache/ and nothing related to any directory that i'm working with spawns.

Also, when moving the file around (yes, i tried different locations), i noticed that my public_html has the following permission scheme:

drwxrwxr-x.  8 5500 www-data 4096 May  3 12:08 domain1_com
drwxrwxrwx   2 root root     4096 May  2 17:25 _cgi-bin
drwxr-xr-x   3 root root     4096 May 17 14:15 comercial_YYYY_com
drwxrwxr-x.  6 5500 www-data 4096 May  3 11:47 domain2_com
drwxrwxr-x.  6 5500 www-data 4096 May  2 17:25 domain3.pt
drwxr-xr-x   7 5500 www-data 4096 May  3 17:55 orcamento_YYYY_com
drwxrwxr-x.  6 5500 www-data 4096 May 13 18:48 domain4_pt
drwxr-xr-x   3 5500 www-data 4096 May 17 11:40 to_domain5_com
drwxrwxr-x.  8 5500 www-data 4096 May 13 18:03 YYYYY.com
drwxrwxr-x. 19 5500 www-data 4096 May  3 11:20 domain5.com
drwxrwxr-x.  6 5500 www-data 4096 May  2 17:25 domain6.pt

But I don't have SELinux on. I know this because the answer to sestatus is -bash: sestatus: command not found -- I'm on Debian Squeeze -- but php doesn't work on folders that don't have the dot permission (.) (the SELinux thingy).

And, since I don't seem to have SELinux I really don't know how or what happened. (I know, thought, all domains are a copy-pasta from another server i was on)

I'm at loss here. Please shed some light on my path?

share|improve this question

closed as too localized by Chris S May 17 '13 at 16:59

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

up vote 4 down vote accepted

This is the wrong way to set-up Apache. Your sites-available and sites-enabled directories are for virtual host configurations only, not your website's content files. These should be stored in /var/www or a directory of your choice.

Your AddType and DirectoryIndex directives should be merged into your main Apache configuration at /etc/apache2/apache2.conf.

Example:

/etc/apache2/sites-available/mydomain.com:

<VirtualHost *:80>
  ServerAdmin myadmin@mydomain.com
  DocumentRoot "/var/www/mydomain.com"
  ServerName mydomain.com
  <Directory /var/www/mydomain.com/>
    Options -Indexes
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

This file is then sym-linked to /etc/apache2/sites-enabled/mydomain.com.

Your website data is then stored in /var/www/mydomain.com.

share|improve this answer
    
I know this is not the prettiest (by far!) configuration of "the beast" but i was in a hurry and needed a fast-action thingy. For some reason, mkdir to and then reuploading the shenanigans again to that new file and editing the Alias worked out. But I'll be sure to make it like it's supposed to be - thanks for the heads up. –  MoshMage May 17 '13 at 14:36
1  
No problem, though a "fast action thingy" is no excuse for not using best practices. It's always better to do things properly, for your own knowledge and learning if nothing else. –  Craig Watson May 17 '13 at 14:39
    
To be honest: The fast-action thingy got me to learn how to properly configure a "website" under apache; I'd say it worked out pretty fine after all :P (But indeed, you are right. Again, thanks for the heads up.) Also: I did comment sites-enabled from the apache2.conf so it wouldn't be loaded as vhost config files -- I'm not that fast thingy. –  MoshMage May 17 '13 at 14:43

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