公認的Nginx的運行效能高于Apache,因此很多用戶喜歡在Linux下面搭建Nginx環境進行網站運營。對于Joomla用戶來說,Joomla偽靜態設置.htaccess是依賴Apache才能運行的。如果使用nginx 則需要進行一些設置才可以實現偽靜態效果。
并不復雜,在網站配置時,創建一個/nginx/conf/vhosts/joomla.conf (根據你的實際情況命名xxxx.conf) 文件中復制一下代碼:
server {
listen 80;
server_name YOUR_DOMAIN;(你要綁定的域名,多個域名用空格分開)
server_name_in_redirect off;
access_log /var/log/nginx/localhost.access_log;(設置日志文件)
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;
}
}
(注意:橘色部分根據你的服務器情況而定)
配置完成后,service nginx restart 進行服務重啟即可。
六翼團隊,致力于提供中國最專業的Joomla建站解決方案!





