problems_nginx

1 配置nginx编译选项./configure --prefix=/usr/local/nginx --with-http_ssl_module报错

报错内容:./configure: error: C compiler cc is not found

原因:未安装gcc gcc-c++ autoconf make

解决方法:yum -y install gcc gcc-c++ autoconf make

2 通过make命令编译和安装nginx报错

make && make install 报错,内容如下:make: *** No rule to make target 'build', needed by 'default'. Stop.
解决方法:

  1. 更新yum:yum update(不过实际过程中我没执行这一步)
  2. 安装前置库openssl,pcre和gd,执行命令yum -y install openssl-devel pcre-devel gd-devel
  3. 删除之前准备make的nginx包,然后重新解压一个
    tar -zxvf /usr/apps/nginx-1.16.1.tar.gz -C /usr/develop/
  4. 再次配置编译选项,执行./configure --prefix=/usr/local/nginx --with-http_ssl_module
  5. 再次编译和安装,执行make && make install
    参考链接:https://blog.csdn.net/cailongbiaoyuli/article/details/84348866

3 docker容器中无法使用 systemd(systemctl) 相关命令

centos7和centos8启动nginx服务报错,执行systemctl start nginx.service报错内容如下:

[root@2cabcd9b34f1 system]# systemctl start nginx.service
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

原因: 1号进程不是 init ,而是其他例如 /bin/bash ,所以导致缺少相关文件无法运行。
解决方案:/sbin/init
例如:centos,ubuntu,
docker run -tid --name test --privileged=true centos:latest /sbin/init
docker run -tid --name test_1 --privileged=true centos:latest /usr/sbin/init
docker run -tid --name test_2 --privileged=true ubuntu:16.04 /sbin/init
docker exec -it test /bin/bash
注: --privilaged=true一定要加上。

小结:还可以使用Dockerfile来设置nginx的开机启动。

4 halo无法上传容量大于1M的附件

(当然是经过了多次的测试,得出了1M的结论)
猜想是nginx的限制。果然,原因是nginx默认上传的最大文件大小是1M。
解决方法:

vim /usr/local/nginx/conf/nginx.conf
# 在server下添加如下语句
client_max_body_size 10M;
# 保存,再重新加载nginx配置,解决
systemctl reload nginx

注意:一定要将上述语句放在server{} 中,否则无效。

5

6

原文地址:https://www.cnblogs.com/mediocreWorld/p/15186191.html