首页 > 系统服务 > 详细

Linux下安装nginx

时间:2019-04-12 16:25:31      阅读:197      评论:0      收藏:0      [点我收藏+]

1.whereis nginx

  首先查看服务器上是否已经安装过nginx,如果没有,继续。

2.cd usr/local

3. 安装依赖

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

   yum -y install wget httpd-tools vim
   yum -y install zlib zlib-devel

4. 下载tar包(nginx

wget http://nginx.org/download/nginx-1.14.2.tar.gz

5. 解压

tar -xvf nginx-1.14.2.tar.gz

6. 安装(cd nginx-1.13.7)

 mkdir nginx
./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf
make && make install(make->编译,make install->安装)

 注意:

  1)运行./configure报错: permission denied,

          说明文件不可执行,需要赋权:chmod +x configure

  2)运行make报错: make:*** No rule to make target `build‘, needed by `default‘.  Stop.

           yum update->删除现有的nginx解压的文件夹,重新解压

      3) 运行make install报错: 是同一个文件

           ./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf

7. 启动

   cd /usr/local/nginx/sbin

   运行./nginx

8.  如果访问不到,请确认服务器的该端口是否开启。

9. nginx.conf配置文件

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html/dist;
            index  index.html index.htm;
        }
  }
  server {
        listen       8082;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html/build;
            index  index.html index.htm;
        proxy_pass http://localhost:8080;
        }
  }

10.重启nginx

   kill -HUP pid

11.查看nginx全部进程

   ps -ef | grep nginx(e:全部进程,f:全格式)

 

                 

 

Linux下安装nginx

原文:https://www.cnblogs.com/lyraLee/p/10696721.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!