Linux Ubuntu安装Nginx 1.22.1
准备工作
1、一台崭新的云服务器(你也可以在虚拟机上搞),Ubuntu系统,我的是这样的
2、下载Nginx 1.22.1,地址:http://nginx.org/en/download.html
3、安装一些会用到的包
sudo apt-get install openssl libssl-dev zlib1g-dev libpcre3 libpcre3-dev
ok,开始安装Nginx
1、把下载好的Nginx压缩文件上传到 /tmp 文件夹
2、解压缩
tar -zxvf nginx-1.22.1.tar.gz
3、进入到解压后的文件夹内
cd nginx-1.22.1/
4、搞一搞配置,就是选安装位置啊,需要添加什么模块啊,日志地址啊
如果都按照默认值来,直接执行下面这个就行了
./configure
安装路径啥的呢,我就用默认的,如果要添加模块的话,就像这样
./configure
--with-pcre \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_image_filter_module \
--with-http_slice_module \
--with-threads \
--with-file-aio \
--with-stream \
--with-stream_ssl_module
执行完之后是这样滴,他会告诉你安装目录在哪啊,二进制文件在哪啊,模块在哪个文件夹下啊,pid啊,日志啊等等
这时候你在看文件夹,多出了一个Makfile文件
5、编译并安装
make && make install
6、等一会,等他执行完之后,没有报错,显示这行就ok了
7、然后可以用命令查看一下状态,在这里有命令 https://www.cnblogs.com/freejx/p/16962716.html
8、用浏览器打开公网ip看看
不对劲......
9、是不是咱刚才没启动,先启动看看
/usr/local/nginx/sbin/nginx
完了之后,端口占用
嗯......,如图,都给他kill掉
kill -9 [pid]
完了之后再启动一下
焯,摔纸巾......
咱按照上面那个目录新建一下这个pid文件,然后在里面加一串数字,我加的是6222,随便点[生气],加完保存退出来
完了吧,在启动一下
嘿嘿......搞定啦
配置文件嘛,下一篇再讲吧
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构