Web site acceleration is very annoying? Linux can solve

Source: Internet
Author: User
Keywords Server Website construction
Tags access cache cached centos data directory file files

The Linux system provides us with the solution, that is, the Tmpfs file system, TMPFS can use the memory directly, while not enough memory to use the swap partition to store. Also note that TMPFS is not persistent, restart data does not retain, please be sure to note, but we only use it to store cached files, even if the file is lost does not affect the site access, there is no risk.

/dev/shm/is a device file that uses the Tmpfs file system (note: Under CentOS and Redhat, the SHM directory is a link to the/RUN/SHM directory, under the Ubuntu system Tmpfs file system corresponds to/run/ The SHM directory can be viewed using the DF command because the/dev/shm/directory is not on the hard drive but in memory, which is called TMPFS. You can see by command DF, tmpfs default size is half of the physical memory, of course, can also be adjusted according to the actual situation.

First, create a directory for WordPress cache files Wpcache

Mkdir/dev/shm/wpcache
Grant Read and Write execution permissions

chmod 1777/dev/shm/wpcache
Mount Tmpfs to the cache directory generated by the WordPress cache plugin

Mount--bind/dev/shm/wpcache/home/wwwroot/trojansun.com/wp-content/cache Ls-ld/dev/shm/wpcache
Returns something similar to the following description Mount success

DRWXRWXRWT 3 www. 22:50/dev/shm/wpcache
At this time, the cache plug-in will regenerate the static paging file, after a period of time, through the command DF can find the use of TMPFS.

Two issues to be noted:

1. According to the actual situation (memory size, number of articles) to adjust the WordPress cache plug-in cache page expiration time, otherwise it will occupy too much memory;
2. Note that you add a swap partition to prevent memory from being available for standby, 4G physical memory to set the swap partition size to 2G.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.