1,购买云服务器
2,配置安全项
云服务器ecs下,配置ip、端口所有人都可访问
3,关闭防火墙,将前端静态项目传输到云服务器上
可以使用SecureCRT,本地远程连接到服务器(需要用户名与密码,ip等),
关闭防火墙:
systemctl stop firewalld --停止Firewalld服务
systemctl disable firewalld --禁止Firewalld在系统启动时自动启动
项目可放到/var/www/html下,需新建
传文件详见:
mac使用crt传输下载文件
传完文件权限设置777
chmod 777 myfolder
4,下载并配置nginx
配置.
vim /etc/nginx/nginx.conf #编辑配置文件
我的配置文件:
user root;#这里需改成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;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
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;
server {
listen 80;
listen [::]:80;
root /var/www/html;#这里需改前端文件根目录
server_name 144.55.xxx.xx;#这里需改为主机公网ip或域名
allow all;#这里允许所有人访问
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /var/www/html/personalWeb;#这里需改前端文件首页目录
index index.html;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
修改完成后,保存,重启nginx命令:
sudo systemctl restart nginx
5,访问
公网id(或域名,需要备案与配置)+nginx配置的端口访问