2

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

user568829
  • 231
  • 1
  • 3
  • 8

3 Answers3

2

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

Mark Wagner
  • 18,019
  • 2
  • 32
  • 47
0

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...

alexus
  • 13,112
  • 32
  • 117
  • 174
0

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
quanta
  • 51,413
  • 19
  • 159
  • 217
Kevin DeGraaf
  • 456
  • 3
  • 4
  • 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