拖把厂家
免费服务热线

Free service

hotline

010-00000000
拖把厂家
热门搜索:
技术资讯
当前位置:首页 > 技术资讯

UbuntuLinuxnginx虚拟主机配置和伪静态Rewrite配置笔记

发布时间:2020-06-29 17:27:42 阅读: 来源:拖把厂家

拷贝一份/etc/nginx/sites-available下的default # You may add here your# server {# …# }# statements for each of your virtual hostsserver {listen 80 default;server_name localhost;access_log /var/log/nginx/g;location / {root /var/www/nginx-default;index ml m;}location /doc {root /usr/share;autoindex on;allow 127.0.0.1;deny all;}location /images {root /usr/share;autoindex on;}#error_page 404 /ml;# redirect server error pages to the static page /ml##error_page 500 502 503 504 /ml;#location = /ml {# root /var/www/nginx-default;#}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#proxy_pass ;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {#fastcgi_pass 127.0.0.1:9000;#fastcgi_index p;#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;#includefastcgi_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 ias;#location / {#root html;#index ml m;#}#}# HTTPS server##server {#listen 443;#server_name localhost;#ssl on;#ssl_certificate m;#ssl_certificate_key y;#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 ml m;#}#}然后改名名字比如home修改特别是红色部分server { # Replace this port with the right one for your requirements listen 80; # Multiple hostnames separated by spaces. Replace these as well. server_name ; #Alternately: _ root /var/www/home; error_page 404 /ml; access_log /var/log/nginx/nginx_g; index p ml m; # serve static files directly location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html)$ { access_log off; expires 30d; }#以下是Rewrite 规则rewrite ^(.*)/(space|network)\-(.+)\.html$ $1/$p?rewrite=$3 last;rewrite ^(.*)/(space|network)\.html$ $1/$p last;rewrite ^(.*)/([0-9]+)$ $1/p?uid=$2 last;#以上是Rewrite 规则 要注意直接放在没括号的位置就行 location ~ .php$ { # By all means use a different server for the fcgi processes if you need to fastcgi_pass 127.0.0.1:9000; fastcgi_index p; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_intercept_errors on; } location ~ /\.ht { deny all; }}启用虚拟主机ln -s /etc/nginx/sites-available/home /etc/nginx/sites-enabled/home会在/etc/nginx/sites-enabled下生成同名文件home跟apache有点像,但命令不一样同样按照上面办法可以配置出无限站点来,只要主机配置强大!然后重启nginx服务sudo /etc/init.d/nginx restartphp-cgi启动(没它会报502,稍后搞定它自动启动)spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi

金大宝官网

现代支付代理

现代支付金付通

金大宝