2233466866 / lnmp

Docker Linux+Nignx+MySQL+PHP+Node.js+Redis
https://hub.docker.com/r/2233466866/lnmp
MIT License
65 stars 34 forks source link

将nginx日志配置到/dev/stdout中输出,nginx状态正常,但却不可访问 #10

Closed MrChium closed 1 year ago

MrChium commented 2 years ago

将 nginx.conf 中的日志配置指向 /dev/stdout error_log /dev/stderr notice; access_log /dev/stdout main;

nginx -t 返回: nginx: the configuration file /usr/local/nginx//conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx//conf/nginx.conf test is successful 但却不可访问

使用 docker logs -f (容器名) 也无日志输出

2233466866 commented 1 year ago

此镜像基于systemd对nginx、php、mysql服务进行管理,请检查是否已经成功启动相关服务。

LNMP无法启动php、nginx、mysql,参考以下方案:

CentOS:

--privileged=true
-v /sys/fs/cgroup:/sys/fs/cgroup:ro

Ubuntu:

--privileged=true
-v /tmp/$(mktemp -d):/run
-v /sys/fs/cgroup:/sys/fs/cgroup:ro

Windows、Mac:

# 需要进入容器手动启动服务,进入容器:
docker exec -it <CONTAINERID> bash

# 启动nginx:
/usr/local/nginx/sbin/nginx

# php5、php7、php8都是9000端口,想使用多版本需要修改配置文件的端口号
# 启动php7:(启动php5、php8命令改下数字照搬命令即可,多版本共用要改配置)
/usr/local/php7/sbin/php-fpm

# 启动mysql
su mysql
mysqld --initialize
/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS

# 查看mysql默认密码
password=`cat /var/log/mysqld.log|grep 'A temporary password'`;password=${password:91};echo $password