Linux下安装nginx

1.直接下载稳定安装包,官网:https://nginx.org/en/download.html

 

 

 

 

直接运行下载命令:

wget -c http://nginx.org/download/nginx-1.18.0.tar.gz

注:确保系统已经安装了wget,如果没有安装,执行 yum install wget 安装。

2、解压

tar -zxvf nginx-1.18.0.tar.gz

3、访问该文件夹

cd nginx-1.18.0

4、配置

./configure

5、编译安装

make
make install

6、寻找安装路径

whereis nginx

7、nginx操作命令

进入安装目录:cd /usr/local/nginx/sbin/
开启:./nginx 
停止:./nginx -s stop
退出:./nginx -s quit
重启:./nginx -s reload
验证配置文件是否正确:./nginx -t

注:cd /usr/local/nginx/sbin/为nginx的安装路径,必须在sbin文件夹下执行相关命令

常见错误:
a../configure: error: C compiler cc is not found 解决方案
yum -y install gcc gcc-c++ kernel-devel

若已安装还是报错:

whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc
cd /usr/bin/
ls -alh gcc
gcc -> gcc-4.9
sudo ln -s gcc-4.9 cc

 


b.没有规则可以创建“default”需要的目标“build” 解决方案
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel

注:安装后再执行配置命令【./configure

 

./configure: error: C compiler cc is not found 解决方案

posted @ 2021-01-28 16:52  疯狂阿坤  阅读(81)  评论(0编辑  收藏  举报