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

What is the command to install Nginx in Linux?

王林
王林forward
2023-05-17 21:58:041295browse

1. Install nginx dependencies

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

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

3. Unzip

tar -zxvf nginx-1.22.0.tar.gz

4. Automatically configure

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

5. During execution of make command

# 1
make
# 2 自动安装
make install

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

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

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;

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete