首先花 79 元 在腾讯云购买1年的腾讯云轻应用服务器,优惠链接:
https://url.cn/YzyglSN0
完成购买之后,进入 管理面板:
https://console.cloud.tencent.com/lighthouse/instance
选择刚购买的服务器,选择重置密码,重置之后会重启服务器,然后通过外网IP使用ssh登录到服务器
ssh root@xxx.xxx.xxx.xxx
首先执行源的更新,默认选择宝塔服务器的话是centos 7的系统,执行一下命令更新
yum update
安装Nginx
yum install nginx
从源码安装nginx 可以参考另外一篇文章
安装最新版本PHP
当前服务器是Centos-7 ,默认的源里面是比较老的php版本,需要使用其他yum来下载最新版本
添加yum源
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
启动某个版本源
yum-config-manager --enable remi-php81
安装
yum install php php-fpm
启动 php-fpm 服务
systemctl start php-fpm
设置 php-fpm 开机启动
systemctl enable php-fpm
配置Nginx
站点使用workdpress来搭建,需要使用nginx代理php文件,具体nginx配置文件如下
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# try_files $uri $uri/ /index.php?$args;
}
location ~ .php(.*)$ {
root /data/www/wordpress; #你的网站目录,注意修改
fastcgi_pass 127.0.0.1:9000; #php-cgi监听地址
fastcgi_index index.php; #默认页
fastcgi_split_path_info ^(.+.php)(.*)$; #分离路径
fastcgi_param PATH_INFO $fastcgi_path_info; #添加PATH_INFO信息
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
校验nginx配置并重载
nginx -t
nginx -s reload