Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos7 uses / dev/shm to optimize the website

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The / dev/shm directory is not on disk, but in memory, so using linux / dev/shm/ is very efficient and writes directly to memory.

View the size of / dev/shm

Df-h

Modify the size of / dev/shm, which defaults to half of memory

Vim / etc/fstab

Add at the end

Tmps / dev/shm tmpfs defaults,size=1G 0 0

Remount / dev/shm

Mount-o remount / dev/shm/

/ Application of dev/shm

Mkdir / dev/shm/tmp

Chmod 777 / dev/shm/tmp

Mount-B / dev/shm/tmp / tmp

Put the session file of php under / tmp

Vim / etc/php.ini

Modify it if you have it, and add it if you don't.

Session.save_path = "/ tmp"

/ dev/shm/tmp directory will be lost after restart. Set restart to automatically re-add / dev/shm/tmp

Touch shmTmp.sh

Chmod + x shmTmp.sh

Vim shmTmp.sh

Add:

#! / bin/bash

Mkdir / dev/shm/tmp

Chmod 777 / dev/shm/tmp

Mount-B / dev/shm/tmp/ / tmp

Set the script to be automatically executed on boot

Vim / etc/rc.local

Add at the end:

/ root/shmTmp.sh

Save exit and add execution file properties

Chmod + x / etc/rc.local

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report