码迷,mamicode.com
首页 > 系统相关 > 详细

Linux安装nginx

时间:2020-04-28 23:05:03      阅读:87      评论:0      收藏:0      [点我收藏+]

标签:pac   zookeeper   class   ready   sbin   pip   could not   ftp   执行   

1:使用xftp上传nginx-1.12.0.tar.gz到/usr/local/mysoft目录下(我一般把软件都安装到/usr/local/mysoft目录下)

[root@myLinux /]# cd usr/local/mysoft/
[root@myLinux mysoft]# ls
apache-tomcat-7.0.93 jdk1.8.0_251 nginx-1.12.0.tar.gz redis-5.0.7 zookeeper-3.4.14

2:解压nginx压缩包  tar -zxvf nginx-1.12.0.tar.gz


[root@myLinux mysoft]# tar -zxvf nginx-1.12.0.tar.gz
[root@myLinux mysoft]# ls
apache-tomcat-7.0.93  jdk1.8.0_251  nginx-1.12.0  nginx-1.12.0.tar.gz  redis-5.0.7  zookeeper-3.4.14

3:进入解压后的目录 

[root@myLinux mysoft]# cd nginx-1.12.0
[root@myLinux nginx-1.12.0]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src

4:执行./configure

[root@myLinux nginx-1.12.0]# ./configure
checking for OS
 + Linux 3.10.0-514.26.2.el7.x86_64 x86_64
checking for C compiler ... found

5:有可能make失败,所以我们先安装前置库  yum install -y gcc pcre pcre-devel openssl openssl-devel gd gd-devel

[root@myLinux nginx-1.12.0]# yum install -y gcc pcre pcre-devel openssl openssl-devel gd gd-devel

6:make

[root@myLinux nginx-1.12.0]# make
make -f objs/Makefile
make[1]: Entering directory `/usr/local/mysoft/nginx-1.12.0cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \

7make install

[root@myLinux nginx-1.12.0]# make install
make -f objs/Makefile install
make[1]: Entering directory `/usr/local/mysoft/nginx-1.12.0test -d ‘/usr/local/nginx‘ || mkdir -p ‘/usr/local/nginx‘

8:cd /usr/local  进入/usr/local目录  发现该目录下多了一个nginx文件夹

[root@myLinux nginx-1.12.0]# cd /usr/local
[root@myLinux local]# ls
aegis  bin  etc  games  include  lib  lib64  libexec  mysoft  mysql  nginx  sbin  share  src

9:cd nginx/conf 进入nginx的conf目录下

[root@myLinux local]# cd nginx/conf
[root@myLinux conf]# ls
fastcgi.conf          fastcgi_params.default  mime.types          nginx.conf.default   uwsgi_params
fastcgi.conf.default  koi-utf                 mime.types.default  scgi_params          uwsgi_params.default
fastcgi_params        koi-win                 nginx.conf          scgi_params.default  win-utf

10:vim nginx.conf 编辑nginx配置文件内容,为防止端口占用,将listen后面的端口号改为8081,将sever_name后面的localhost换成自己的服务器的ip

    server {
        listen       8081;
        server_name  11.97.188.188;

11: /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 启动nginx

[root@myLinux conf]#  /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nginx: [emerg] bind() to 0.0.0.0:8081 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8081 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8081 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8081 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8081 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[root@myLinux conf]# 

12:在浏览器地址栏中输入:ip:8081     出现nginx欢迎页说明安装并启动成功

 

技术图片

 

Linux安装nginx

标签:pac   zookeeper   class   ready   sbin   pip   could not   ftp   执行   

原文地址:https://www.cnblogs.com/misterwu/p/12797956.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!