nginx相关内容的安装

nginx的安装

安装依赖

yum install gcc gcc-c++ automake autoconf libtool make gd gd-devel libxslt-devel -y

安装lua与lua依赖

lua安装步骤如下:

复制代码
mkdir /www
mkdir /www/server #选择你自己的目录即可,不需要跟我一致
cd /www/server
tar -zxvf lua-5.4.3.tar.gz
cd lua-5.4.3
make linux test
make install

luajit安装步骤如下:

复制代码
cd /home
tar -zxvf luajit2-2.1-20211210.tar.gz
cd luajit2-2.1-20211210
make install PREFIX=/www/server/luaJIT

lua依赖包安装:

复制代码
cd /home
tar -zxvf lua-resty-core-0.1.23rc1.tar.gz
cd lua-resty-core-0.1.23rc1
make install PREFIX=/www/server/luaJIT
​
    cd /home
tar -zxvf lua-resty-lrucache-0.11.tar.gz
cd lua-resty-lrucache-0.11
make install PREFIX=/www/server/luaJIT

配置luajit的环境变量:

复制代码
vim /etc/profile
​
export LUAJIT_LIB=/www/server/luaJIT/lib
export LUAJIT_INC=/www/server/luaJIT/include/luajit-2.1
​
退出vim编辑后,刷新文件
source /etc/profile
​
安装nginx:
1. 解压与配置
复制代码
cd /home
tar -zxvf nginx-1.20.2.tar.gz
cd nginx-1.20.2
​
./configure --user=www --group=www --prefix=/www/server/nginx --add-module=srclib/ngx_devel_kit --add-module=srclib/lua-nginx-module --add-module=srclib/ngx_cache_purge --add-module=srclib/nginx-sticky-module --with-openssl=srclib/openssl --with-pcre=srclib/pcre --with-zlib=srclib/zlib --with-http_v2_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_stub_status_module --with-http_ssl_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --with-ld-opt=-Wl,-E --with-cc-opt=-Wno-error --with-http_dav_module --add-module=srclib/nginx-dav-ext-module --add-module=srclib/nginx-upsync-module --add-module=srclib/echo-nginx-module
​
2. 编译安装并配置nginx.conf
复制代码
make -j2 && make install
​
cd /www/server/nginx
避免之后的./nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory问题
​
配置如下:
echo "/www/server/luaJIT/lib" >> /etc/ld.so.conf
​
然后在刷新下配置文件
运行命令: ldconfig
​
​
vim /www/server/nginx/conf/nginx.conf
​
加入如下配置:
​
user www;
​
http
{
  ...
  lua_package_path "/www/server/luaJIT/lib/lua/?.lua";
}
3. 创建用户组与启动nginx

因为在配置时我们要求使用www用户启动与操作nginx,所以需要创建这个www

复制代码
1. 创建用户组与用户
groupadd www
useradd -r -g www www
2. 启动nginx
cd /www/server/nginx
sbin/nginx -c conf/nginx.conf
相关推荐
潘yi.6 小时前
web技术与nginx网站环境部署
服务器·网络·nginx
Jtti7 小时前
Jtti:nginx服务器如何限制访问频率
服务器·网络·nginx
穿条秋裤到处跑17 小时前
前端连接websocket服务报错 Unexpected response code: 301
websocket·网络协议·nginx
YJQ996719 小时前
Nginx防盗链及HTTPS:保护网站内容安全与加密传输
nginx·安全·https
猿java1 天前
什么是Nginx?它有哪些应用场景?
java·nginx·面试
绝顶少年1 天前
反向代理、负载均衡与镜像流量:原理剖析、区别对比及 Nginx 配置实践
运维·nginx·负载均衡
天下·第二1 天前
【Nginx】负载均衡配置详解
运维·nginx·负载均衡
Hello.Reader2 天前
洞悉 NGINX ngx_http_access_module基于 IP 的访问控制实战指南
tcp/ip·nginx·http
PWRJOY2 天前
在 Ubuntu 24.04 系统上安装和管理 Nginx
linux·nginx·ubuntu
菠萝崽.2 天前
安装docker,在docker上安装mysql,docker上安装nginx
java·mysql·nginx·docker·软件工程·springboot·开发