PHP Session Support in /tmp

Greg Larkin glarkin at FreeBSD.org
Mon Nov 24 07:19:28 PST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

APseudoUtopia wrote:
> Hey.
> 
> PHP stores session data for the 'file' handler in /tmp, by default.
> For organizational purposes, I'd like to change this to something like
> /tmp/php_sessions/ or so. However, I have the clear_tmp_enable feature
> enabled, so /tmp is cleared on reboot. PHP wont create the
> php_sessions dir on it's own.
> 
> So basically, I'm looking for a way to create the dir
> /tmp/php_sessions/ each time the server is booted BEFORE apache
> starts. I'm sure I could do this somehow with the rc.d scripts, but I
> really have no idea how.
> 
> Thanks very much.

Hi APseudoUtopia,

In addition to the other solutions offered, you can also create a simple
script like this and place it in /usr/local/etc/rc.d/make_php_session_dir:

- ---------- cut ---------- cut ---------- cut ---------- cut ----------
# PROVIDE: make_php_session_dir
# REQUIRE: mountcritlocal

# Create the PHP session file directory
mkdir -p /tmp/php_sessions
- ---------- cut ---------- cut ---------- cut ---------- cut ----------

By using the "REQUIRE: mountcritlocal" tag, the rcorder system invokes
this script before the Apache startup script in /usr/local/etc/rc.d.  I
tested this on 7.0 with a standard Apache 2.2 installation from the
ports tree.

I hope this helps, and please post any follow-up questions you have.

Best regards,
Greg
- --
Greg Larkin

http://www.FreeBSD.org/       - The Power To Serve
http://www.sourcehosting.net/ - Ready. Set. Code.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJKsX70sRouByUApARApxhAJ9IaNPLMchvKf2J4I0P85AxV+JiOgCfSv+8
Y0SwTCn3f288E+lyWL1IMgs=
=pm8E
-----END PGP SIGNATURE-----



More information about the freebsd-questions mailing list