连接远程服务器
1.阿里云控制台
远程连接
2.本地命令链接
ssh root@公网IP
3.客户端连接
FileZilla、Xshell、Xftp
安装Nginx
- Ubuntu
sudo(超级用户) 更新 sudo apt-get update 下载 sudo apt-get install nginx 查看进程 ps aux | grep nginx
- CentOs
升级所有包同时也升级软件和系统内核 yum -y update 只升级所有包,不升级软件和系统内核 yum -y upgrade 下载 yum install nginx 手动启动nginx service nginx start 查看进程 ps aux | grep nginx
- 数据源安装
下载nginx wget https://nginx.org/download/nginx-1.21.0.tar.gz 解压 tar -zxvf nginx-1.21.0.tar.gz 检测环境 ./configure 安装模块 apt-get install libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev 配置路径 ./configure --sbin-path=/usr/bin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --with-pcre --with-http_ssl_module 编译 make 安装 make install
本地上传文件
// 上传文件
scp <需要上传的本地文件路径> root@xxx.xxx.xxx.xxx:/<想要保存在服务器的位置>
// 将文件夹全部上传上去
scp -r <需要上传的本地文件路径> root@xxx.xxx.xxx.xxx:/<想要保存在服务器的位置>
拷贝服务器文件
scp -r root@xxx.xxx.xxx.xxx<想要拷贝的文件的位置> <想要保存到本地的位置>
systemd
启动
systemctl start nginx
关闭
systemctl stop nginx
配置
创建文件
touch /lib/systemd/system/nginx.service
更改文件内容
nano /lib/systemd/system/nginx.service
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/vat/run/nginx.pid
ExecStartPre=/usr/bin/nginx -t
ExecStart=/usr/bin/nginx
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
查看状态
systemctl status nginx
重启之后自启nginx服务
systemctl enable nginx
重载systemd配置文件
systemctl daemon-reload
启动服务
systemctl start nginx.service
开机启动
systemctl enable nginx.service
更多命令
// 重新加载nginx服务
systemctl reload nginx.service
// 停止nginx服务
systemctl stop nginx.service
配置nginx.conf
events{
}
http{
server{
# 80 http默认端口
# 443 https默认端口
listen : 80;
# 阿里云服务器
server_name:47.108.214.10
# 设置根路径
root /sites/Demo;
}
}
将静态页面部署到服务器上