What is the default location of session files on an installation of Apache/PHP on Ubuntu 10.10?
If unsure of compiled default for session.save_path
, look at the pertinent php.ini
.
Normally, this will show the commented out default value.
Ubuntu/Debian old/new php.ini
locations:
Older php5 with Apache: /etc/php5/apache2/php.ini
Older php5 with NGINX+FPM: /etc/php5/fpm/php.ini
Ubuntu 16+ with Apache: /etc/php/*/apache2/php.ini
*
Ubuntu 16+ with NGINX+FPM - /etc/php/*/fpm/php.ini
*
* /*/
= the current PHP version(s) installed on system.
To show the PHP version in use under Apache:
$ a2query -m | grep "php" | grep -Eo "[0-9]+\.[0-9]+"
7.3
Since PHP 7.3 is the version running for this example, you would use that for the php.ini
:
$ grep "session.save_path" /etc/php/7.3/apache2/php.ini
;session.save_path = "/var/lib/php/sessions"
Or, combined one-liner:
$ APACHEPHPVER=$(a2query -m | grep "php" | grep -Eo "[0-9]+\.[0-9]+") \ && grep ";session.save_path" /etc/php/${APACHEPHPVER}/apache2/php.ini
Result:
;session.save_path = "/var/lib/php/sessions"
Or, use PHP itself to grab the value using the "cli" environment (see NOTE below):
$ php -r 'echo session_save_path() . "\n";'
/var/lib/php/sessions
$
These will also work:
php -i | grep session.save_path
php -r 'echo phpinfo();' | grep session.save_path
NOTE:
The 'cli' (command line) version of php.ini
normally has the same default values as the Apache2/FPM versions (at least as far as the session.save_path
). You could also use a similar command to echo the web server's current PHP module settings to a webpage and use wget/curl to grab the info. There are many posts regarding phpinfo()
use in this regard. But, it is quicker to just use the PHP interface or grep
for it in the correct php.ini
to show it's default value.
EDIT: Per @aesede comment -> Added php -i
. Thanks