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.

Basically - I have some PHP scripts that need to be run as cron jobs.

Lets say the script needing to be run is: http://admin.somedomain.com/cron_jobs/get_stats

If I run the script from the local machine it gives me a 404 Not Found error.

So I entered the following into /etc/hosts

XX.XX.XX.45    admin.somedomain.com

Now wget works fine from the local machine to that domain. However when I restart Apache that domain no longer works. Here is the config for that site in /etc/apache2/sites-available

NameVirtualHost XX.XX.XX.45:80

<VirtualHost XX.XX.XX.45:80>
    ServerName admin.somedomain.com
     DocumentRoot /var/www/admin.somedomain.com/
    <Directory "/var/www/admin.somedomain.com">
            allowoverride all
          Options Indexes
          order deny,allow
           allow from all
       </Directory>
    ErrorLog /var/log/apache2/admin.somedomain.com-error_log
    CustomLog /var/log/apache2/admin.somedomain.com-access_log combined

</VirtualHost>

It just goes to the default site config showing "It Works".

If I take out that setting in /etc/hosts and restart apache the website at that domain works fine again.

Can anyone point me in the right direction here? Thanks

share|improve this question

3 Answers 3

try httpd -S that should give you list of all configured virtualhosts including yours. Also verify that your directory "/var/www/admin.somedomain.com/" exists and also take a look in logs and see what they're saying...

share|improve this answer
    
command not found for httpd -S. And yes, /var/www/admin.somedomain.com/ is there. –  user568829 Sep 11 '12 at 20:31
    
sudo which httpd -S find your httpd and run it w/ -S –  alexus Sep 11 '12 at 20:58
    
'which httpd' gives me no output. The system is running debian. –  user568829 Sep 12 '12 at 5:09
    
In Debian it's apache2 instead of httpd. –  Janne Pikkarainen Sep 12 '12 at 5:32
    
Thanks - Running apache2 -S from root returns apache2: bad user name ${APACHE_RUN_USER} –  user568829 Sep 12 '12 at 5:59

Try wget --header="Host: admin.somedomain.com" http://localhost/cron_jobs/get_stats (That's one line.)

share|improve this answer
    
ERROR 404: Not Found. –  user568829 Sep 12 '12 at 5:05

Is there some reason you need to run the scripts through Apache, triggered by an HTTP client? What about just running them directly from cron?

0 4 * * * /usr/bin/php /path/to/script
share|improve this answer
    
I already tried this. They are Code Igniter virtual addresses - so there is no full path to them unfortunately. –  user568829 Sep 11 '12 at 20:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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