yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
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
tar -zxvf nginx-1.22.0.tar.gz
# 进入解压的nginx目录 cd nginx-1.22.0 # 自动配置 ./configure
# 1 make # 2 自动安装 make install
If an error is reported such as
, 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
# 查看安装的nginx位置(不是安装包的位置,算是app的位置) whereis nginx # 编辑profile文件 vim /etc/profile # 在profile中追加指向nginx的sbin目录 export PATH=$PATH:/usr/local/nginx/sbin # 重新加载使其生效 source /etc/profile # 任意目录执行查看版本号,看是否配置成功 nginx -v
If the page reports an error
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!