linux 部署Nginx

1,进入官网下载Nginx资源:

官网下载:http://nginx.org/en/download.html

2、下载 nginx-1.20.2 

3、上传服务器 /opt目录

4、解压nginx-1.20.2.tar.gz 到当前目录

tar -zxvf nginx-1.20.2.tar.gz

5、配置基本信息,命令如下

#配置configure --prefix 代表安装的路径,--with-http_ssl_module 安装ssl,--with-http_stub_status_module查看nginx的客户端状态
./configure --prefix=/usr/local/nginx-1.20.2 --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_dav_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module

6、执行第5步命令后可以看到我们的目录下,多了一个Makefile文件

7、开始编译文件

make & make install 

 8、编译成功后进入安装目录

cd /usr/local/nginx-1.20.2

9、进入sbin目录进行启动

cd sbin

./nginx

 10、通过ip:80访问

 11、如果发现有错误 可以执行如下命令,后再次编译

yum -y install gcc gcc-c++ autoconf automake make  openssl openssl-devel

12、配置nginx的web访问项目

打开 /usr/local/nginx-1.20.2/conf/nginx.conf

执行命令

vi conf/nginx.conf

最下面的 花括号“}”里面添加如下案例代码

server {
        listen  80; #端口
        server_name  127.2.0.1; #IP
        location / {
            alias  /opt/web/;  #web地址
            index  index.html index.htm;
        }
    }

最后验证配置文件 进入 sbin执行以下命令

./nginx -t

重新加载配置文件

./nginx -s reload

猜你喜欢

转载自blog.csdn.net/GL666/article/details/130849761
今日推荐