nginx安装

下载nginx压缩包

官网地址:http://nginx.org/en/download.html​​​​​​ 

将下载的压缩包放进去

安装所需求的环境

yum install gcc-c++

yum install -y pcre pcre-devel

yum install -y zlib zlib-devel

yum install -y openssl openssl-devel

解压安装包

tar -xvf nginx-1.24.0.tar.gz -C /usr/local

使用cofigure命令创建一个makefile文件

需要进入到解压的nginx-1.24.0目录里面去

./configure \

--prefix=/usr/local/nginx \

--pid-path=/var/run/nginx/nginx.pid \

--lock-path=/var/lock/nginx.lock \

--error-log-path=/var/log/nginx/error.log \

--http-log-path=/var/log/nginx/access.log \

--with-http_gzip_static_module \

--http-client-body-temp-path=/var/temp/nginx/client \

--http-proxy-temp-path=/var/temp/nginx/proxy \

--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \

--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \

--http-scgi-temp-path=/var/temp/nginx/scgi \

--with-http_stub_status_module \

--with-http_ssl_module \

--with-file-aio \

--with-http_realip_module

进行编译

make && make install

 

启动nginx

在启动前需要创建文件目录

mkdir /var/temp/nginx -p

cd /usr/local/nginx/sbin

./nginx

查看nginx是否启动

ps -aux | grep nginx

刷新配置文件

./nginx -s reload

关闭防火墙,开启远程访问

[root@131 sbin]# systemctl stop firewalld.service 

 配置虚拟主机

就是在一台服务器启动多个网站。

如何区分不同的网站:主要有以下两种方式

方式一:端口不同

方式二:域名不同

通过端口区分不同的主机

nginx配置文件的位置:/usr/local/nginx/conf/nginx.conf

原始配置文件的内容如下:

 下面测试以下:复制原来的html目录,改名为html-81

 cd /usr/local/nginx

cp -r html html-81

修改以下里面的index.html文件,方便区分

vim html-81/index.html

 修改完成之后刷新以下配置文件

 ./nginx -s reload

然后分别访问不同的端口

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值