wordpress官方下载地址:https://cn.wordpress.org/download/
搭建步骤:
- Linux服务器
- 安装PHP环境
- 安装Mysql数据库
- 安装Nginx
安装环境(推荐Docker来部署,省去了繁琐的环境配置)
# 安装PHP
sudo yum update -y # 确保系统组件最新
sudo yum install -y php php-cli php-fpm php-mysqlnd php-gd php-mbstring php-curl php-xml php-zip # 常用扩展套件
# 安装Mysql,创建名为“wordpress”数据库
# 安装nginx
sudo yum install -y nginx
Nginx配置文件
nginx.conf
# user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#access_log /var/log/nginx/access.log main;
server_tokens off;
sendfile on;
tcp_nopush on;
#tcp_nodelay on;
keepalive_timeout 3;
types_hash_max_size 4096;
#gzip on;
#php max upload limit cannot be larger than this
client_max_body_size 13m;
index index.php index.html index.htm;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
upstream php {
#this should match value of "listen" directive in php-fpm pool
server unix:/run/php-fpm/www.sock;
}
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
# 安全头设置
# add_header X-Content-Type-Options "nosniff" always;
# add_header X-Frame-Options "SAMEORIGIN" always;
# add_header X-XSS-Protection "1; mode=block" always;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi.conf;
fastcgi_index index.php;
fastcgi_intercept_errors on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_pass php;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
}