Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

Lets say the script needing to be run is:

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


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>
     DocumentRoot /var/www/
    <Directory "/var/www/">
            allowoverride all
          Options Indexes
          order deny,allow
           allow from all
    ErrorLog /var/log/apache2/
    CustomLog /var/log/apache2/ combined


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

try httpd -S that should give you list of all configured virtualhosts including yours. Also verify that your directory "/var/www/" 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/ 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:" 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


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.