phpearth / docker-php

🐳 Docker For PHP developers - Docker images with PHP, Nginx, OpenLiteSpeed, Apache, Lighttpd, and Alpine
https://docs.php.earth/docker
MIT License
261 stars 80 forks source link

PHP-Litespeed [Alpine:3.8] missing admin_php symlink/binary #22

Closed adaliszk closed 5 years ago

adaliszk commented 5 years ago

I've wanted to use the litespeed but looks like it's not quite working with the current package. The problem seems to that while the php7.*-litespeed contains the lsphp it doesn't have the /var/lib/litespeed/admin/fcgi-bin/admin_php

Dockerfile:

# Build configurations
ARG ALPINE_VERSION="3.8"

# STAGE: Base image for Laravel 5.4 with OpenLiteSpeed
FROM "alpine:${ALPINE_VERSION}" as php-litespeed
LABEL Name="PHP-Base-Image" \
      Description="Simple base image for Laravel 5.6 and serve it trough LiteSpeed" \
      Maintainer="Ádám Liszkai <adaliszk@gmail.com>" \
      Version="0.2.0-beta"

# Environment configurations
ENV COMPOSER_HOME="/tmp/composer" \
    COMPOSER_CACHE_DIR="/tmp/composer-cache" \
    PHP_VERSION="7.2" \
    DAEMON_USER="lsdaemon" \
    DAEMON_UID="50" \
    DAEMON_GID="50"

# Add base dependencies
RUN apk add --no-cache bash wget ca-certificates \
 # Adding PHPEarth repository for quick, optimized php packages
 && wget -O /etc/apk/keys/phpearth.rsa.pub https://repos.php.earth/alpine/phpearth.rsa.pub \
 && echo "https://repos.php.earth/alpine/v${ALPINE_VERSION}" >> /etc/apk/repositories \
 # Adding the testing repos so we can install OpenLiteSpeed
 && echo '@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories \
 && apk add --no-cache "php${PHP_VERSION}" "php${PHP_VERSION}-litespeed" "litespeed@testing" "composer" \
 # Creating folders for Composer/Project
 && mkdir -p /code /tmp/code "${COMPOSER_HOME}" "${COMPOSER_CACHE_DIR}" \
 # Update permissions for normal users to get access
 && chmod g+rwx /code /tmp/code "${COMPOSER_HOME}" "${COMPOSER_CACHE_DIR}" \
 # Add Paralel downloading for composer
 && composer global require --no-interaction --no-progress "hirak/prestissimo" \
 # Add Laravel dependencies
 && composer global require "laravel/framework" "5.6.*" \
 && composer global require "vlucas/phpdotenv" "2.4.*" \
 # Cleanup pacakge list cache (~300MB) but leave downloaded source cache
 && rm -rf "${COMPOSER_CACHE_DIR}" \
 # Create a separate user to run services instead using root
 && set -x && addgroup -g "${DAEMON_GID}" -S "${DAEMON_USER}" \
 && adduser -u "${DAEMON_UID}" -D -S -G ${DAEMON_USER} ${DAEMON_USER} \
 # Expose LiteSpeed output to the container
 && ln -sf /dev/stdout /var/lib/litespeed/logs/access.log \
 && ln -sf /dev/stderr /var/lib/litespeed/logs/error.log

# Expose ports
EXPOSE 7080 8080

# Run the LiteSpeed service
CMD ["/var/lib/litespeed/bin/lswsctrl", "start"]

# STAGE: Add the codebase
FROM php-litespeed

COPY . /code

Log:

[INFO] [PlainConf] [httpServerConfig:] start parsing file /var/lib/litespeed/conf/httpd_config.conf
[INFO] [PlainConf] [httpServerConfig:] Failed to RCS checkin conf file /var/lib/litespeed/conf/httpd_config.conf0, ret 32512, error(File exists). Org command is ci -l -q -t-"/var/lib/litespeed/conf/httpd_config.conf0" -mUpdate "/var/lib/litespeed/conf/httpd_config.conf0" >/dev/null 2>&1.
[NOTICE] Loading LiteSpeed/1.4.28 Open ...
[NOTICE] Using [LibreSSL 2.7.4]
[NOTICE] [ADMIN] server socket: uds://var/lib/litespeed/admin/tmp/admin.sock.7036
[NOTICE] chroot is disabled.
[INFO] old priority: 0, new priority: 0
[INFO] [config:server:basics2] For better obscurity, server version number is hidden in the response header.
 [INFO] [PlainConf] Failed to RCS checkin conf file /var/lib/litespeed/conf/mime.properties0, ret 32512, error(No such file or directory). Org command is ci -l -q -t-"/var/lib/litespeed/conf/mime.properties0" -mUpdate "/var/lib/litespeed/conf/mime.properties0" >/dev/null 2>&1.
