我有几个站点在 ezplatform 的 symfony 3 上运行,但缓存文件夹无限增长,需要我每周手动清除一次。
root@myserver:/# df -ih
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/ploop41633p1 6,2M 2,5M 3,7M 41% /
none 256K 17 256K 1% /sys/fs/cgroup
none 256K 79 256K 1% /dev
tmpfs 256K 1 256K 1% /dev/shm
tmpfs 256K 180 256K 1% /run
tmpfs 256K 3 256K 1% /run/lock
none 256K 1 256K 1% /run/shm
周末,免费节点从 32% 免费增加到 41%。
主机使用 2gig ram 和 100gig SSD 运行。
该系统在没有任何 Varnish 缓存的 Apache 2.4 上运行,我们不想考虑该站点的 Varnish 缓存开销,因为这是矫枉过正。
我刚刚清除了站点的整个缓存并运行了与上面相同的命令显示:
root@acrontum01:/# df -ih
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/ploop41633p1 6,2M 85K 6,1M 2% /
none 256K 17 256K 1% /sys/fs/cgroup
none 256K 79 256K 1% /dev
tmpfs 256K 1 256K 1% /dev/shm
tmpfs 256K 180 256K 1% /run
tmpfs 256K 3 256K 1% /run/lock
none 256K 1 256K 1% /run/shm
保持该服务器存活的唯一方法不可能是在 cron 上运行手动缓存清除吗?
apache vhost 文件如下,SYMFONY_ENV 设置为 prod:
<IfModule mod_ssl.c>
<VirtualHost 0.0.0.0:443 >
ServerName "myserver.com:443"
ServerAlias "www.myserver.com"
ServerAlias "myserver.com"
ServerAdmin "info@myserver.com"
UseCanonicalName Off
DocumentRoot "/var/www/vhosts/myserver.com/releases/current/web"
<Directory /var/www/vhosts/myserver.com/releases/current/web>
SSLRequireSSL
Options -Includes -ExecCGI
</Directory>
DirectoryIndex "app.php" "index.html" "index.cgi" "index.pl" "index.php" "index.xhtml" "index.htm" "index.shtml"
<FilesMatch "\.(jpeg|jpg|png|gif|js|css|woff2)$">
ExpiresActive On
ExpiresDefault "access plus 1 week"
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^myserver\.de$ [NC]
RewriteRule ^(.*)$ https://www.myserver.com$1 [L,R=301]
</IfModule>
## eZ Platform/Symfony ENVIRONMENT variables, used for customizing app.php execution (not used by console commands)
# Environment.
# Possible values: "prod" and "dev" out-of-the-box, other values possible with proper configuration
# Defaults to "prod" if omitted (uses SetEnvIf so value can be used in rewrite rules)
SetEnvIf Request_URI ".*" SYMFONY_ENV=prod
# Optional: Whether to use custom ClassLoader (autoloader) file
# Needs to be a valid path relative to root web/ directory
# Defaults to bootstrap.php.cache, or autoload.php in debug if env value is omitted or empty
#SetEnv SYMFONY_CLASSLOADER_FILE ""
# Optional: Whether to use debugging.
# Possible values: 0, 1 or ""
# Defaults to enabled if SYMFONY_ENV is set to "dev" if env value is omitted or empty
SetEnv SYMFONY_DEBUG 0
# Optional: Whether to use Symfony's builtin HTTP Caching Proxy.
# Disable it if you are using an external reverse proxy (e.g. Varnish)
# Possible values: 0, 1 or ""
# Defaults to disabled if SYMFONY_ENV is set to "dev" or SYMFONY_TRUSTED_PROXIES is set,
# and if this env value is omitted or empty
SetEnv SYMFONY_HTTP_CACHE 1
# Optional: Whether to use custom HTTP Cache class if SYMFONY_HTTP_CACHE is enabled
# Value must be a autoloadable cache class
# Defaults to to use provided "AppCache" if env value is omitted or empty
#SetEnv SYMFONY_HTTP_CACHE_CLASS ""
# Optional: Defines the proxies to trust
# Needed when using Varnish as proxy, if so disable SYMFONY_HTTP_CACHE.
# Separate entries by a comma, example: "proxy1.example.com,proxy2.example.org"
# Defaults to not be set if env value is omitted or empty
#SetEnv SYMFONY_TRUSTED_PROXIES ""
<IfModule mod_rewrite.c>
RewriteEngine On
# For FastCGI mode or when using PHP-FPM, to get basic auth working.
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Needed for ci testing, you can optionally remove this.
RewriteCond %{ENV:SYMFONY_ENV} "behat"
RewriteCond %{REQUEST_URI} ^/php5-fcgi(.*)
RewriteRule . - [L]
# Cluster/streamed files rewrite rules. Enable on cluster with DFS as a binary data handler
#RewriteRule ^/var/([^/]+/)?storage/images(-versioned)?/.* /app.php [L]
RewriteRule ^/var/([^/]+/)?storage/images(-versioned)?/.* - [L]
# Makes it possible to place your favicon at the root of your eZ Platform instance.
# It will then be served directly.
RewriteRule ^/favicon\.ico - [L]
# Give direct access to robots.txt for use by crawlers (Google, Bing, Spammers...)
# managed by seo bundle RewriteRule ^/robots\.txt - [L]
# Platform for Privacy Preferences Project ( P3P ) related files for Internet Explorer
# More info here : http://en.wikipedia.org/wiki/P3p
RewriteRule ^/w3c/p3p\.xml - [L]
# The following rule is needed to correctly display bundle and project assets
RewriteRule ^/bundles/ - [L]
RewriteRule ^/assets/ - [L]
# Additional Assetic rules for environments different from dev,
# remember to run php app/console assetic:dump --env=prod
RewriteCond %{ENV:SYMFONY_ENV} !^(dev)
RewriteRule ^/(css|js|fonts?)/.*\.(css|js|otf|eot|ttf|svg|woff) - [L]
RewriteRule .* /app.php
</IfModule>
# Everything below is optional to improve performance by forcing
# clients to cache image and design files, change the expires time
# to suite project needs.
<IfModule mod_expires.c>
<LocationMatch "^/var/[^/]+/storage/images/.*">
# eZ Platform appends the version number to image URL (ezimage
# datatype) so when an image is updated, its URL changes too
ExpiresActive on
ExpiresDefault "now plus 10 years"
</LocationMatch>
</IfModule>
<Directory /var/www/vhosts/myserver.com/releases/current>
AllowOverride AuthConfig FileInfo Limit Options=SymLinksIfOwnerMatch,MultiViews,FollowSymLinks,ExecCGI,Includes,IncludesNOEXEC
</Directory>
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/myserver.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/myserver.com/privkey.pem
</VirtualHost>
</IfModule>