编译安装nginx搭建小游戏网站
编译安装流程
下载nginx代码
wget -P /server/tools/ http:Վˌnginx.org/download/nginx1.22.0.tar.gz
解压并进入目录
cd /server/tools/ tar xf nginx-1.22.0.tar.gz cd nginx-1.22.0/
配置
./configure prefix=/app/nginx-1.22.0/ user=nginx group=nginx with-http_ssl_module with-http_v2_module with-http_stub_status_module # prefix指定安装目录 user 用户 group 用户组
成功提示:
错误提示:
./configure: error: the HTTP rewrite module requires the pcre library. You can either disable the module by using Վʔwithouthttp_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using Վʔwith- pcre=
./configure: error: SSL modules require the OpenSSL library. You can either do not enable the modules, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using Վʔwith-openssl=
编译make成功提示:
安装:
make install
后续配置
检查目录
ll /app/nginx-1.22.0/ 总用量 0 drwxr-xr-x 2 root root 333 7月 drwxr-xr-x 2 root root 40 7月 drwxr-xr-x 2 root root 6 7月 drwxr-xr-x 2 root root 19 7月
创建用户
useradd -s /sbin/nologin -M nginx
创建软链接
ln -s /app/nginx-1.22.0/ /app/nginx 并检查
管理编译安装的nginx
温馨提示:关闭防火墙和selinux
#1. 查看nginx版本信息及编译信息 /app/nginx/sbin/nginx -V nginx version: nginx/1.22.0 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: Վʔprefix=/app/nginx-1.22.0/ Վʔ user=nginx Վʔgroup=nginx Վʔwith-http_ssl_module Վʔwithhttp_v2_module Վʔwith-http_stub_status_module #2.启动nginx /app/nginx/sbin/nginx ps aux |grep nginx #3. 关闭 pkill nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx已经运行了并占用80端口
检查端口nginx ss -lntup |grep nginx
访问网站
启动nginx并检查:浏览器中输入服务器ip地址即可