This topic describes how to change the session directory for an HTTP trigger that uses the PHP runtime in Function Compute.
Because Function Compute is serverless, it stores shared content such as web application files and temporary cache in a NAS directory by default. To move the session directory to a shared NAS directory for the PHP runtime, follow the steps in this topic.
-
Create a directory named extension in the same directory as the entry file. The directory structure is as follows:
. |____extension | |____my_ext.ini |____index.php -
Edit the my_ext.ini file to set the session storage directory and enable automatic session startup.
In the following example, the last two lines set the session storage path and enable automatic session startup.
extension=session.so extension=ftp.so extension=shmop.so extension=bcmath.so extension=gettext.so extension=pcntl.so extension=simplexml.so extension=xmlreader.so extension=bz2.so extension=gmp.so extension=pdo.so extension=soap.so extension=xmlrpc.so extension=calendar.so extension=iconv.so extension=pdo_mysql.so extension=sockets.so extension=xmlwriter.so extension=ctype.so extension=imagick.so extension=phar.so extension=sysvmsg.so extension=dom.so extension=json.so extension=posix.so extension=sysvsem.so extension=exif.so extension=mbstring.so extension=protobuf.so extension=sysvshm.so extension=fileinfo.so extension=mysqli.so extension=redis.so extension=zip.so extension=memcached.so extension=tokenizer.so session.save_path=/mnt/www session.auto_start=1 -
Create a function from the code package with the directory structure above. For more information, see Create a function.
-
Add an environment variable to the function to make
PHP_INI_SCAN_DIRscan for additional INI files, such as my_ext.ini. For more information, see Create a web function. In the Environment Variables configuration of the function, add a variable namedPHP_INI_SCAN_DIRwith the value/code/extention.