Mac brew、rpm、服务器连接、Centos7 nginx配置、服务器防火墙操作

1.brew的安装

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

2.rpm的安装

brew install rpm

3.终端访问服务器

/** 打开终端输入下列命令 */
sudo su -

输入密码后出现下图表现后执行下一步 

ssh -p <端口号> <用户名>@<服务器公网ip>

出现下图红色框中所展示英文代表链接成功

4.nginx配置

/** 1.输入下列命令进入目录 */
$ cd /usr/local

/** 2.进入官网下载任意版本nginx */
$ wget http://nginx.org/download/nginx-1.9.12.tar.gz

/** 3.解压文件 */
$ tar -zxvf nginx-1.9.12.tar.gz

/** 使用命令查看文件列表,有nginx-1.9.12 目录则解压成功(可跳过) */
$ ls

/** 4.进入 nginx-1.9.12(若执行命令未发现文件使用ls查看列表无gz后缀文件继续执行第3步) */
$ cd nginx-1.9.12

/** 5.使用默认配置,若出现第6步错误,则执行第6步后,在重新执行第5步,未出现错误直接执行第7步*/
$ ./configure

/**
 *6.报错信息
 *./configure: error: the HTTP rewrite module requires the PCRE library.
 *You can either disable the module by using --without-http_rewrite_module
 *option, or install the PCRE library into the system, or build the PCRE library
 *statically from the source with nginx by using --with-pcre=<path> option.
 *执行下列命令
 */
$ yum install pcre-devel

/** 7.安装 */
$ make&&make install

/** 8.查看nginx安装目录 */  
$ whereis nginx

/** 9.进入nginx目录 */
$ cd /usr/local/nginx/sbin/

/** 10.启动nginx */
$ ./nginx

nginx其他命令

/** 停止nginx */
$ ./nginx -s stop

/** 重启nginx */
$ ./nginx -s reload

/** 查看或编辑nginx配置 */
$ vim nginx.conf

/** 查看是否已安装nginx及安装位置 */
$ find -name nginx

/** 卸载nginx(若已有nginx且卸载失败可直接使用rm命令删除文件再重新安装) */
$ yum remove nginx

/** 删除文件 */
$ rm -rf <文件名+路径>

5.服务器防火墙操作

/** 查看防火墙是否处于开启状态(dead未开启,running已开启) */
$ systemctl status firewalld

/** 开启防火墙(无任何提示代表开启成功)再次输入上条命令查看防火墙是否已开启 */
$ systemctl start firewalld

/** 关闭防火墙 */
$ systemctl stop firewalld

/** 重启防火墙 */
$ firewall-cmd --reload

/** 
 *开放指定端口
 *字段说明
 *

作用域                      –zone
 *添加端口,格式为:端口/通讯协议
 –add-port=80/tcp
 *永久生效,没有此参数重启后失效  –permanent
 */
$ firewall-cmd --permanent --zone=public --add-port=12456/tcp

/** 查看开放端口列表 */
$ firewall-cmd --permanent --list-port

/** 关闭不需要的端口 */
$ firewall-cmd --zone=public--remove-port=80/tcp --permanent

ps:仅作为个人记录,如有错误请指出,欢迎交流

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值