# 配置MariaDB以便普通用户能够不使用root权限来访问数据库 sudo mysql MariaDB> use mysql; MariaDB> update user set plugin=''where User='root'; MariaDB> flush privileges; MariaDB> exit
# 然后使用如下命令执行数据库命令 mysql -u root -p -e 'show databases'
# Usually equal to number of CPUs you have. worker_processes1;
# Global error log [ debug | info | notice | warn | error | crit ]. error_log /var/log/nginx/error.log warn;
# Pid file pid /run/nginx.pid;
events { worker_connections1024; }
http { ### Basic Settings ###
include /etc/nginx/mime.types; default_type application/octet-stream; sendfileon; tcp_nopushon; tcp_nodelayon; keepalive_timeout60; client_max_body_size15m; # Limit the max size of plugin in Wordpress.
# Managed by Certbot listen443 ssl; ssl_certificate /etc/letsencrypt/live/localhost/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/localhost/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
if ($scheme != "https") { return301 https://$host$request_uri; }
# Add rewrite support for wordpress location / { try_files $uri $uri/ /index.php?$args; rewrite /wp-admin$ $scheme://$host$uri/ permanent; }
# Cache strategy set $no_cache 0;
# POST requests and urls with a query string should always go to PHP if ($request_method = POST) { set $no_cache 1; } if ($query_string != "") { set $no_cache 1; }
# Don't cache uris containing the following segments if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { set $no_cache 1; }
# Don't use the cache for logged in users or recent commenters if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { set $no_cache 1; }
location~ /wp-admin { location~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; # Making the updates in Wordpress real time. fastcgi_bufferingoff; add_header X-Accel-Buffering "no"; } }
# Purge cache(Nginx Helper Purge Method: Using a Get) location~ /purge(/.*) { allow127.0.0.1; allow182.254.246.42; deny all; fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1"; }
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) location~ /\. { deny all; }
# Deny access to any files with a .php extension in the uploads directory # Works in sub-directory installs and also in multisite network # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) location~* /(?:uploads|files)/.*\.php$ { deny all; }