centos7源碼編譯安裝LNMP+ZABBIX4.0LTS(1)——nginx

  • 環境:
    192.168.117.132——zabbix server
    192.168.117.133——zabbix proxy
  • 安裝路徑爲/zabbix
  • 安裝nginx

1.安裝包下載
http://nginx.org/en/download.html
這次使用穩定版1.18.0
javascript

 

2.安裝依賴php

yum install -y gcc gcc-c++ automake zlib zlib-devel openssl-devel pcre pcre-devel

 

3.添加用戶css

useradd -m nginx

 

4.建立目錄html

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.修改配置java

建立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.啓動node

systemctl start nginx

#添加開機啓動
systemctl enable nginx

 

8.訪問nginx

#建立一個頁面
cat > /zabbix/nginx/html/zabbix/index.html << EOF
this is a test
EOF
#瀏覽器輸入ip地址訪問下是否成功

 

 

 

 

至此nginx安裝完成c++

相關文章
相關標籤/搜索