连接到服务器
ssh root@[服务器IP地址],然后输入服务器密码
退出服务器
logout
配置Web服务器(nginx)
运行以下命令备份Nginx配置文件。
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
运行以下命令打开Nginx配置文件。
vim /etc/nginx/nginx.conf
修改nginx权限
user nginx; => user root;
- 在
Server大括号内,添加下列配置信息
前端工程放到www文件夹下
location / {root /root/www/;index index.html index.htm;try_files $uri /index.html;}location /api {proxy_pass http://localhost:8000;proxy_set_header Host $host;}
如果使用BrowserRouter,还需要设置try_files
location / {root /root/www/;index index.html index.htm;try_files $uri /index.html;}location /api {proxy_pass http://localhost:8000;proxy_set_header Host $host;}
运行以下命令启动Nginx服务。
systemctl start nginx
运行以下命令设置Nginx服务开机自启动。
systemctl enable nginx
检查Web配置:nginx -t
查看Web服务:ps -ef | grep nginx
启动Web服务:nginx
停止Web服务:nginx -s stop
重启Web服务:nginx -s reload
补充:如果删除文件的时候发生文件太大导致错误发生,把以下内容加入到配置文件中
#vim /etc/nginx/nginx.conf
client_max_body_size 20M
设置到http{}内,控制全局nginx所有请求报文大小
设置到server{}内,控制该server的所有请求报文大小
设置到location{}内,控制满足该路由规则的请求报文大小
!!强烈建议:开启gzip压缩,可以极大的缩短页面加载时间
server {listen 80 default_server;listen [::]:80 default_server;server_name _;root /usr/share/nginx/html;# Load configuration files for the default server block.include /etc/nginx/default.d/*.conf;location / {root /root/www/;index index.html index.htm;try_files $uri /index.html;}location /api {proxy_pass http://localhost:8000;proxy_set_header Host $host;}error_page 404 /404.html;location = /40x.html {}error_page 500 502 503 504 /50x.html;location = /50x.html {}#on为启用,off为关闭gzip on;#设置允许压缩的页面最小字节数,页面字节数从header头中的Content-Length中进行获取。默认值是0,不管页面多大都压缩。建议设置成大于1k的字节数,小于1k可能会越压越大。gzip_min_length 1k;#获取多少内存用于缓存压缩结果,‘4 16k’表示以16k*4为单位获得gzip_buffers 4 16k;#gzip压缩比(1~9),越小压缩效果越差,但是越大处理越慢,所以一般取中间值gzip_comp_level 5;#对特定的MIME类型生效,其中'text/html’被系统强制启用#gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php;gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;#gzip_http_version 1.0;}
上传文件到服务器
- 使用scp命令
- scp -r local_dir user@ip:remote_dir
cd [前端工程目录]scp -r ./* root@[服务器IP地址]:/root/www
./* 表示当前目录下的所有文件
所以,以上命令的意思就是:把当前文件夹里的所有文件,上传到服务器的www文件夹下
上传完文件之后,直接在浏览器中输入服务器地址,就能看到网站了
终端中文显示
查看系统是否安装中文包
如果出现以下结果,说明已经安装中文包
[root@chenyisong logs]# locale -a | grep "zh_CN"zh_CNzh_CN.gb18030zh_CN.gb2312zh_CN.gbkzh_CN.utf8
修改配置文件:vim /etc/locale.conf
LANG="zh_CN.UTF-8" //改成自己需要的编码格式
然后做一下操作启动相关进程
cd redis-5.0.5 => make => src/redis-server
cd server => npm run prd
JDK环境搭建及项目部署
- Linux/Unix操作系统上JDK环境的配置
- Linux/Unix操作系统上web运行环境的配置
- Linux/Unix操作系统上java项目的部署发布
