nginx安装步骤

1、下载nginx的依赖

 [root@localhost nginx-1.25.1]# yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

2、在Linux系统上下载nginx

 [root@localhost vagrant]# wget http://nginx.org/download/nginx-1.25.1.tar.gz

3、便于管理,可以创建一个文件夹保存(可跳过)

 [root@localhost vagrant]# mkdir /usr/web    #创建文件夹
 [root@localhost vagrant]#  mv nginx-1.25.1.tar.gz /usr/web #将包移动到指定文件夹下
 [root@localhost vagrant]# cd /usr/web   #进入到指定文件夹下
 [root@localhost web]# ls    #查看文件夹下内容
 nginx-1.25.1.tar.gz

注:# 后是命令解释

4、解压并进入nginx文件夹下

 [root@localhost web]# tar -zxf nginx-1.25.1.tar.gz  #解压文件夹
 [root@localhost web]# cd nginx-1.25.1   #进入到nginx文件夹下

5、配置nginx

 [root@localhost nginx-1.25.1]# ./configure

出现如下信息,代表nginx配置成功

 Configuration summary
   + using system PCRE library
   + OpenSSL library is not used
   + using system zlib library
 ​
   nginx path prefix: "/usr/local/nginx"
   nginx binary file: "/usr/local/nginx/sbin/nginx"
   nginx modules path: "/usr/local/nginx/modules"
   nginx configuration prefix: "/usr/local/nginx/conf"
   nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
   nginx pid file: "/usr/local/nginx/logs/nginx.pid"
   nginx error log file: "/usr/local/nginx/logs/error.log"
   nginx http access log file: "/usr/local/nginx/logs/access.log"
   nginx http client request body temporary files: "client_body_temp"
   nginx http proxy temporary files: "proxy_temp"
   nginx http fastcgi temporary files: "fastcgi_temp"
   nginx http uwsgi temporary files: "uwsgi_temp"
   nginx http scgi temporary files: "scgi_temp"

6、编译安装nginx

 [root@localhost nginx-1.25.1]# make&&make install

出现如下信息,代表安装成功

 make[1]: Leaving directory `/usr/web/nginx-1.25.1'

7、运行nginx

 [root@localhost local]# cd /usr/local/nginx/sbin
 [root@localhost sbin]# ./nginx

8、查看nginx状态

 [root@localhost sbin]# ps -ef| grep nginx
 root      7489     1  0 02:02 ?        00:00:00 nginx: master process ./nginx
 nobody    7490  7489  0 02:02 ?        00:00:00 nginx: worker process
 root      7621  2632  0 02:05 pts/0    00:00:00 grep --color=auto nginx

9、查看安装结果

 [root@localhost conf]# curl http://localhost:80
 <!DOCTYPE html>
 <html>
 <head>
 <title>Welcome to nginx!</title>
 <style>
 html { color-scheme: light dark; }
 body { width: 35em; margin: 0 auto;
 font-family: Tahoma, Verdana, Arial, sans-serif; }
 </style>
 </head>
 <body>
 <h1>Welcome to nginx!</h1>
 <p>If you see this page, the nginx web server is successfully installed and
 working. Further configuration is required.</p>
 ​
 <p>For online documentation and support please refer to
 <a href="http://nginx.org/">nginx.org</a>.<br/>
 Commercial support is available at
 <a href="http://nginx.com/">nginx.com</a>.</p>
 ​
 <p><em>Thank you for using nginx.</em></p>
 </body>
 </html>

10、可以直接访问浏览器http://你的ip地址:80

如果出现下图,表示安装成功

注意:如果是在云上操作,需要配置安全组,把80端口开放出来

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值