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

CentOS7 install Nginx and configure the method and steps for automatic startup

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

1. Download the installation package from the official website

http://nginx.org/en/download.html, Select the version suitable for Linux, Here select the latest version, Download to the local upload to the server or direct wget command download under centos.

Switch to/usr/local directory to download packages

# cd /usr/local# wget http://nginx.org/download/nginx-1.11.5.tar.gz

2, Install nginx

First execute the following command to install the nginx dependency library. If the dependency library is missing, the installation may fail. For details, please refer to the error message at the end of the article.

# yum install gcc-c++# yum install pcre# yum install pcre-devel# yum install zlib # yum install zlib-devel# yum install openssl# yum install openssl-devel

Extract the installation package

# tar -zxvf nginx-1.11.5.tar.gz

nginx is unzipped to/usr/local/nginx-1.11.5 (do not unzip the package to/usr/local/nginx, or rename the unzipped directory to nginx, because nginx will be installed to/usr/local/nginx by default), switch to nginx-1.11.5/directory

# cd /usr/local/nginx-1.11.5/

Implementation # ./ configure

# ./ configure

This operation checks the current system environment to ensure that nginx can be successfully installed. After performing this operation, the following prompts may appear:

checking for OS

+ Linux 3.10.0-123.el7.x86_64 x86_64

checking for C compiler ... not found

./ configure: error: C compiler cc is not found

If the above error message appears, execute yum install gcc-c++ to install gcc

./ configure: error: the HTTP rewrite module requires the PCRE library.

You can either disable the module by using --without-http_rewrite_module

option, or install the PCRE library into the system, or build the PCRE library

statically from the source with nginx by using --with-pcre= option.

if that above prompt appear, the PCRE library is missing

./ configure: error: the HTTP gzip module requires the zlib library.

You can either disable the module by using --without-http_gzip_module

option, or install the zlib library into the system, or build the zlib library

statically from the source with nginx by using --with-zlib= option.

If the above prompt appears, it means that the zlib library is missing

If it doesn't appear./ configure: error prompt, indicating that nginx can be installed in the current environment, execute make and make install to compile nginx

# make# make install

If there is no error, it means that nginx has been successfully installed. The default installation location is/usr/local/nginx. The previous/usr/local/nginx-1.11.5/can be deleted.

If cp: 'conf/koi-win' and '/usr/local/nginx/conf/koi-win' are the same file, you may have extracted the installation package to the/usr/local/nginx directory, the solution is to rename the directory to something else and then execute make,make install.

3. Configure nginx to boot

Change to/lib/systemd/system/directory and create nginx.service file vim nginx.service

# cd /lib/systemd/system/# vim nginx.service

The document reads as follows:

[Unit]Description=nginx After=network.target [Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginxExecReload=/usr/local/nginx/sbin/nginx reloadExecStop=/usr/local/nginx/sbin/nginx quitPrivateTmp=true [Install] WantedBy=multi-user.target

Exit and save the file, execute systemctl enable nginx.service enable nginx boot

# systemctl enable nginx.service

systemctl start nginx.service Start nginx

systemctl stop nginx.service Ends nginx

systemctl restart nginx.service Restart nginx

4, verify whether the installation is successful

Enter http://Server IP/If you can see the interface of nginx, it means that the installation is successful.

The above is all the content of this article, I hope to help everyone's study, but also hope that everyone a lot of support.

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