# php - configure shared memory
###### tags: `php`
```
(1). Set the size of SHM in the system in "/etc/sysctl.conf" file.
kernel.shmmax=6000000000
kernel.shmall=6000000000
kernel.shmmni=6000000000
(2). Set the size of SHM of PHPin "/etc/php5/apache2/php.ini" file.
memory_limit = 4000M ; Maximum amount of memory a script may consume (128MB)
sysvshm.init_mem = 6000000000
php_sysvshm.init_mem = 6000000000
(3). Use shared memory in your PHP program.
EX:
$shm_key = 123456789;
$shm_id = shm_attach($shm_key);
shm_put_var($shm_id, 1, array());
shm_get_var($shm_id, 1)
!!! your PHP must compiled with SHM support. Which means "./configure .... --enable-pcntl --enable-ftp --enable-sysvshm --enable-sysvsem --enable-shmop"
```