节外生枝,安装Nginx
竟然要搞Nginx
我用centos7,
一. gcc 安装
安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:
yum install gcc-c++
二. PCRE pcre-devel 安装
PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。命令:
yum install -y pcre pcre-devel
三. zlib 安装
zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。
yum install -y zlib zlib-devel
四. OpenSSL 安装
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。
nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。
yum install -y openssl openssl-devel
五. 下载Nginx
yum install wget
wget -c https://nginx.org/download/nginx-1.12.0.tar.gz
六. 解压Nginx
tar -zxvf nginx-1.12.0.tar.gz -C /opt/lagou/servers/
七. 配置
使用默认配置
./configure
mkdir -p /var/temp/nginx
八. 编译
make
make install
# 查找安装路径
whereis nginx
九. 启动/停止Nginx
# 修改
vi /usr/local/nginx/conf/nginx.conf
释放第9行
pid /usr/local/nginx/logs/nginx.pid;
# 第一次要执行这个
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
cd /usr/local/nginx/sbin/ ./nginx ./nginx -s stop ./nginx -s quit ./nginx -s reload
十. 完成Nginx安装
十一. 部署HTML到Nginx
mkdir -p /opt/lagou/file_dic/nginx-web-demo
vi index.html
<html> <head> <title>Nginx-demo</title> </head> <body style="padding: 20px;"> <br/> <p>Nginx 静态 Html hello world ......</p> </body> </html>
十一. 配置Nginx
vi /usr/local/nginx/conf/nginx.conf
http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; charset utf-8; # 设置编码格式 #gzip on; server { listen 8081; # 端口号 server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root /opt/lagou/file_dic/nginx-web-demo/; # 静态页面根目录 index index.html index.htm; }
}
}
十二. 启动Nginx
cd /usr/local/nginx/sbin/
./nginx
浏览器访问 http://centos7-1:8081/
大功告成
节外生枝中的节外生枝
cd /opt/lagou/servers/kafka_2.12-1.0.2/config # 启动kafka kafka-server-start.sh ../config/server.properties
cd /usr/local/nginx/sbin/
./nginx
cd /usr/local/nginx/html kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic tp_individual --from-beginning curl localhost/user/actio -d "message send to kafka topic2"