0

I am experiencing some odd behavior with Apache. I have several vhosts setup on my local machine. I am currently experiencing this on 1 of the vhosts, as I am doing dev work constantly, however I think it happened on another local site as well.

Here's whats happening:

I go to nekst.local and the page loads fine. I refresh the page constantly to check my updated code. All of a sudden I get a 403 error in the console for all assets but the page loads (minus assets). If I refresh again I get a 403 error in browser rather than a page load. If I restart apache everything works for a while and then all of a sudden it happens again.

I did recently download xdebug and add that to my php.ini. I'm not sure if this may be causing any issues.

I am running apache 2.4.9, php 5.5.14 on osx yosemite

my vhost:

<Directory "/Users/shawn/Documents/work/sites/mindbox/nekst/webapp/web">
   Require all granted
   AllowOverride All
</Directory>
<VirtualHost *:80>
    DocumentRoot "/Users/shawn/Documents/work/sites/mindbox/nekst/webapp/web"
    ServerName nekst.local
    ErrorLog "/Users/shawn/Documents/work/sites/mindbox/nekst/webapp/app/logs/error_log"
    CustomLog "/Users/shawn/Documents/work/sites/mindbox/nekst/webapp/app/logs/access_log" common
</VirtualHost>

and my dir:

drwxr-xr-x  15 shawn  staff     510 Jan 27 10:25 web

2 Answers2

1

Have you tried looking into your error log for more details?

I always run the following command while developing PHP, to be aware of any notices. It may also help you narrow down this issue:

tail --follow=name -n 100 /Users/shawn/Documents/work/sites/mindbox/nekst/webapp/app/logs/error_log

Ctrl-C when done

Dan Armstrong
  • 821
  • 4
  • 6
  • Good call, I should have thought to look at the error log... not sure what the `--follow=name` was meant to do but didn't work, ran `tail -f -n 100 /User....` and eventually got these errors: https://gist.github.com/shawn-northrop/709b07b074285d3c1308 error is saying: 'failed to open stream too many open files'. Is this a setting I can bump up (and would I want to) in my php.ini? – Shawn Northrop Jan 30 '15 at 17:30
  • I ran the following `launchctl limit maxfiles` and it returned `maxfiles 256 unlimited` I'm not sure what a reasonable number for this is. I'm looking into finding out what files are already open. – Shawn Northrop Jan 30 '15 at 17:40
  • To find which files are open, you can use lsof command or look in /proc/$PID/fd However, some things use file handles that are not, in fact, files - such as open TCP sockets. – Dan Armstrong Jan 30 '15 at 18:02
  • and "--follow=name" (leave as 'name', do not put filename there) will reopen the file after a log file rotation. This is convenient for leaving the error file open for days on end. – Dan Armstrong Jan 30 '15 at 18:04
  • I ran `lsof | wc -l` returned `2626` `lsof | grep -v /dev/null` | returned `2407` and `lsof | grep txt | wc -l` returned `1415` not sure if these numbers seem reasonable, I just rebooted the system. I followed these instructions: http://docs.basho.com/riak/latest/ops/tuning/open-files-limit/#Mac-OS-X and got the following `launchctl limit - maxfiles 65536 65536` I'll test and see if this works – Shawn Northrop Jan 30 '15 at 18:30
  • lsof has many, many options to select. What you found was an upper bound for all files open on the system. Good call to raising file limits. I suspect you'll be good to go. – Dan Armstrong Jan 30 '15 at 18:33
  • Still getting the too many open files error, any other thoughts? again, `launchctl limit` is showing `maxfiles 65536 65536` and `lsof | wc -l` is only showing `3252` – Shawn Northrop Jan 30 '15 at 19:43
  • 1
    Also, `tail -F` is the syntax required vs `tail --follow=name` which gave me an error... atleast on my machine – Shawn Northrop Jan 30 '15 at 19:46
  • Ok found the issue: http://superuser.com/questions/787888/too-many-files-open-on-mac-osx-after-running-apache-in-php-with-xdebug-for-som The accepted answer shows there is a bug with Xdebug on OSX: http://bugs.xdebug.org/view.php?id=1070 – Shawn Northrop Jan 30 '15 at 20:12
  • I also had in php.ini xdebug.remote_autostart = 1, I have disabled this as recommended – Shawn Northrop Jan 30 '15 at 20:14
0

Do you have mod_evasive enabled in apache? I had the same kind of problem and after disabling it, the problem was gone. See here for a guide to tweak values for mod_evasive: http://www.faqforge.com/linux/prevent-dos-attacks-on-apache-webserver-for-debian-linux-with-mod_evasive/