GNU/Linux >> Linux の 問題 >  >> Ubuntu

apache2キャッシュを有効にしてubuntuでウェブサイトを高速化する方法

最初にmodを有効にします:

sudo a2enmod file_cache
sudo a2enmod headers
sudo a2enmod expires
Code language: Bash (bash)

次に、仮想ホストを編集します:

pico /etc/apache2/sites-enabled/000-default.conf
Code language: Bash (bash)

そして、仮想ホスト間にifmoduleを追加します:

<VirtualHost *:80>
ServerName www.lateweb.info
ServerAdmin [email protected]
DocumentRoot /home/latewebi/public_html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
#Include conf-available/serve-cgi-bin.conf
<IfModule mod_expires.c>
# Turn on the module.
ExpiresActive on
# Set the default expiry times.
ExpiresDefault "access plus 2 days"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType text/css "now plus 1 month"
ExpiresByType image/ico "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType text/html "access plus 600 seconds"
</IfModule>
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Code language: Apache (apache)

次に、apacheサービスを再起動します。

service apache2 restart
Code language: Bash (bash)

Ubuntu
  1. Ubuntu18.04でSSHを有効にする方法

  2. Ubuntuのバージョンを確認する方法

  3. Ubuntu 20.04 – Hweを有効にする方法は?

  1. Ubuntuリモートデスクトップを有効にする方法

  2. Ubuntu17.10で常夜灯を有効にする方法

  3. Ubuntu19.04で分数スケーリングを有効にする方法

  1. Ubuntu20.04でSSHを有効にする方法

  2. Ubuntuのバージョンを確認する方法

  3. Ubuntu18.04LTSでVarnishHTTPキャッシュを使用してApacheを高速化する方法