Session save path errors and the vhost.conf


Browse by products and services

  • Applies to: DV
    • Difficulty: Easy
    • Time Needed: 10
    • Tools Required: SSH, root access, vi knowledge
  • Applies to: DV 4.0
    • Difficulty: Easy
    • Time Needed: 10
    • Tools Required: SSH, root access, vi knowledge

Overview

Session support in PHP is of a way to preserve certain data across subsequent accesses. This enables you to build more customized applications for your web site.

The /var/lib/php/session/ directory should be writable by default.

READ ME FIRST

This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is unsupported by (mt) Media Temple. Please take a moment to review the Statement of Support.

Instructions

The default configuration on DV does not allow for this if you are running PHP as a specific user (using FCGI, for example). To fix this, run the following command:


chmod 1777 /var/lib/php/session

It is also possible to fix this on a domain-by-domain basis using a special file called vhost.conf:

  1. Create the new directory to house your sessions inside of your domain directory:
    
    mkdir /var/www/vhosts/system/example.com/tmp
    

  2. Apply the appropriate permissions and file ownership:
    
    chown username:psaserv /var/www/vhosts/system/example.com/tmp && chmod 777 /var/www/vhosts/system/example.com/tmp
    
  3. Create the vhost.conf file in the following directory /var/www/vhosts/example.com/conf using the following command:
    
    vi /var/www/vhosts/system/example.com/conf/vhost.conf
    
  4. Next, include the following line:
    
    php_value session.save_path /var/www/vhosts/system/example.com/tmp
    
  5. Save the file and run this command to force Plesk to see the changes:
    
    /usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=example.com
    
  6. Restart Apache to load the new changes:
    
    service httpd graceful
    
  7. Your software should now use the new path for sessions data and your CMS installation should proceed.

Instructions

The default configuration on DV servers does not allow for this if you are running PHP as a specific user (using FCGI, for example). To fix this, run the following command:


chmod 1777 /var/lib/php/session

It is also possible to fix this on a domain-by-domain basis using a special file called vhost.conf:

  1. Create the new directory to house your sessions inside of your domain directory:
    
    mkdir /var/www/vhosts/example.com/tmp
    

    NOTE:

    Replace example.com with your domain name. If this is an additional domain on the same webspace or subscription, replace example.com for the root directory for the additional domain. The default directory for an additional domain in this example is site1.

    Figure 1.

  2. Apply the appropriate permissions and file ownership:
    
    chown username:psaserv /var/www/vhosts/example.com/tmp && chmod 777 /var/www/vhosts/example.com/tmp
    
  3. Create the vhost.conf file in the following directory /var/www/vhosts/example.com/conf using the following command:
    
    vi /var/www/vhosts/example.com/conf/vhost.conf
    
  4. Next, include the following line:
    
    php_value session.save_path /var/www/vhosts/example.com/tmp
    
  5. Save the file and run this command to force Plesk to see the changes:
    
    /usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=example.com
    
  6. Restart Apache to load the new changes:
    
    service httpd graceful
    
  7. Your software should now use the new path for sessions data and your CMS installation should proceed.

Resources