集成开发环境:Visual Studio Code版本:
Windows x64 1.64.0插件:
中文(简体)语言包
Remote Development服务器:
阿里云轻量应用服务器操作系统:
WordPress 5.6.2
一、VSCode远程连接服务器
1、使用服务器控制台远程连接服务器,在控制台切换至root账号,输入passwd
设置密码。
2、使用VSCode打开远程窗口,打开SSH配置文件(Open SSH Configuration File…),修改如下,保存后连接Host(Connect to Host…),输入密码。若服务器重置系统,需要在本地删除C:/Users/sciuridae/.ssh/known_hosts
文件。
#Host名Host sciuridae#IP地址HostName 121.41.11.127#用户名User root
二、配置Nginx虚拟主机和ssl证书
1、在usr/local/nginx/conf/vhost
新建虚拟主机配置文件(sciuridae.conf)如下。若需使用HTTPS,将SSL证书安装到/usr/local/nginx/conf/ssl
。
server{listen 80 default;listen [::]:80 default;#HTTPSlisten 443 ssl http2 default;listen [::]:443 ssl http2 default;ssl_certificate /usr/local/nginx/conf/ssl/sciuridae.xyz.pem;ssl_certificate_key /usr/local/nginx/conf/ssl/sciuridae.xyz.key;ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;ssl_prefer_server_ciphers on;ssl_session_timeout 10m;ssl_session_cache builtin:1000 shared:SSL:10m;ssl_buffer_size 1400;add_header Strict-Transport-Security max-age=15768000;ssl_stapling on;ssl_stapling_verify on;#服务名server_name www.sciuridae.xyz;#根目录路径root /data/wwwroot/sciuridae;#if ($ssl_protocol = "") { return 301 https://$host$request_uri; }#if ($host != sciuridae.xyz) { return 301 $scheme://sciuridae.xyz$request_uri; }#301重定向if ($host = sciuridae.xyz){return 301 https://www.sciuridae.xyz$request_uri;}include /usr/local/nginx/conf/rewrite/sciuridae.conf;}
2、在usr/local/nginx/conf/rewrite
新建配置文件(sciuridae.conf)如下。
#访问日志access_log /data/wwwlogs/access_nginx.log combined;#主页文件名index index.html index.htm index.php;#error_page 404 /404.html;#error_page 502 /502.html;#字符编码charset utf-8;location /nginx_status{stub_status on;access_log off;allow 127.0.0.1;deny all;}location ~ [^/]\.php(/|$) {#fastcgi_pass remote_php_ip:9000;fastcgi_pass unix:/dev/shm/php-cgi.sock;fastcgi_index index.php;include fastcgi.conf;}location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {expires 30d;access_log off;}location ~ .*\.(js|css)?$ {expires 7d;access_log off;}location ~ ^/(\.user.ini|\.ht|\.git|\.svn|\.project|LICENSE|README.md) {deny all;}
3、在根目录路径/data/wwwroot/sciuridae
部署Web项目文件。若文件过大可使用scp -r
命令传输文件。
4、在终端输入/usr/local/nginx/sbin/nginx -s reload
重启Nginx使配置生效。