I am trying to set up mod_fcgid on my server. Part of the requirement is that Apache needs to create a socket file for mod_fcgid.

I specified the folder for Apache to write the socket data to:


I then specified this file in my fcgid.conf file as follows:

SocketPath /var/run/apache2/fcgid/sock

I then changed the owner of the folder to www-data (the apache user) and gave the owner full permissions to the folder and its contents.

I was able to run my test fcgi app then.

When I rebooted the machine, y fastcgi app no longer worked. After some investigation, I found that ownership of /var/run/apache2/fcgid has been reset to root, and with permission reset to 700

I have the following questions:

  • Is there something specific about the /var/run folder?
  • why is the permissions being reset after a reboot?
  • Should I move my socket file to another location (in case root automatically takes ownership of contents in this folder for security reasons?)

I am running Ubuntu 10.0.4 LTS 64 bit


/var/run is not a "real" filesystem on Ubuntu, it's tmpfs (something like "ramdisk"). So I think permissions and files are not preserved in case of reboot since that filesystem only exists till the reboot. You can use another location which is a real filesystem, or you can modify some startup script to create and set the rights/ownership of the socket you want to use. Issue the command mount in terminal, you will see that /var/run is on tmpfs.

  • Thanks for the prompt response. I tried /var/lock as well and I had the same problem. After running mount as you suggested, I realized (as luck would have it), that both of these folder locations were indeed tmpfs. BTW, this is the OP, for some strange reason, I can't seem to add comments or edit my question. I will try a 'real' filesystem and if that works I will accept your answer (if the system will allow me to) – Homunculus Reticulli Feb 14 '11 at 7:26
  • Ok, but I think it's a good choice to use /var/run ... It's even a logical choice. However the problem that you must set up permissions each time. I would do it in some init script which launch your daemon(s) as well. But for sure, it's up to you, you can use different location for your sockets as well, if you prefer that, but you must know that /var/run is for this purpose exactly (and usually pid file), just check /var/run/mysql if you're using MySQL: MySQL server stores (by default) its pid file and socket there. For sure, it creates socket/ser permission each time so it works. – LGB Feb 14 '11 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy