Nginx稳定安装

Nginx安装

环境准备

1,centos 7.5
2,nginx-1.16.1.tar.gz
下载链接: http://nginx.org/en/download.html
稳定版本 table version nginx-1.16.1

安装部署

# 1,解压进入目录
tar -zxvf nginx-1.16.1.tar.gz -C /usr/local/nginx/
cd  /usr/local/nginx/nginx-1.16.1/

# 2,安装编译工具及库文件
yum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel

# 3, 编译安装
./configure --prefix=/usr/local/nginx/nginx-1.16.1 --with-http_stub_status_module --with-http_ssl_module

make

make install

# 4,配置开机启动
vi /etc/rc.local
# 文件后面添加:/usr/local/nginx/nginx-1.16.1/sbin/nginx

# 5,启动nginx
./nginx

# 6,启动检查
ps -ef|grep nginx

详细步骤(包括异常处理)

[root@sentos local]# cd /home/ 
[root@sentos home]# ls
apache-tomcat-8.5.53.tar.gz  jdk-8u161-linux-x64.tar.gz  mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz  nginx-1.16.1.tar.gz  redis-4.0.9.tar.gz
[root@sentos home]# tar -zxvf nginx-1.16.1.tar.gz -C /usr/local/nginx/
[root@sentos home]# cd /usr/local/nginx/
[root@sentos nginx]# ls
nginx-1.16.1
[root@sentos nginx]# yum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel

[root@sentos nginx]# cd nginx-1.16.1/
[root@sentos nginx-1.16.1]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src
[root@sentos nginx-1.16.1]# pwd
/usr/local/nginx/nginx-1.16.1
[root@sentos nginx-1.16.1]# ./configure --prefix=/usr/local/nginx/nginx-1.16.1 --with-http_stub_status_module --with-http_ssl_module
[root@sentos nginx-1.16.1]# ll
total 752
drwxr-xr-x 6 1001 1001    326 Apr 16 20:04 auto
-rw-r--r-- 1 1001 1001 296463 Aug 13  2019 CHANGES
-rw-r--r-- 1 1001 1001 452171 Aug 13  2019 CHANGES.ru
drwxr-xr-x 2 1001 1001    168 Apr 16 20:04 conf
-rwxr-xr-x 1 1001 1001   2502 Aug 13  2019 configure
drwxr-xr-x 4 1001 1001     72 Apr 16 20:04 contrib
drwxr-xr-x 2 1001 1001     40 Apr 16 20:04 html
-rw-r--r-- 1 1001 1001   1397 Aug 13  2019 LICENSE
-rw-r--r-- 1 root root    428 Apr 16 20:16 Makefile
drwxr-xr-x 2 1001 1001     21 Apr 16 20:04 man
drwxr-xr-x 3 root root    125 Apr 16 20:16 objs
-rw-r--r-- 1 1001 1001     49 Aug 13  2019 README
drwxr-xr-x 9 1001 1001     91 Apr 16 20:04 src
[root@sentos nginx-1.16.1]# make
[root@sentos nginx-1.16.1]# make install
make -f objs/Makefile install
make[1]: Entering directory `/usr/local/nginx/nginx-1.16.1'
test -d '/usr/local/nginx/nginx-1.16.1' || mkdir -p '/usr/local/nginx/nginx-1.16.1'
test -d '/usr/local/nginx/nginx-1.16.1/sbin' \
	|| mkdir -p '/usr/local/nginx/nginx-1.16.1/sbin'
test ! -f '/usr/local/nginx/nginx-1.16.1/sbin/nginx' \
	|| mv '/usr/local/nginx/nginx-1.16.1/sbin/nginx' \
		'/usr/local/nginx/nginx-1.16.1/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/nginx-1.16.1/sbin/nginx'
test -d '/usr/local/nginx/nginx-1.16.1/conf' \
	|| mkdir -p '/usr/local/nginx/nginx-1.16.1/conf'
cp conf/koi-win '/usr/local/nginx/nginx-1.16.1/conf'
cp: ‘conf/koi-win’ and ‘/usr/local/nginx/nginx-1.16.1/conf/koi-win’ are the same file
make[1]: *** [install] Error 1
make[1]: Leaving directory `/usr/local/nginx/nginx-1.16.1'
make: *** [install] Error 2
[root@sentos nginx-1.16.1]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  sbin  src
[root@sentos nginx-1.16.1]# cd sbin/
[root@sentos sbin]# ls
nginx
[root@sentos sbin]# /pwd
-bash: /pwd: No such file or directory
[root@sentos sbin]# pwd
/usr/local/nginx/nginx-1.16.1/sbin
[root@sentos sbin]# vi /etc/rc.local 
[root@sentos sbin]# cat /etc/rc.local 
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local

# redis开机启动配置 
/usr/local/redis/redis-4.0.9/conf/redis-server /usr/local/redis/redis-4.0.9/conf/redis.conf

# nginx开机启动配置
/usr/local/nginx/nginx-1.16.1/sbin/nginx
[root@sentos sbin]# ls
nginx
[root@sentos sbin]# ./nginx 
nginx: [alert] could not open error log file: open() "/usr/local/nginx/nginx-1.16.1/logs/error.log" failed (2: No such file or directory)
2020/04/16 20:29:58 [emerg] 14428#0: open() "/usr/local/nginx/nginx-1.16.1/logs/access.log" failed (2: No such file or directory)
[root@sentos sbin]# cd /usr/local/nginx/nginx-1.16.1/logs
-bash: cd: /usr/local/nginx/nginx-1.16.1/logs: No such file or directory
[root@sentos sbin]# cd /usr/local/nginx/nginx-1.16.1/
[root@sentos nginx-1.16.1]# ls
auto  CHANGES  CHANGES.ru  client_body_temp  conf  configure  contrib  fastcgi_temp  html  LICENSE  Makefile  man  objs  proxy_temp  README  sbin  scgi_temp  src  uwsgi_temp
[root@sentos nginx-1.16.1]# mkdir logs
[root@sentos nginx-1.16.1]# ls
auto  CHANGES  CHANGES.ru  client_body_temp  conf  configure  contrib  fastcgi_temp  html  LICENSE  logs  Makefile  man  objs  proxy_temp  README  sbin  scgi_temp  src  uwsgi_temp
[root@sentos nginx-1.16.1]# cd logs
[root@sentos logs]# touch error.log access.log
[root@sentos logs]# ls
access.log  error.log
[root@sentos logs]# pwd
/usr/local/nginx/nginx-1.16.1/logs
[root@sentos logs]# cd ../sbin/
[root@sentos sbin]# ls
nginx
[root@sentos sbin]# ./nginx 
[root@sentos sbin]# ps -ef|grep nginx 
root      14525      1  0 20:31 ?        00:00:00 nginx: master process ./nginx
nobody    14526  14525  0 20:31 ?        00:00:00 nginx: worker process
root      14535   6805  0 20:31 pts/0    00:00:00 grep --color=auto nginx
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值