将网站放到内存中运行

  • A+
所属分类:运维教程

在Linux系统中有一个神奇的目录/dev/shm,为什么说它神奇呢?因为这货直接挂载到内存中,也就是说,它并非使用硬盘块设备存储,而是直接写入数据到内存中,所以读写速度几乎是瞬间的。

今天教大家如何将自己网站,放到该目录中运行,其实非常简单,如果你运行的是apache,只需要修改下DocumentRoot就行了,大致代码如下:

  1. <VirtualHost *:80>
  2.     ServerName birdteam1.net
  3.     DocumentRoot /dev/shm/birdteam.net
  4. </VirtualHost>

如果你运行的是nginx,那么代码如下:

  1. server
  2. {
  3.     listen 80;
  4.     server_name birdteam.net www.birdteam.net;
  5.     index index.php index.html index.htm default.php default.htm default.html;
  6.     root /dev/shm/birdteam.net;
  7. }

然后将自己网站根目录中的所有文件,放到指定目录即可,是不是特别的简单,现在来感觉下飞速运行的网站吧!

  • 问答中心
  • 微信小程序扫一扫
  • weinxin
  • 微信公众
  • 微信公众号扫一扫
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:24   其中:访客  24   博主  0

    • avatar click now

      Hi there! I know this is kind of off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having problems finding one? Thanks a lot!

      • avatar cbd oil that works 2020

        Thanks for sharing your thoughts about 网站. Regards

        • avatar cbd oil that works 2020

          Howdy! This post couldn’t be written any better! Reading through this post reminds me
          of my previous roommate! He constantly kept preaching about this.
          I will send this information to him. Fairly certain he’ll have a good read.
          I appreciate you for sharing!

          • avatar try this website

            Wow, awesome blog format! How long have you been blogging for? you made running a blog look easy. The full glance of your web site is magnificent, as neatly as the content material!