搭建 Ubuntu环境
1.更换为管理员用户root(很重要)
sudo su
2.安装依赖(不在管理员模式下要加sudo)
apt-get update
apt-get install build-essential
apt-get install libtool
apt-get install libpcre3 libpcre3-dev
apt-get install zlib1g-dev
apt-get install libssl-dev
3.下载nginx安装包,可以在官网下载在通过远程连接工具拖入虚拟机,也可以利用wget拉载(这边使用wget)
wget http://nginx.org/download/nginx-1.21.6.tar.gz
4.解压下载的压缩包
tar -xvf nginx-1.21.6.tar.gz
5.进入nginx包目录下
cd nginx-1.21.6
6.创建nginx用户(执行编译命令前先创建Nginx用户不然后面Nginx运行时会报错)
useradd nginx
7.执行命令编译安装
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_gzip_static_module --with-http_flv_module --with-http_ssl_module --with-http_realip_module --with-http_v2_module --with-http_sub_module --with-http_mp4_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module
make
make install
8.执行以上命令之后,nginx安装成功目录为/usr/local/nginx,进入该目录
9.配置nginx软连接
ln -s /usr/local/nginx/sbin/nginx /usr/bin/
10.软连接配置完成即以成功开启nginx服务即可,在浏览器上访问对应ip即可
