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

Centos8 how to customize the directory to install nginx

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "centos8 how to customize the directory to install nginx". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and go deep into it together to study and learn "centos8 how to customize the directory to install nginx"!

1. Installation tools and libraries

# pcre is a perl library that includes perl-compatible regular expression libraries. The http module of nginx uses pcre to parse regular expressions

# zlib library provides many ways to compress and decompress, nginx uses zlib to gzip the contents of http packages

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

2. directory structure

Source directory: /home/werben/pkgsrc/nginx

Installation directory: /home/werben/application/nginx

3. Download and extract source code

#Official website address:

wget -c

4. Create user groups and users

groupadd wwwuseradd -g www www

5. compile source code

./ configure --user=www --group=www --prefix=/home/werben/application/nginx --with-http_v2_module --with-http_ssl_module --with-http_sub_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --with-pcremake && make install

6. Map global commands

ln -s /home/werben/application/nginx/sbin/nginx /usr/local/bin/nginx

7. Start, stop, restart

nginx -s stopnginx -s quitngins -s reload

8. Check the correctness of the configuration file nginx.conf

nginx -t

9. start automatically when the system

vim /lib/systemd/system/nginx.service[unit]description=nginxafter=network.target[service]type=forkingexecstart=nginxexecreload=nginx reloadexecstop=nginx quitprivatetmp=true[install]wantedby=multi-user.target#Reload daemon systemctl daemon-reload#Start nginx service systemctl start nginx.service#Stop nginx service systemctl stop nginx.service#Set boot-up to enable systemctl enable nginx.service#Stop boot-up to disable nginx.service#View current status of services systemctl status nginx.service#Restart services systemctl restart nginx.service#View all started services systemctl list-units --type=service

10. Problems and solutions

#If `systemctl start nginx.service` prompts job for nginx.service failed because the control process exited with error code.see "systemctl status nginx.service" and "journalctl -xe" for details.# Execute systemctl status nginx.service#If the error process: 35783 execstart=... nginx/sbin/nginx(code=exitedstatus=203/exec) nginx.service: control process exited, code=exited status=203 systemd[1]: nginx.service: failed with result 'exit-code'. localhost.localdomain systemd[1]: failed to start nginx.journalctl -xe#If you see the following message if you believe that systemd should be allowed execute access on the> then you should report this as a bug. you can generate a local policy module to allow this access. do allow this access for now by executing: # ausearch -c '(nginx)' --raw |audit2allow -m my-nginx # semodule -x 300 -i my-nginx.pp#resolution setenforce 0vim /etc/selinux/configselinux=disabled

ps: Structure description of nginx configuration file

All nginx configuration files are located in the/etc/nginx/directory.

The main configuration file for nginx is/etc/nginx/nginx.conf.

Creating a separate profile for each domain makes the server easy to maintain.

The nginx server blocking file must end with.conf and be stored in the/etc/nginx/conf.d directory. You can have as many server blocks as you want.

It is a good practice to follow standard naming conventions. For example, if the domain name is mydomain.com then the configuration file should be named mydomain.com.conf

If repeatable configuration segments are used in domain server blocks, it is best to reconstruct these segments into fragments.

The nginx log files (access.log and error.log) are located in the/var/log/nginx/directory. It is recommended to have different access and error log files for each server module.

You can set the root directory of the domain document to any location you want. The most common locations for webroot include:

/home//var/www//var/www/html/opt//usr/share/nginx/html Thank you for reading, the above is the content of "centos8 how to customize the directory to install nginx", after learning this article, I believe that everyone has a deeper understanding of how to customize the directory to install nginx in centos8, and the specific use needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

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

Internet Technology

Wechat

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

12
Report