1
santa 2012-10-30 10:00:25 +08:00
后端Apache的话应该直接用.htaccess解决,nginix什么都不用做才对吧
|
3
anyforever 2012-10-30 10:22:20 +08:00 1
楼上两位的正解,应该在Apache里配置伪静态.
你找Apache下的配置方法就Ok了。 |
4
Gauin OP @anyforever 我试了 没弄好。Gtalk能给我下吗
|
5
chairo 2012-10-30 13:19:19 +08:00
添加.htaccess,且删除nginx里的伪静态规则
|
6
Gauin OP @chairo 下面是Nginx的 conf文件配置。删掉那些?
user daemon; worker_processes 8; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; pid logs/nginx.pid; google_perftools_profiles /var/tmp/tcmalloc; worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { server_tokens off; include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; tcp_nopush on; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; #keepalive_timeout 0; keepalive_timeout 120; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; include vhost/*.conf; server { listen 80; server_name www.gauin.com; #charset koi8-r; #access_log logs/host.access.log main; location / { root /usr/local/apache2/htdocs/wordpress/; index index.html index.htm index.php; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # location ~ \.(php|php5)?$ { proxy_pass http://127.0.0.1:81; } include proxy.conf; # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443; # server_name localhost; # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_timeout 5m; # ssl_protocols SSLv2 SSLv3 TLSv1; # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} } |
7
chairo 2012-10-30 14:05:48 +08:00
@Gauin 试试server段用这个写法,原配置文件保留备份,如果下边这段不能用建议恢复成你的那个文件
server { listen 80; server_name www.gauin.com; index index.html index.htm index.php; root /usr/local/apache2/htdocs/wordpress/; location / { try_files $uri @apache; } location @apache { internal; proxy_pass http://127.0.0.1:81; include proxy.conf; } location ~ .*\.(php|php5)?$ { proxy_pass http://127.0.0.1:81; include proxy.conf; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } |
8
ajoop 2012-10-30 14:09:59 +08:00
如果就一个博客的话,没必要后端用apache了,直接LNMP就可以了,占用资源还少,如果用军哥LNMP一键安装包的话,添加网站时候会提示你是否设置rewrite的,其中就有WP伪静态的选项,根本不用自己去写。
|
9
Gauin OP |
11
TONYHEAD 2012-10-31 14:48:19 +08:00
有插件的,搜索下nginx
|
12
ybf1220 2012-10-31 15:00:44 +08:00
其实前端 nginx 后端 apache 和直接 nginx+php-fpm 相差不是很大。在20%之内。再说 apache2 对 内存是占用很大的。而且容易跨站。 只是对付 php 的话 用php-fpm 管理 fastcgi,这样执行足以,要性能好,可以再安装缓存插件 ,比如 eacc ,memcache,APC,xcache 等,轻量级我比较推崇,虽然 apache2 现在还是web服务器的老大。
|