官网下载安装包,这个没的说,而后安装宝塔面板,配置网站,核心是配置文件php
server{ listen 80; server_name www.baidu.com;#写本身域名 index index.php index.html index.htm default.php default.htm default.html; root ***********/public;#相对于绝对路径的目录 #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则 #error_page 404/404.html; #SSL-END #ERROR-PAGE-START 错误页配置,能够注释、删除或修改 error_page 404 /404.html; error_page 502 /502.html; #ERROR-PAGE-END #PHP-INFO-START PHP引用配置,能够注释或修改 include enable-php-72.conf; #PHP-INFO-END #REWRITE-START URL重写规则引用,修改后将致使面板设置的伪静态规则失效 include /www/server/panel/vhost/rewrite/XXXXXXXXXXXXXXXX.conf;#修改路径和文件名 #REWRITE-END location / { index index.php index.html index.htm; #若是请求既不是一个文件,也不是一个目录,则执行一下重写规则 if (!-e $request_filename) { #地址做为将参数rewrite到index.php上。 rewrite ^/(.*)$ /index.php?s=$1; #如果子目录则使用下面这句,将subdir改为目录名称便可。 #rewrite ^/subdir/(.*)$ /subdir/index.php?s=$1; } } location /api/ { index index.php index.html index.htm; #若是请求既不是一个文件,也不是一个目录,则执行一下重写规则 if (!-e $request_filename) { #地址做为将参数rewrite到index.php上。 #rewrite ^/(.*)$ /index.php?s=$1; #如果子目录则使用下面这句,将subdir改为目录名称便可。 rewrite ^/api/(.*)$ /api/index.php?s=$1; } } location ~ \.php { include fastcgi_params; ##pathinfo支持start #定义变量 $path_info ,用于存放pathinfo信息 set $path_info ""; #定义变量 $real_script_name,用于存放真实地址 set $real_script_name $fastcgi_script_name; #若是地址与引号内的正则表达式匹配 if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { #将文件地址赋值给变量 $real_script_name set $real_script_name $1; #将文件地址后的参数赋值给变量 $path_info set $path_info $2; } #配置fastcgi的一些参数 fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; ###pathinfo支持end fastcgi_intercept_errors on; fastcgi_pass 127.0.0.1:9000; # fastcgi_pass 若是是 sock形式,多是下面的配置 # fastcgi_pass unix:/tmp/php-cgi.sock } access_log /www/wwwlogs/****.log; error_log /www/wwwlogs/******.log; }