centos7源码编译安装LNMP+ZABBIX4.0LTS(1)——nginx
2024-09-04 21:20:28
- 环境:
192.168.117.132——zabbix server
192.168.117.133——zabbix proxy - 安装路径为/zabbix
- 安装nginx
1.安装包下载
http://nginx.org/en/download.html
此次使用稳定版1.18.0
2.安装依赖
yum install -y gcc gcc-c++ automake zlib zlib-devel openssl-devel pcre pcre-devel
3.添加用户
useradd -m nginx
4.创建目录
mkdir -p /zabbix/nginx
5.编译安装
tar -xf nginx-1.18.0.tar.gz
cd nginx-1.18.0 ./configure --prefix=/zabbix/nginx --user=nginx --group=nginx --with-stream --with-stream_ssl_module --with-threads --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module make -j4 && make install
6.修改配置
创建2个目录 #nginx包含的配置文件目录
mkdir /zabbix/nginx/conf/conf.d #创建zabbix前端代码目录
mkdir /zabbix/nginx/html/zabbix
#创建nginx主配置文件
cat > /zabbix/nginx/conf/nginx.conf << EOF
user nginx;
worker_processes auto; events {
use epoll;
worker_connections 65535;
multi_accept on;
} http {
include mime.types;
default_type application/octet-stream;
#charset utf-8;
server_names_hash_bucket_size 128;
large_client_header_buffers 4 64k;
client_header_buffer_size 32k;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'$upstream_addr $upstream_response_time $request_time';
sendfile on;
tcp_nopush on;
client_max_body_size 1024m;
tcp_nodelay on;
keepalive_timeout 100;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 8k;
gzip_http_version 1.1;
gzip_types text/* text/css application/javascript application/x-javascript;
server_tokens off;
include /zabbix/nginx/conf/conf.d/*.conf;
}
EOF
#创建zabbix页面的nginx配置文件 cat > /zabbix/nginx/conf/conf.d/zabbix.web.conf << EOF
server {
listen 80;
server_name localhost;
access_log /zabbix/nginx/logs/zabbix_access.log main;
error_log /zabbix/nginx/logs/zabbix_error.log error;
location / {
root /zabbix/nginx/html/zabbix;
index index.php index.html index.htm ;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /zabbix/nginx/html/zabbix$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
}
EOF
#添加systemctl
cat > /usr/lib/systemd/system/nginx.service << EOF
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target [Service]
Type=forking
PIDFile=/zabbix/nginx/logs/nginx.pid
ExecStartPre=/usr/bin/rm -f /zabbix/nginx/logs/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true [Install]
WantedBy=multi-user.target
EOF #拷贝二进制程序
cp /zabbix/nginx/sbin/nginx /usr/sbin/nginx
7.启动
systemctl start nginx #添加开机启动
systemctl enable nginx
8.访问
#创建一个页面
cat > /zabbix/nginx/html/zabbix/index.html << EOF
this is a test
EOF
#浏览器输入ip地址访问下是否成功
至此nginx安装完成
server { listen 80; server_name localhost;
location / { root html; index index.html index.htm; }
error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }
}
最新文章
- Go语言实战 - revel框架教程之CSRF(跨站请求伪造)保护
- Burp Suite 常用功能 0x01 扫描后台
- 修复FreeBSD上的ufs文件系统
- sublime3 常用插件
- Validform —— 再也不用担心“表单验证”!
- 消息队列MQ - Apache ActiveMQ
- ajax 代码
- mysql保存中文乱码的原因和解决办法
- 【翻译习作】 Windows Workflow Foundation程序开发-第一章04
- Microsoft StreamInsight install
- wsdlLocation可以写成项目的相对路劲吗
- Ubuntu小私房(4)--Linux系统目录结构
- Git——git 上传时 遗漏文件解决办法
- hdu3790最短路径问题
- Vector 特性
- 熟悉HBase基本操作
- CSS BFC(格式化上下文)深入理解
- Cartographer源码阅读(9):图优化的前端——闭环检测
- 自动化测试 selenium 环境搭建
- SpringMVC入门学习(一)
热门文章
- 高可用集群之keepalived+lvs实战2
- 12.扩展:向量空间模型算法(Vector Space Model)
- Module build failed: TypeError: this.getResolve is not a function at Object.loader 使用vue-cli 创建项目 使用sass时报错 -- 等其他sass 报错 ./node_modules/css-loader?{";sourceMap";:true}!./node_modules/vue-loader/lib
- Java Set 常用集合 HashSet、LinkedHashSet、TreeSet
- 刷题[MRCTF2020]套娃
- vue学习02-v-text
- 802.1X 账号密码+设备信息双重认证
- 小程序开发-iView app的NoticeBar 通告栏修改背景颜色
- zookeeper 笔记--curator分布式锁
- 【记】《.net之美》之读书笔记(二) C#中的泛型