[NOTICE] [PID: 23]: forked cgid: 27
[INFO] [PlainConf] [adminConfig:] start parsing file /var/lib/litespeed/admin/conf/admin_config.conf
[INFO] [PlainConf] [adminConfig:] Failed to RCS checkin conf file /var/lib/litespeed/admin/conf/admin_config.conf0, ret 32512, error(No such file or directory). Org command is ci -l -q -t-"/var/lib/litespeed/admin/conf/admin_config.conf0" -mUpdate "/var/lib/litespeed/admin/conf/admin_config.conf0" >/dev/null 2>&1.
[INFO] [Module: modcompress 1.1] has been initialized successfully
[INFO] [Module: moddecompress 1.1] has been initialized successfully
[NOTICE] The maximum number of file descriptor limit is set to 1048576.
[ERROR] [config:admin] missing PHP binary for admin server - /var/lib/litespeed/admin/fcgi-bin/admin_php!
[ERROR] Failed to setup the WEB administration interface!
[ERROR] Fatal error in configuration, exit!
[OK] litespeed: pid=23.
killall: litespeed: no process killed
[INFO] [PlainConf] [httpServerConfig:] start parsing file /var/lib/litespeed/conf/httpd_config.conf
[INFO] [PlainConf] [httpServerConfig:] Failed to RCS checkin conf file /var/lib/litespeed/conf/httpd_config.conf0, ret 32512, error(File exists). Org command is ci -l -q -t-"/var/lib/litespeed/conf/httpd_config.conf0" -mUpdate "/var/lib/litespeed/conf/httpd_config.conf0" >/dev/null 2>&1.
[NOTICE] Loading LiteSpeed/1.4.28 Open ...
[NOTICE] Using [LibreSSL 2.7.4]
[NOTICE] [ADMIN] server socket: uds://var/lib/litespeed/admin/tmp/admin.sock.7254
[NOTICE] chroot is disabled.
[INFO] old priority: 0, new priority: 0
[INFO] [config:server:basics2] For better obscurity, server version number is hidden in the response header.
[OK] litespeed: pid=46.
adaliszk commented 5 years ago

Hmm, it's there without any problem so I close this because the problem is different:

ls -la /var/lib/litespeed/admin
drwxr-xr-x   13 root     root          4096 Jul 27 09:46 .
drwxr-xr-x    1 root     root          4096 Jul 27 09:46 ..
drwxr-xr-x    5 root     root          4096 Jul 27 09:46 Example
-rw-r--r--    1 root     root             7 Apr  9 08:14 VERSION
drwxr-xr-x    2 root     root          4096 Jul 27 09:46 add-ons
drwxr-xr-x    7 root     root          4096 Jul 27 09:46 admin
drwxr-xr-x    2 litespee litespee      4096 Jul 27 09:46 backup
drwxr-xr-x    2 root     root          4096 Jul 27 09:46 bin
drwxr-xr-x    2 litespee litespee      4096 Jul 27 09:46 cachedata
lrwxrwxrwx    1 root     root            14 Jul 27 09:46 conf -> /etc/litespeed
drwxr-xr-x    6 root     root          4096 Jul 27 09:46 docs
drwxr-xr-x    2 root     root          4096 Jul 27 09:47 fcgi-bin
lrwxrwxrwx    1 root     root            18 Jul 27 09:46 logs -> /var/log/litespeed
drwxr-xr-x    2 root     root          4096 Jul 27 09:46 modules
drwxr-xr-x    3 root     root          4096 Jul 27 09:46 share
drwxr-xr-x    3 litespee litespee      4096 Jul 27 09:46 tmp
total 28

ls -la /var/lib/litespeed/admin
drwxr-xr-x    7 root     root          4096 Jul 27 09:46 .
drwxr-xr-x   13 root     root          4096 Jul 27 09:46 ..
drwx--x---    3 root     root          4096 Jul 27 09:46 cgid
lrwxrwxrwx    1 root     root            20 Jul 27 09:46 conf -> /etc/litespeed/admin
drwxr-xr-x    2 root     root          4096 Jul 27 09:46 fcgi-bin
lrwxrwxrwx    1 root     root            11 Jul 27 09:46 html -> ./html.open
drwxr-xr-x    5 root     root          4096 Jul 27 09:46 html.open
lrwxrwxrwx    1 root     root            24 Jul 27 09:46 logs -> /var/log/litespeed/admin
drwxr-xr-x    2 root     root          4096 Jul 27 09:46 misc
drwx--x---    2 litespee litespee      4096 Jul 27 09:46 tmp
total 8

ls -la /var/lib/litespeed/admin/cgi-bin
drwxr-xr-x    2 root     root          4096 Jul 27 09:46 .
drwxr-xr-x    7 root     root          4096 Jul 27 09:46 ..
lrwxrwxrwx    1 root     root            15 Jul 27 09:46 admin_php -> /usr/bin/lsphp7
petk commented 5 years ago

Instead of executing lswsctrl via CMD ["/var/lib/litespeed/bin/lswsctrl", "start"], it would be better and more resilient to use something like runit or a bit more resources intense supervisord. These images use runit.

adaliszk commented 5 years ago

Yeah it would be nice, can I set that up with a non-root user?

petk commented 5 years ago

Yes, can be done...

adaliszk commented 5 years ago

Okay, because there is one piece which is not mentioned here is that I need to make it work in a kubertenes environment where we using namespace users. But one issue at a time ;)