服务器信息
centos_7_04_64_20G
CentOS7使用firewalld打开关闭防火墙与端口
1、firewalld的基本使用
启动: systemctl start firewalld
查看状态: systemctl status firewalld
停止: systemctl disable firewalld
禁用: systemctl stop firewalld
2.firewalld是centos7的一大特性,最大的好处有两个:支持动态更新,不用重启服务;
启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed
3.配置firewalld-cmd
查看版本: firewall-cmd --version
查看帮助: firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
安装配置Nginx
安装Nginx
提示No package nginx available 需要先安装epe:
yum install epel-release
安装epel之后
yum -y install nginx
安装完成之后
service nginx start 启动nginx
配置Nginx
- cd到 /etc/nginx目录下
vi nginx.conf
- 配置,以下有两个配置:
# 反向代理,将3389端口代理到80端口下
server {
listen 80;
# listen [::]:80 default_server;
server_name 127.0.0.1:3389;
root /home/app;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass http://127.0.0.1:3389;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# 监听8082端口,同时访问ip:8082/teacher/static的时候代理到/home/vue/static目录下
server {
listen 8082;
# listen [::]:80 default_server;
server_name _;
root /home/vue;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
index index.html index.htm;
}
location /teacher/static {
alias /home/vue/static;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
3.配置完成,重启Nginx
nginx -s reload
总结
以上就是阿里云服务器的基本配置,了解更多可以看我的博客