├── .github └── workflows │ └── docker.yml ├── LICENSE ├── README.md └── template ├── Dockerfile ├── build.sh ├── docker.conf ├── entrypoint.sh ├── htpasswd └── setup_docker.sh /.github/workflows/docker.yml: -------------------------------------------------------------------------------- 1 | name: docker-build 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - master 8 | 9 | pull_request: 10 | branches: 11 | - master 12 | env: 13 | FOLDER: template 14 | OLS_VERSION: 1.8.3 15 | 16 | jobs: 17 | test: 18 | runs-on: ubuntu-latest 19 | strategy: 20 | matrix: 21 | PHP_VERSION: [lsphp81,lsphp82,lsphp83,lsphp84] 22 | TAG: [latest,''] 23 | steps: 24 | - uses: actions/checkout@v2 25 | - 26 | name: Set up QEMU 27 | uses: docker/setup-qemu-action@v3 28 | - 29 | name: Set up Docker Buildx 30 | uses: docker/setup-buildx-action@v3 31 | - name: Docker build and push 32 | if: ${{ (github.ref == 'refs/heads/master' && github.event_name == 'push') || (github.event_name == 'workflow_dispatch') }} 33 | run: | 34 | echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin 35 | cd ${{ env.FOLDER }} 36 | bash build.sh --ols ${{ env.OLS_VERSION }} --php ${{ matrix.PHP_VERSION }} --arch 'linux/amd64,linux/arm64' --tag "${{ matrix.TAG }}" --push 37 | env: 38 | DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} 39 | DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} 40 | - name: Docker build 41 | if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'pull_request' }} 42 | run: | 43 | cd ${{ env.FOLDER }} 44 | bash build.sh --ols ${{ env.OLS_VERSION }} --php ${{ matrix.PHP_VERSION }} --arch 'linux/amd64,linux/arm64' --tag ${{ matrix.TAG }} 45 | 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Litespeedtech 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenLiteSpeed Docker Container 2 | [![Build Status](https://github.com/litespeedtech/ols-dockerfiles/workflows/docker-build/badge.svg)](https://github.com/litespeedtech/ols-dockerfiles/actions/new) 3 | [![docker pulls](https://img.shields.io/docker/pulls/litespeedtech/openlitespeed?style=flat&color=blue)](https://hub.docker.com/r/litespeedtech/openlitespeed) 4 | [](litespeedtech.com/slack) 5 | [](https://twitter.com/litespeedtech) 6 | 7 | Install a lightweight OpenLiteSpeed container using either the Edge or Stable version in Ubuntu 24.04 Linux. 8 | 9 | ### Prerequisites 10 | * [Install Docker](https://www.docker.com/) 11 | 12 | ## Build Components 13 | The system will regulary build both OpenLiteSpeed Edge and Latest stable versions, along with the last two PHP versions. 14 | 15 | |Component|Version| 16 | | :-------------: | :-------------: | 17 | |Linux|Ubuntu 24.04| 18 | |OpenLiteSpeed|[Latest stable version](https://openlitespeed.org/release-log/version-1-8-x)| 19 | |PHP|[Latest stable version](http://rpms.litespeedtech.com/debian/)| 20 | 21 | ## Usage 22 | ### Download an image 23 | Download the openlitespeed image, we can use latest for latest version 24 | ``` 25 | docker pull litespeedtech/openlitespeed:latest 26 | ``` 27 | or specify the OpenLiteSpeed version with lsphp version 28 | ``` 29 | docker pull litespeedtech/openlitespeed:1.8.3-lsphp83 30 | ``` 31 | ### Start a Container 32 | ``` 33 | docker run --name openlitespeed -p 7080:7080 -p 80:80 -p 443:443 -it litespeedtech/openlitespeed:latest 34 | ``` 35 | You can also run with Detached mode, like so: 36 | ``` 37 | docker run -d --name openlitespeed -p 7080:7080 -p 80:80 -p 443:443 -it litespeedtech/openlitespeed:latest 38 | ``` 39 | Tip, you can get rid of `-p 7080:7080` from the command if you don’t need the web admin access. 40 | 41 | ### Add a sample page 42 | The server should start running successfully, and you should be able to log into the container. Add some files you want to display with the following command: 43 | ``` 44 | docker exec -it openlitespeed bash 45 | ``` 46 | Your default `WORKDIR` should be `/var/www/vhosts/`, since the default document root path is `/var/www/vhosts/localhost/html`. Simply add the following command to `index.php`, then we can verify it from the browser with a public server IP address on both HTTP and HTTPS. 47 | ``` 48 | echo ' localhost/html/index.php 49 | ``` 50 | 51 | ### Stop a Container 52 | Feel free to substitute the "openlitespeed" to the "Container_ID" if you did not define any name for the container. 53 | ``` 54 | docker stop openlitespeed 55 | ``` 56 | 57 | ## Customization 58 | Sometimes you may want to install more packages from the default image, or some other web server or PHP version which is not officially provided. You can build an image based on an existing image. Here’s how: 59 | 1. Download the dockerfile project 60 | 2. `cd` into the project directory 61 | 3. Edit the Dockerfile here if necessary 62 | 4. Build, feeling free to substitute server and PHP versions to fit your needs 63 | 64 | For example, 65 | ``` 66 | git clone https://github.com/litespeedtech/ols-dockerfiles.git 67 | cd ols-dockerfiles/template 68 | bash build.sh -O 1.7.16 -P lsphp81 69 | ``` 70 | 71 | ## Support & Feedback 72 | If you still have a question after using OpenLiteSpeed Docker, you have a few options. 73 | * Join [the GoLiteSpeed Slack community](https://litespeedtech.com/slack) for real-time discussion 74 | * Post to [the OpenLiteSpeed Forums](https://forum.openlitespeed.org/) for community support 75 | * Reporting any issue on [Github ols-dockerfiles](https://github.com/litespeedtech/ols-dockerfiles/issues) project 76 | 77 | **Pull requests are always welcome** -------------------------------------------------------------------------------- /template/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:24.04 2 | ARG OLS_VERSION 3 | ARG PHP_VERSION 4 | ARG TARGETPLATFORM 5 | 6 | ENV LS_FD='/usr/local/lsws' 7 | ENV PHPINI_PATH="$LS_FD/$PHP_VERSION/etc/php/*/litespeed/php.ini" 8 | 9 | RUN apt-get update && apt-get install wget curl cron tzdata -y 10 | 11 | RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ 12 | wget https://openlitespeed.org/packages/openlitespeed-$OLS_VERSION-x86_64-linux.tgz && \ 13 | tar xzf openlitespeed-$OLS_VERSION-x86_64-linux.tgz && cd openlitespeed && ./install.sh && \ 14 | echo 'cloud-docker' > $LS_FD/PLAT && rm -rf /openlitespeed && rm /openlitespeed-$OLS_VERSION-x86_64-linux.tgz; \ 15 | elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ 16 | wget https://openlitespeed.org/packages/openlitespeed-$OLS_VERSION-aarch64-linux.tgz && \ 17 | tar xzf openlitespeed-$OLS_VERSION-aarch64-linux.tgz && cd openlitespeed && ./install.sh && \ 18 | echo 'cloud-docker' > $LS_FD/PLAT && rm -rf /openlitespeed && rm /openlitespeed-$OLS_VERSION-aarch64-linux.tgz; \ 19 | else \ 20 | echo "$TARGETPLATFORM is not supported"; \ 21 | fi 22 | 23 | RUN wget -O - https://repo.litespeed.sh | bash 24 | 25 | RUN apt-get install mysql-client $PHP_VERSION $PHP_VERSION-common $PHP_VERSION-mysql $PHP_VERSION-opcache \ 26 | $PHP_VERSION-curl $PHP_VERSION-imagick $PHP_VERSION-redis $PHP_VERSION-memcached $PHP_VERSION-intl -y 27 | 28 | RUN ["/bin/bash", "-c", "if [[ $PHP_VERSION == lsphp7* ]]; then apt-get install $PHP_VERSION-json -y; fi"] 29 | 30 | RUN wget -O $LS_FD/admin/misc/lsup.sh \ 31 | https://raw.githubusercontent.com/litespeedtech/openlitespeed/master/dist/admin/misc/lsup.sh && \ 32 | chmod +x $LS_FD/admin/misc/lsup.sh 33 | 34 | RUN sed -i 's/memory_limit = 128M/memory_limit = 1024M/g' $PHPINI_PATH && \ 35 | sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 1024M/g' $PHPINI_PATH && \ 36 | sed -i 's/post_max_size = 8M/post_max_size = 1024M/g' $PHPINI_PATH && \ 37 | sed -i 's/max_execution_time = 30/max_execution_time = 300/g' $PHPINI_PATH 38 | 39 | RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \ 40 | chmod +x wp-cli.phar && mv wp-cli.phar /usr/bin/wp && \ 41 | ln -s $LS_FD/$PHP_VERSION/bin/php /usr/bin/php 42 | 43 | RUN wget -O - https://get.acme.sh | sh 44 | 45 | EXPOSE 7080 46 | ENV PATH="/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin" 47 | 48 | ADD docker.conf $LS_FD/conf/templates/docker.conf 49 | ADD setup_docker.sh $LS_FD/bin/setup_docker.sh 50 | ADD htpasswd $LS_FD/admin/conf/htpasswd 51 | 52 | RUN $LS_FD/bin/setup_docker.sh && rm $LS_FD/bin/setup_docker.sh 53 | RUN chown 994:994 $LS_FD/conf -R 54 | RUN cp -RP $LS_FD/conf/ $LS_FD/.conf/ 55 | RUN cp -RP $LS_FD/admin/conf $LS_FD/admin/.conf/ 56 | RUN ["/bin/bash", "-c", "if [[ $PHP_VERSION == lsphp8* ]]; then ln -sf $LS_FD/$PHP_VERSION/bin/lsphp $LS_FD/fcgi-bin/lsphp8; fi"] 57 | RUN ["/bin/bash", "-c", "if [[ $PHP_VERSION == lsphp8* ]]; then ln -sf $LS_FD/fcgi-bin/lsphp8 $LS_FD/fcgi-bin/lsphp; fi"] 58 | RUN ["/bin/bash", "-c", "if [[ $PHP_VERSION == lsphp7* ]]; then ln -sf $LS_FD/$PHP_VERSION/bin/lsphp $LS_FD/fcgi-bin/lsphp7; fi"] 59 | RUN ["/bin/bash", "-c", "if [[ $PHP_VERSION == lsphp7* ]]; then ln -sf $LS_FD/fcgi-bin/lsphp7 $LS_FD/fcgi-bin/lsphp; fi"] 60 | COPY entrypoint.sh /entrypoint.sh 61 | RUN chmod +x /entrypoint.sh 62 | ENTRYPOINT ["/entrypoint.sh"] 63 | WORKDIR /var/www/vhosts/ 64 | -------------------------------------------------------------------------------- /template/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | OLS_VERSION='' 3 | PHP_VERSION='' 4 | PUSH='' 5 | CONFIG='' 6 | TAG='' 7 | BUILDER='litespeedtech' 8 | REPO='openlitespeed' 9 | EPACE=' ' 10 | ARCH='linux/amd64' 11 | 12 | echow(){ 13 | FLAG=${1} 14 | shift 15 | echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}" 16 | } 17 | 18 | help_message(){ 19 | echo -e "\033[1mOPTIONS\033[0m" 20 | echow '-O, --ols [VERSION] -P, --php [lsphpVERSION]' 21 | echo "${EPACE}${EPACE}Example: bash build.sh --ols 1.8.2 --php lsphp83" 22 | echow '--push' 23 | echo "${EPACE}${EPACE}Example: build.sh --ols 1.8.2 --php lsphp83 --push, will push to the dockerhub" 24 | echow '--arch' 25 | echo "${EPACE}${EPACE}Example: build.sh --ols 1.8.2 --php lsphp83 --arch linux/amd64,linux/arm64, will build image for both amd64 and arm64, otherwise linux/amd64 will be applied." 26 | exit 0 27 | } 28 | 29 | check_input(){ 30 | if [ -z "${1}" ]; then 31 | help_message 32 | fi 33 | } 34 | 35 | build_image(){ 36 | if [ -z "${1}" ] || [ -z "${2}" ]; then 37 | help_message 38 | else 39 | echo "Build image: ${1} ${2}" 40 | #docker build . --tag ${BUILDER}/${REPO}:${1}-${2} --build-arg OLS_VERSION=${1} --build-arg PHP_VERSION=${2} 41 | docker buildx build . --platform ${ARCH} --tag ${BUILDER}/${REPO}:${1}-${2} --build-arg OLS_VERSION=${1} --build-arg PHP_VERSION=${2} --output=type=registry 42 | fi 43 | } 44 | 45 | test_image(){ 46 | echo "Test image" 47 | ID=$(docker run -d ${BUILDER}/${REPO}:${1}-${2}) 48 | docker exec -i ${ID} su -c 'mkdir -p /var/www/vhosts/localhost/html/ \ 49 | && echo " /var/www/vhosts/localhost/html/index.php \ 50 | && /usr/local/lsws/bin/lswsctrl restart' 51 | sleep 5 52 | HTTP=$(docker exec -i ${ID} curl -s -o /dev/null -Ik -w "%{http_code}" http://localhost) 53 | HTTPS=$(docker exec -i ${ID} curl -s -o /dev/null -Ik -w "%{http_code}" https://localhost) 54 | docker kill ${ID} 55 | if [[ "${HTTP}" != "200" || "${HTTPS}" != "200" ]]; then 56 | echo '[X] Test failed!' 57 | echo "http://localhost returned ${HTTP}" 58 | echo "https://localhost returned ${HTTPS}" 59 | exit 1 60 | else 61 | echo '[O] Tests passed!' 62 | fi 63 | } 64 | 65 | build_push_image(){ 66 | if [ ! -z "${PUSH}" ]; then 67 | echo 'Push image' 68 | if [ -f ~/.docker/litespeedtech/config.json ]; then 69 | CONFIG=$(echo --config ~/.docker/litespeedtech) 70 | fi 71 | #docker ${CONFIG} push ${BUILDER}/${REPO}:${1}-${2} 72 | if [ -z "${TAG}" ]; then 73 | docker buildx build . --platform ${ARCH} --tag ${BUILDER}/${REPO}:${1}-${2} --build-arg OLS_VERSION=${1} --build-arg PHP_VERSION=${2} --output=type=registry --push 74 | else 75 | #docker tag ${BUILDER}/${REPO}:${1}-${2} ${BUILDER}/${REPO}:${3} 76 | #docker ${CONFIG} push ${BUILDER}/${REPO}:${3} 77 | docker buildx build . --platform ${ARCH} --tag ${BUILDER}/${REPO}:${3} --build-arg OLS_VERSION=${1} --build-arg PHP_VERSION=${2} --output=type=registry --push 78 | fi 79 | else 80 | echo 'Skip Push.' 81 | fi 82 | } 83 | 84 | main(){ 85 | build_image ${OLS_VERSION} ${PHP_VERSION} 86 | test_image ${OLS_VERSION} ${PHP_VERSION} 87 | build_push_image ${OLS_VERSION} ${PHP_VERSION} ${TAG} 88 | } 89 | 90 | check_input ${1} 91 | while [ ! -z "${1}" ]; do 92 | case ${1} in 93 | -[hH] | -help | --help) 94 | help_message 95 | ;; 96 | -[oO] | -ols | --ols) shift 97 | check_input "${1}" 98 | OLS_VERSION="${1}" 99 | ;; 100 | -[pP] | -php | --php) shift 101 | check_input "${1}" 102 | PHP_VERSION="${1}" 103 | ;; 104 | -[tT] | -tag | -TAG | --tag) shift 105 | TAG="${1}" 106 | ;; 107 | -[aA] | -arch | --arch) shift 108 | check_input "${1}" 109 | ARCH="${1}" 110 | ;; 111 | --push ) shift 112 | PUSH=true 113 | ;; 114 | *) 115 | help_message 116 | ;; 117 | esac 118 | shift 119 | done 120 | 121 | main -------------------------------------------------------------------------------- /template/docker.conf: -------------------------------------------------------------------------------- 1 | allowSymbolLink 1 2 | enableScript 1 3 | restrained 1 4 | setUIDMode 2 5 | vhRoot /var/www/vhosts/$VH_NAME/ 6 | configFile $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf 7 | 8 | virtualHostConfig { 9 | docRoot $VH_ROOT/html/ 10 | enableGzip 1 11 | 12 | errorlog { 13 | useServer 1 14 | } 15 | 16 | accesslog $SERVER_ROOT/logs/$VH_NAME.access.log { 17 | useServer 0 18 | rollingSize 100M 19 | keepDays 7 20 | compressArchive 1 21 | } 22 | 23 | index { 24 | useServer 0 25 | indexFiles index.html, index.php 26 | autoIndex 0 27 | autoIndexURI /_autoindex/default.php 28 | } 29 | 30 | expires { 31 | enableExpires 1 32 | } 33 | 34 | accessControl { 35 | allow * 36 | } 37 | 38 | context / { 39 | location $DOC_ROOT/ 40 | allowBrowse 1 41 | 42 | rewrite { 43 | RewriteFile .htaccess 44 | } 45 | } 46 | 47 | rewrite { 48 | enable 1 49 | autoLoadHtaccess 1 50 | logLevel 0 51 | } 52 | 53 | vhssl { 54 | keyFile /root/.acme.sh/certs/$VH_NAME_ecc/$VH_NAME.key 55 | certFile /root/.acme.sh/certs/$VH_NAME_ecc/fullchain.cer 56 | certChain 1 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /template/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -z "$(ls -A -- "/usr/local/lsws/conf/")" ]; then 3 | cp -R /usr/local/lsws/.conf/* /usr/local/lsws/conf/ 4 | fi 5 | if [ -z "$(ls -A -- "/usr/local/lsws/admin/conf/")" ]; then 6 | cp -R /usr/local/lsws/admin/.conf/* /usr/local/lsws/admin/conf/ 7 | fi 8 | chown 994:994 /usr/local/lsws/conf -R 9 | chown 994:1001 /usr/local/lsws/admin/conf -R 10 | 11 | /usr/local/lsws/bin/lswsctrl start 12 | $@ 13 | while true; do 14 | if ! /usr/local/lsws/bin/lswsctrl status | /usr/bin/grep 'litespeed is running with PID *' > /dev/null; then 15 | break 16 | fi 17 | sleep 60 18 | done 19 | 20 | -------------------------------------------------------------------------------- /template/htpasswd: -------------------------------------------------------------------------------- 1 | admin:$1$RaqgGtmd$81EhmoqpWhiJJtCDRp0FX/ 2 | -------------------------------------------------------------------------------- /template/setup_docker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "listener HTTP { 3 | address *:80 4 | secure 0 5 | } 6 | 7 | listener HTTPS { 8 | address *:443 9 | secure 1 10 | keyFile /usr/local/lsws/admin/conf/webadmin.key 11 | certFile /usr/local/lsws/admin/conf/webadmin.crt 12 | } 13 | 14 | vhTemplate docker { 15 | templateFile conf/templates/docker.conf 16 | listeners HTTP, HTTPS 17 | note docker 18 | 19 | member localhost { 20 | vhDomain localhost, * 21 | } 22 | } 23 | 24 | " >> /usr/local/lsws/conf/httpd_config.conf 25 | 26 | mkdir -p /var/www/vhosts/localhost/{html,logs,certs} 27 | chown 1000:1000 /var/www/vhosts/localhost/ -R --------------------------------------------------------------------------------