nginx部署及问题
部署:
安装步骤 (准备相关文件:jemalloc-3.6, pcre-8.37)
yum -y install gcc
yum -y install gcc-c++
yum install make
yum install openssl
yum install openssl-devel
tar xzvf pcre-8.37.tar.gz
cd pcre-8.37
./configure --prefix=/usr/local/pcre-8.37
make
make install
若: checking whether the C compiler works... no
1. yum install gdb
2. yum reinstall gcc
3. yum reinstall glibc
cd /usr/local
tar -xf jemalloc-3.6.0.tar.bz2 -C /usr/local/
tar xzvf tengine-2.1.2.tar.gz
cd /usr/local/tengine-2.1.2
./configure --prefix=/usr/local/tengine \--sbin-path=/usr/local/tengine/sbin/nginx --conf-path=/usr/local/tengine/conf/nginx.conf --error-log-path=/var/log/tengine/error.log --http-log-path=/var/log/tengine/access.log --pid-path=/var/run/tengine.pid --lock-path=/var/lock/subsys/tengine --user=nginx --group=nginx --with-pcre=../pcre-8.37 --with-http_ssl_module --with-http_upstream_check_module --dso-path=/usr/local/tengine/modules --with-jemalloc --with-jemalloc=/usr/local/jemalloc-3.6.0 --add-module=../nginx_concat_module/
make
make install
mkdir -pv /var/tmp/tengine/{proxy,fastcgi,uwsgi}
查询版本: /usr/local/tengine/sbin/nginx ?v
启动:. /usr/local/tengine/sbin/nginx
出错提示:[emerg] getpwnam("nginx") failed
添加用户组->nginx : useradd -r -M nginx
后,使用url访问可看到 “ Welcome to tengine!”,
如:http://192.168.1.103/
实例1:反向代理指定端口
在 server{} 内加入:
listen 80;
server_name ELK;
proxy_pass http://192.168.1.78:9100/;
}
直接跳过原端口直接访问原带有端口的地址:
即:
http://192.168.1.78/elk_head/ => http://192.168.1.78:9100/
实例2:二级域名反向代理不同后端服务
server {
listen 80;
server_name project1.example.com;
location / {
proxy_pass http://127.0.0.1:8001;
}
}
server {
listen 80;
server_name project2
.example.com;
location / {
proxy_pass http://127.0.0.1:8002;
}
}
问题1:mongodb 加载图片只显示部分
原因:查询nginx错误日志,发现nginx proxy_temp目录无权访问
tail -1000f /usr/local/tengine/logs/error.log
/usr/local/tengine/proxy_temp/4/03/0000000034" failed (13: Permission denied)
解决办法:
chown -R nginx:nginx /usr/local/tengine/
问题2:日志文件出现大量head访问日志
在配置文件中关闭head访问日志
if ($request_method = HEAD) {
access_log off;
}
- 本文标签: 暂无相关标签
- 本文链接: https://www.jimmy2k.top/article/54
- 版权声明: 本文由JimmyZ的个人博客原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权