今天在lnmp环境下装joomla,结果nginx蛋疼的地方就在于重写规则都要自己来写,这点就比不上apache了。于是网上找啊,找找看有没有现成的。找来找去发现有好多版本,正在愁相信哪个。也就在这时,用英文再查了下,于是奇迹就出现了,出现了官方版本。
源地址:http://docs.joomla.org/Nginx
啥脑筋都不用动,官方都给了标准答案了,抄呗。
server { listen 80; server_name YOUR_DOMAIN; server_name_in_redirect off; access_log /var/log/nginx/localhost.access_log main; error_log /var/log/nginx/localhost.error_log info; root PATH_ON_SERVER; index index.php index.html index.htm default.html default.htm; # Support Clean (aka Search Engine Friendly) URLs location / { try_files $uri $uri/ /index.php?$args; } # deny running scripts inside writable directories location ~* /(images|cache|media|logs|tmp)/.*.(php|pl|py|jsp|asp|sh|cgi)$ { return 403; error_page 403 /403_error.html; } location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi.conf; } # caching of files location ~* .(ico|pdf|flv)$ { expires 1y; } location ~* .(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ { expires 14d; } }
记得把YOUR_DOMAIN改成你自己的域名,为了大家在vps上方便操作,我已经将其传到我的主机上,直接打开你的vhost目录用命令
wget https://tang.biz/joomla.conf
就可以下载到你的vps上了。