Nginx安裝和啟動

2021-10-02 13:35:31 字數 4517 閱讀 3286

首先需要安裝乙個叫」epel-release」的軟體包,這個軟體包會自動配置yum的軟體倉庫。當然你也可以不安裝這個包,自己配置軟體倉庫也是一樣的。

yum install epel-release -y
epel源-是什麼?為什麼安裝?

epel (extra packages for enterprise linux)是基於fedora的乙個專案,為「紅帽系」的作業系統提供額外的軟體包,適用於rhel、centos和scientific linux

檢視nginx源

yum list all | grep nginx
安裝

yum  install  nginx -y
顯示軟體安裝資訊

rpm -ql nginx
/etc/logrotate.d/nginx

/etc/nginx/fastcgi.conf

/etc/nginx/fastcgi.conf.default

/etc/nginx/fastcgi_params

/etc/nginx/fastcgi_params.default

/etc/nginx/koi-utf

/etc/nginx/koi-win

/etc/nginx/mime.types

/etc/nginx/mime.types.default

/etc/nginx/nginx.conf //主配置檔案

/etc/nginx/nginx.conf.default

/etc/nginx/scgi_params

/etc/nginx/scgi_params.default

/etc/nginx/uwsgi_params

/etc/nginx/uwsgi_params.default

/etc/nginx/win-utf

/usr/bin/nginx-upgrade

/usr/lib/systemd/system/nginx.service

/usr/lib64/nginx/modules

/usr/sbin/nginx //主執行程式檔案

/usr/share/doc/nginx-1.16.1

/usr/share/doc/nginx-1.16.1/changes

/usr/share/doc/nginx-1.16.1/readme

/usr/share/doc/nginx-1.16.1/readme.dynamic

/usr/share/doc/nginx-1.16.1/upgrade-notes-1.6-to-1.10

/usr/share/licenses/nginx-1.16.1

/usr/share/licenses/nginx-1.16.1/license

/usr/share/man/man3/nginx.3pm.gz

/usr/share/man/man8/nginx-upgrade.8.gz

/usr/share/man/man8/nginx.8.gz

/usr/share/nginx/html/404.html

/usr/share/nginx/html/50x.html

/usr/share/nginx/html/en-us

/usr/share/nginx/html/icons

/usr/share/nginx/html/icons/poweredby.png

/usr/share/nginx/html/img

/usr/share/nginx/html/index.html

/usr/share/nginx/html/nginx-logo.png

/usr/share/nginx/html/poweredby.png

/usr/share/vim/vimfiles/ftdetect/nginx.vim

/usr/share/vim/vimfiles/ftplugin/nginx.vim

/usr/share/vim/vimfiles/indent/nginx.vim

/usr/share/vim/vimfiles/syntax/nginx.vim

/var/lib/nginx

/var/lib/nginx/tmp

/var/log/nginx

通過 /usr/sbin/nginx -h 檢視執行命令

[root@izwz9cc9df2x1kjs5kptkmz admin]#  /usr/sbin/nginx  -h

nginx version: nginx/1.16.1

usage: nginx [-?hvvttq] [-s signal] [-c filename] [-p prefix] [-g directives]

options:

-?,-h : this help

-v : show version and exit

-v : show version and configure options then exit

-t : test configuration and exit

-t : test configuration, dump it and exit

-q : suppress non-error messages during configuration testing

-s signal : send signal to a master process: stop, quit, reopen, reload

-p prefix : set prefix path (default: /usr/share/nginx/)

-c filename : set configuration file (default: /etc/nginx/nginx.conf) //啟動時,指定配置檔案

-g directives : set global directives out of configuration file

啟動命令:

/usr/sbin/nginx
啟動失敗

[root@izwz9cc9df2x1kjs5kptkmz admin]# /usr/sbin/nginx

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: address already in use)

nginx: [emerg] still could not bind()

檢視埠占用情況

[root@izwz9cc9df2x1kjs5kptkmz admin]# netstat -tnlp | grep 80

tcp 0 0 0.0.0.0:80 0.0.0.0:* listen 2836/httpd

結束程序

kill -9    2836
再次啟動

/usr/sbin/nginx
檢視啟動情況

[root@izwz9cc9df2x1kjs5kptkmz admin]# ps -ef | grep nginx

root 4395 1 0 20:32 ? 00:00:00 nginx: master process /usr/sbin/nginx //主

nginx 4396 4395 0 20:32 ? 00:00:00 nginx: worker process //子程序

root 4425 3453 0 20:33 pts/0 00:00:00 grep --color=auto nginx

通過配置檔案啟動

/usr/sbin/nginx -c /etc/nginx/nginx.conf

Nginx的安裝和啟動

1.c語言的環境 yum y install gcc c 2.安裝 pcre 環境pcre 的壓縮包 wget 2.解壓壓縮包 tar zxvf pcre 8.37.tar.gz 如指定則 tar zxvf pcre 8.37.tar.gz c usr local 3.跳轉到 pcre 的目錄下 找...

nginx安裝啟動

yum y install gcc gcc c autoconf automake yum y install zlib zlib devel openssl openssl devel pcre pcre devel wget nginx在linux環境下可以通過編譯原始碼的方式來安裝,最簡單的安...

nginX 安裝 啟動

解壓 tar zxvf nginx 1.8.0.tar.gz 進入資料夾 root localhost local cd nginx 1.8.0 1.開始安裝 root localhost nginx 1.8.0 configure 檢查環境,生成makefile檔案 報錯,缺少一些庫函式,直接yu...