前台html服务器,测试的时候不加缓存
server {
listen 82;
root D:/phpStudy/WWW/xxx;
index index.html index.htm;
location ~ .*/.(css|js|swf|htm|html)$ {
add_header Cache-Control no-store;
}
}
php项目 laravel , thinkphp , Ci 都用这个
server {
listen 83;
root D:/phpStudy/WWW/xxx/public;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ /.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
一般的php项目,例如测试的,非框架
server {
listen 80;
server_name mytest.com test.com;
root "D:/phpStudy/WWW/test.com";
location / {
index index.html index.htm index.php;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~ /.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
apache.conf
<VirtualHost *:80>
# Host that will serve this project.
ServerName app.dev
# The location of our projects public directory.
DocumentRoot /path/to/our/public
# Useful logs for debug.
CustomLog /path/to/access.log common
ErrorLog /path/to/error.log
# Rewrites for pretty URLs, better not to rely on .htaccess.
<Directory /path/to/our/public>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
</Directory>
</VirtualHost>
nginx.conf
server {
# Port that the web server will listen on.
listen 80;
# Host that will serve this project.
server_name app.dev;
# Useful logs for debug.
access_log /path/to/access.log;
error_log /path/to/error.log;
rewrite_log on;
# The location of our projects public directory.
root /path/to/our/public;
# Point index to the Laravel front controller.
index index.php;
location / {
# URLs to attempt, including pretty ones.
try_files $uri $uri/ /index.php?$query_string;
}
# Remove trailing slash to please routing system.
if (!-d $request_filename) {
rewrite ^/(.+)/$ /\ permanent;
}
# PHP FPM configuration.
location ~* /.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+/.php)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# We don't need .ht files with nginx.
location ~ //.ht {
deny all;
}
# Set header expirations on per-project basis
location ~* /.(?:ico|css|js|jpe?g|JPG|png|svg|woff)$ {
expires 365d;
}
}
lighttpd.conf
$HTTP["host"] =~ "example.com$" {
server.document-root = "/path/to/our/public/"
accesslog.filename = "/path/to/access.log"
alias.url = ()
url.redirect = ()
url.rewrite-once = (
"^/(css|img|js|fonts)/.*/.(jpg|jpeg|gif|png|swf|avi|mpg|mpeg|mp3|flv|ico|css|js|woff|ttf)$" => "$0",
"^/(favicon/.ico|robots/.txt|sitemap/.xml)$" => "$0",
"^/[^/?]*(/?.*)?$" => "index.php/\"
)
}
参考
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/279911.html