Home > Operation and Maintenance > Nginx > What is the command to install Nginx in Linux?

What is the command to install Nginx in Linux?

王林
Release: 2023-05-17 21:58:04
forward
1352 people have browsed it

1. Install nginx dependencies

yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
Copy after login

2. wget download nginx

Download nginx in the newly created nginx folder, the version can be selected on the Nginx official website
I chose the current time Click on the latest and most stable version on the official website

wget http://nginx.org/download/nginx-1.22.0.tar.gz
Copy after login

3. Unzip

tar -zxvf nginx-1.22.0.tar.gz
Copy after login

4. Automatically configure

# 进入解压的nginx目录
cd nginx-1.22.0 
# 自动配置
./configure
Copy after login

5. During execution of make command

# 1
make
# 2 自动安装
make install
Copy after login

If an error is reported such as

What is the command to install Nginx in Linux?

, it is likely that the nginx installation package you downloaded is broken and may not be suitable for your Linux version, etc. Please change it to a newer one or For older packages, see which one matches your OS

6. Configure environment variables

# 查看安装的nginx位置(不是安装包的位置,算是app的位置)
whereis nginx
# 编辑profile文件
vim /etc/profile
# 在profile中追加指向nginx的sbin目录
export PATH=$PATH:/usr/local/nginx/sbin
# 重新加载使其生效
source /etc/profile
# 任意目录执行查看版本号,看是否配置成功
nginx -v
Copy after login

7. Check the nginx error log

If the page reports an error

What is the command to install Nginx in Linux?

The best way at this time is to check the error log, otherwise you will not be able to guess where the problem is.
Check the nginx error log location:

vim nginx.conf
# 找这个
#error_log  logs/error.log;
# vim查看log
vim logs/error.log
Copy after login

If permission deny is reported in the log, it means that nginx does not have permission to access static files. You can add configurations in nginx.conf such as:

user root root;
Copy after login

The above is the detailed content of What is the command to install Nginx in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template