Home > System Tutorial > LINUX > body text

How to put a website into memory to speed up the website under Linux

WBOY
Release: 2024-08-07 18:46:33
Original
1080 people have browsed it

/dev/shm/ is a device file, which uses the tmpfs file system (Note: Under Centos and Redhat, the /dev/shm directory is a link pointing to the /run/shm directory, in Ubuntu The tmpfs file system under the system corresponds to the /run/shm directory, which can be viewed using the df command), because the /dev/shm/ directory is not on the hard disk, but in the memory. It is the so-called tmpfs. You can see through the command df -h that the default size of tmpfs is half of the physical memory, and of course it can be adjusted according to the actual situation.

How to put a website into memory to speed up the website under Linux

First create a directory wpcache for wordpress cache files

mkdir /dev/shm/wpcache
Copy after login

Give read, write and execute permissions

chmod 1777 /dev/shm/wpcache
Copy after login

Mount tmpfs to the /cache directory generated by the wordpress cache plug-in

mount --bind /dev/shm/wpcache /home/wwwroot/trojansun.com/wp-content/cache ls -ld /dev/shm/wpcache
Copy after login

Return content similar to the following to indicate successful mounting

drwxrwxrwt 3 www www 60 Jul 31 22:50 /dev/shm/wpcache
Copy after login

At this time, the cache plug-in will regenerate the static page file. After a while, you can check the usage of tmpfs by command df -h.

Two issues to note:

1. Adjust the cache page expiration time in the wordpress cache plug-in according to the actual situation (memory size, number of articles), otherwise it will take up too much memory;

2. Pay attention to adding a swap partition to prevent backup when the memory is not enough. If the physical memory is less than 4G, set the swap partition size to 2G.

The above is the detailed content of How to put a website into memory to speed up the website under Linux. For more information, please follow other related articles on the PHP Chinese website!

source:linuxprobe.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!