Nginx部署
我的环境
环境请看我的其他文章
jdk11(https://blog.csdn.net/qq_51553982/article/details/120649467)
ubuntu20(https://blog.csdn.net/qq_51553982/article/details/120649467)
MobaXterm(https://blog.csdn.net/qq_51553982/article/details/122871497?spm=1001.2014.3001.5501)
linux内核2.6以上
查询linux内核命令
uname -a
我的Linux ubuntu 5.11.0-37-generic #41~20.04.2-Ubuntu SMP Fri Sep 24 09:06:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Nginx下载
http://nginx.org/en/download.html
Nginx安装
下载依赖
sudo apt-get install gcc
sudo apt-get install build-essential
sudo apt-get install libtool
sudo apt-get install zlib1g-dev
sudo apt-get install openssl
sudo apt-get install libpcre3 libpcre3-dev
执行命令(在根目录下)
sudo wget http://nginx.org/download/nginx-1.20.2.tar.gz
mkdir nginx/
mv nginx-1.20.2.tar.gz nginx/
tar -zxvf nginx-1.20.2.tar.gz
./configure
make && make install
最后make && make install
默认安装目录
/usr/local/nginx
启动nginx
注意了,这里需要使用root账户
因为./nginx的执行二进制文件我们没有执行 权限
所以需要root用户
然后chmod赋予权限
不然执行 的时候会报错
nginx: [alert] could not open error log file: open() “/usr/local/nginx/logs/error.log” failed (13: Permission denied)
2022/02/12 04:14:44 [emerg] 5971#0: mkdir() “/usr/local/nginx/client_body_temp” failed (13: Permission denied)
cd /usr/local/nginx/sbin
su root
./nginx
chmod a=rwx ./nginx
启动验证
看到这个页面说明启动成功了