Nginx basis: 1: Installation and Deployment

Here Insert Picture Description
Nginx way of using containers is very convenient, but this approach needs the support of Docker operating environment, the installation and set Nginx way is still very convenient in some cases directly on a physical machine. This article related to the conduct some basic introduction.

Installation Commands

CentOS / RHEL installation command: yum install nginx

Note: This installation package is currently under epel-release, you need to first install epel-release.

Ubuntu installation command: apt install nginx

installation

Confirm beforehand environment

[root@liumiaocn ~]# uname -a
Linux liumiaocn 5.4.2-1.el7.elrepo.x86_64 #1 SMP Wed Dec 4 17:32:23 EST 2019 x86_64 x86_64 x86_64 GNU/Linux
[root@liumiaocn ~]# cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)
[root@liumiaocn ~]# 

installation

Run the following command to complete the installation

Step 1: yum install epel-release -y

Step 2: yum install nginx -y

Version Confirmation

[root@liumiaocn ~]# nginx -v
nginx version: nginx/1.16.1
[root@liumiaocn ~]#

Start nginx Service

Start command: systemctl start nginx

Here Insert Picture Description

Confirm the configuration information

Use nginx -V to confirm detailed configuration information, such as configuration information as shown in the following exemplified herein

[root@liumiaocn ~]# nginx -V
nginx version: nginx/1.16.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-stream_ssl_preread_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'
[root@liumiaocn ~]#

From the foregoing it can be seen some of the configuration settings, and this module nginx

  • Binaries: / usr / sbin / nginx
  • Installation directory: / usr / share / nginx
  • Profile directory: / etc / nginx
  • Profile: /etc/nginx/nginx.conf
  • Access log information: /var/log/nginx/access.log
  • Error Log Information: /var/log/nginx/error.log
  • Save the module directory: / usr / lib64 / nginx / modules

The results confirmed

After the default start the service will start on port 80, so the direct use of http: // IP or domain name is the way you can directly access, you can see the following after the visit:
Here Insert Picture Description
The reason is because index.html in this epel-release has been It has been modified

[root@liumiaocn ~]# cd /usr/share/nginx/html/
[root@liumiaocn html]# grep 'CentOS' index.html
  <title>Welcome to CentOS</title>
	<h1>Welcome to CentOS</h1>
	<p><a href="http://www.centos.org/">CentOS</a> is an Enterprise-class Linux Distribution derived from sources freely provided
to the public by Red Hat, Inc. for Red Hat Enterprise Linux.  CentOS conforms fully with the upstream vendors
redistribution policy and aims to be functionally compatible. (CentOS mainly changes packages to remove upstream vendor
	<p>CentOS is developed by a small but growing team of core
	<p>CentOS has numerous advantages including: an active and growing user community, quickly rebuilt, tested, and QA'ed errata packages, an extensive <a href="http://www.centos.org/download/mirrors/">mirror network</a>, developers who are contactable and responsive, Special Interest Groups (<a href="http://wiki.centos.org/SpecialInterestGroup/">SIGs</a>) to add functionality to the core CentOS distribution, and multiple community support avenues including a <a href="http://wiki.centos.org/">wiki</a>, <a
[root@liumiaocn html]# 

This page appears normal, you can explain in CentOS under nginx installation and start-up has been normal.

Released 1021 original articles · won praise 1288 · Views 3.98 million +

Guess you like

Origin blog.csdn.net/liumiaocn/article/details/104104445