Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation method of Nginx in CentOS

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

My machine is CentOS, so this article is based on CentOS installation. Nginx can be installed in two ways under CentOS, yum installation and source installation.

1. Yum installation

Yum installation is very simple, first of all, we also need to add the repository source of the EPEL package. Use the following command

Yum-y install epel-release

Then execute the install Nginx command.

Yum-y install nginx

II. Source code installation

For source code installation, you need to download the source code and the corresponding dependent package from the official website, and then compile and install it.

The packages that Nginx depends on are:

Openssl-devel

Zlib-devel

Pcre-devel

Gcc

In general, we only need to install zlib-devel and pcre-devel, gcc a lot of centos has been installed.

1. Install the PCRE library

# download, compile and install the latest PCRE source code package using the following command: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ cd / opt/softwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz tar-zxvf pcre-8.40.tar.gzcd pcre-8.40./configuremakemake install

two。 Install the zlib library

Cd / opt/softwget http://zlib.net/zlib-1.2.10.tar.gztar-zxvf zlib-1.2.10.tar.gzcd zlib-1.2.10./configuremakemake install

3. Install Nginx

Cd / opt/softwget http://nginx.org/download/nginx-1.4.2.tar.gztar-zxvf nginx-1.4.2.tar.gzcd nginx-1.4.2./configure makemake install

If you directly execute. / configure, nginx is installed to the default path (default path installation run / usr/local/nginx). The custom installation steps are as follows: install to the / soft/nginx directory

. / configure

-- sbin-path=/opt/soft/nginx/sbin

-- conf-path=/soft/nginx/nginx.conf

-- pid-path=/soft/nginx/nginx.pid

-- with-http_ssl_module

-- with-pcre=/opt/soft/pcre-8.40

-- with-zlib=/opt/soft/zlib-1.2.10

Note that it is consistent with the version number and directory of the installation, and the path of the dependent package.

III. Startup, restart and shutdown of Nginx

1. Firewall Settin

Through the above command operation, Nginx has been installed, we first need to open the firewall, open Nginx open port 80.

/ sbin/iptables-I INPUT-p tcp-- dport 80-j ACCEPT / etc/rc.d/init.d/iptables save / etc/init.d/iptables restart

two。 Start

Start Nginx and run the Nginx execution file directly

/ usr/local/nginx/sbin/nginx

3. Restart

/ usr/local/nginx/sbin/nginx-s restart

4. Close

/ usr/local/nginx/sbin/nginx-s stop

5. test

Later, we will configure the configuration file of Nginx. After modifying the configuration file, we can mirror the configuration file to determine whether the modified configuration is correct.

/ usr/local/nginx/sbin/nginx-t

After the above steps, start Nginx and visit port 80 of the server to see the welcome page of Nginx.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report