centos7 关闭防火墙和配置nginx静态文件
如果不想放行端口,直接关闭防火墙即可防火墙查看防火墙状态firewall-cmd --state小编的是 running 状态,代表防火墙正在运行,如果是 not running 则代表防火墙是关闭状态停止防火墙systemctl stop firewalld.service禁止防火墙开机启动systemctl disable firewalld.servicenginx 配置此时默认nginx是
·
如果不想放行端口,直接关闭防火墙即可
防火墙
- 查看防火墙状态 firewall-cmd --state

小编的是 running 状态,代表防火墙正在运行,如果是 not running 则代表防火墙是关闭状态 - 停止防火墙
systemctl stop firewalld.service
- 禁止防火墙开机启动
systemctl disable firewalld.service
nginx 下载安装
- 查看gcc版本
gcc -v

如果为安装,需要安装 gcc
2. 安装gcc
yum -y install gcc

3. 安装 pcre、pcre-devel
yum install -y pcre pcre-devel

4. zlib安装
yum install -y zlib zlib-devel

- 安装openssl
yum install -y openssl openssl-devel

6. 下载nginx安装包
cd /usr/local
新建 nginx 文件夹
mkdir nginx
进入 nginx:
cd nginx
wget http://nginx.org/download/nginx-1.9.9.tar.gz

- 解压文件
tar -zxvf nginx-1.9.9.tar.gz

9. 进入 nginx-1.9.9 文件, 依次执行 ./configure make && make install
/usr/local/nginx/nginx-1.9.9

./configure
make && make install


- 进入 /usr/local/nginx/nginx-1.9.9/conf
cd /usr/local/nginx/conf

nginx 配置
此时默认nginx 是配置好的
- 进入 nginx配置文件
cd /usr/local/nginx/conf

请根据自己的情况进行处理
2. 进入配置文件 vim nginx.conf
server {
listen 80;
server_name 192.168.8.132;
location / {
root html;
index index.html index.htm;
}
location /static {
root /usr;
index index.html index.htm;
}

配置location 和 server_name(如果想让别的主机访问,请更改为ip 或者域名等)
小编的静态文件都放在了 /usr/static 下,请根据自己的情况进行配置
3. 进入 cd /usr/local/nginx/sbin
4. 启动nginx ,并查看 ngixn 的启动状态
./nginx
ps -ef | grep nginx

nginx 的启动 重启 停止
./nginx
./nginx -s reload
./nginx -s stop
- 访问 ngixn
http://192.168.8.132/

6. 访问静态文件
http://192.168.8.132/static/jp2.html

centos7配置redis开机自启动 centos7配置redis开机自启动
更多推荐
所有评论(0)