nginx+php-fpm5.6搭建wordpress
通过docker安装php-fpm,安装之前提提前将配置文件提取出来,参考 文章 docker安装php5.6
docker run -p 9400:9000 --name myphp-fpm -v /usr/local/php/www:/www -v /usr/local/php/etc:/usr/local/etc -v /usr/local/php/logs:/phplogs -d php:5.6-fpm
配置nginx
server {
listen 80;
server_name i5i5i5.com www.i5i5i5.com;
rewrite ^(.*)$ https://i5i5i5.com$1 permanent;
}
server {
listen 443 ;
server_name i5i5i5.com www.i5i5i5.com;
ssl_certificate /usr/local/nginx/certs/www.i5i5i5.com.pem;
ssl_certificate_key /usr/local/nginx/certs/www.i5i5i5.com.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
client_max_body_size 20m;
client_body_buffer_size 128k;
gzip on;
gzip_buffers 32 4K;
gzip_comp_level 6;
gzip_min_length 100;
gzip_types application/javascript text/css text/xml application/font-woff;
gzip_disable "MSIE [1-6]\.";
root /usr/local/php/www/i5i5i5;
if ( $host = 'www.i5i5i5.com') {
rewrite ^/(.*)$ https://i5i5i5.com/$1 permanent;
return 301;
}
location ^~ /.well-known/acme-challenge/ {
default_type "text/plain";
root /usr/local/nginx/webroot/i5i5i5;
}
location ~* \.(css|js)$ {
root /usr/local/php/www/i5i5i5;
index index.html index.php;
}
location ~ ^(.*)\.(png|jpg|jpeg|gif|webp|bmp|tiff|tif|svg)$ {
root /usr/local/php/www/i5i5i5;
index index.html index.php;
}
location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 200 302 1d;
fastcgi_cache_valid 404 500 502 503 504 0s;
fastcgi_cache_valid any 1d;
fastcgi_cache_use_stale error timeout invalid_header http_500 http_503 updating;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
add_header X-Cache "$upstream_cache_status - $upstream_response_time";
fastcgi_cache_key "$scheme$request_method$host$request_uri";
include fastcgi_params;
fastcgi_pass localhost:9400;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/i5i5i5/$fastcgi_script_name;
}
}
try_files $uri $uri/ /index.php?$args; 比较重要,
root /usr/local/php/www/i5i5i5; 这个重要,之前请求首页一直403,发现这个也会影响,具体原因应该是觉得nginx没有权限才会出现403
上一篇: css小技巧
下一篇: 2.CSS语法——《