├── .github └── workflows │ └── docker.yml ├── .travis.yml.bk ├── LICENSE ├── README.md └── template ├── Dockerfile ├── build.sh ├── docker.xml ├── entrypoint.sh ├── htpasswd ├── lsws-install.sh └── 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 | LSWS_VERSION: 6.3.2 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 --lsws ${{ env.LSWS_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 --lsws ${{ env.LSWS_VERSION }} --php ${{ matrix.PHP_VERSION }} --arch 'linux/amd64,linux/arm64' --tag ${{ matrix.TAG }} 45 | 46 | -------------------------------------------------------------------------------- /.travis.yml.bk: -------------------------------------------------------------------------------- 1 | language: shell 2 | os: linux 3 | 4 | notifications: 5 | email: 6 | on_success: never 7 | on_failure: always 8 | slack: 9 | secure: MY1VT3Cv7lZ2EhNCbzvlqNq4HIKtI+EzjZXTVXnwAZTHuABw+EGmX67q1q6vyyY68lQdtUe/sRh+Q8KbaDKl74P3ZzHZQMN5tZN8RsXmzAAj8ZqDhtOFjreIXlfNjR18ciKIAOQdAZgVCwg/PyGdiCACJmQeI19qRdExMofhAT9W8q6ErEFHFb7QByj+mgbymL/B2LjH1sSEb0wSQEM64VQFDUM5vKKbDWaje+jGBf/W8Ro+vJYGMO/cl3xhGtCJOU+/GwXbylkGq8JCXtpJMn8VxhL5IlP8t3GmgOVZOtL6zt1ZXMblGQSsk7O/rM/lYAZSETUyMO1XivfxXvkvoZbISOpaY0yG58Z5FoQTiGMSL9Qwqv5NBSLcoQdjGCFDrwWmIrLKObmZ3TNazbqwY8n7zCPxHqDl+ZiQvAlhgndvbgTbVG5WthBQv81voXcUukX3sAA2J6yMHxaus32s8dHRayUwPvaxZNrLuToH8pXdhO9XvuIGjAERWwBd90ru1o9quzlilz2JIQH8fFWAjJX23bMDvucqOEfjpMTFFs4Mc5/CkIuQ/9m9eOvvy7wtvPAO51+v+xyr36G+COxUdo/GnbN3uP840QxIlMzf64VKKzlAe0v50VMd3iISwsIAgDYwIIFngxVKvlIDe7hK/n0vgVCgXFmT6YOdnPBuC8g= 10 | template: 11 | - "Repo %{repository_slug} *%{result}* build (<%{build_url}|#%{build_number}>) for commit (<%{compare_url}|%{commit}>)" 12 | - "%{author}: _%{commit_message}_" 13 | - "Execution time: *%{duration}*" 14 | - "Message: *%{message}*" 15 | on_success: always 16 | 17 | services: 18 | - docker 19 | env: 20 | - LSWS_VERSION=5.4.11 PHP_VERSION=lsphp74 FOLDER=template TAG=latest 21 | - LSWS_VERSION=5.4.11 PHP_VERSION=lsphp73 FOLDER=template 22 | script: 23 | - | 24 | if [ $TRAVIS_BRANCH == "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then 25 | echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin 26 | cd $FOLDER && bash build.sh --lsws $LSWS_VERSION --php $PHP_VERSION --tag "$TAG" --push 27 | else 28 | cd $FOLDER && bash build.sh --lsws $LSWS_VERSION --php $PHP_VERSION 29 | fi 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 - 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 | # LiteSpeed Docker Container 2 | [![Build Status](https://github.com/litespeedtech/lsws-dockerfiles/workflows/docker-build/badge.svg)](https://hub.docker.com/r/litespeedtech/litespeed) 3 | [![docker pulls](https://img.shields.io/docker/pulls/litespeedtech/litespeed?style=flat&color=blue)](https://hub.docker.com/r/litespeedtech/litespeed) 4 | [](litespeedtech.com/slack) 5 | [](https://twitter.com/litespeedtech) 6 | 7 | Install a lightweight LiteSpeed container using Stable version in Ubuntu 24.04 Linux. 8 | 9 | ### Prerequisites 10 | * [Install Docker](https://www.docker.com/) 11 | 12 | ## Building Components 13 | The system will regulary build LiteSpeed Latest stable version, along with the last two PHP versions. 14 | 15 | |Component|Version| 16 | | :-------------: | :-------------: | 17 | |Linux|Ubuntu 24.04| 18 | |LiteSpeed|[Latest stable version](https://www.litespeedtech.com/products/litespeed-web-server/download)| 19 | |PHP|[Latest stable version](http://rpms.litespeedtech.com/debian/)| 20 | 21 | ## Usage 22 | ### Downloading an image 23 | Download the litespeed image, we can use latest for latest version 24 | ``` 25 | docker pull litespeedtech/litespeed:latest 26 | ``` 27 | or specify the LiteSpeed version with lsphp version 28 | ``` 29 | docker pull litespeedtech/litespeed:6.2.2-lsphp83 30 | ``` 31 | ### Starting a Container 32 | ``` 33 | docker run --name litespeed -p 7080:7080 -p 80:80 -p 443:443 -it litespeedtech/litespeed:latest 34 | ``` 35 | You can also run with Detached mode, like so: 36 | ``` 37 | docker run -d --name litespeed -p 7080:7080 -p 80:80 -p 443:443 -it litespeedtech/litespeed: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 | Note: The container will auto-apply a 15-day trial license. Please contact LiteSpeed to extend the trial, or apply your own license, [starting from $0](https://www.litespeedtech.com/pricing). 42 | 43 | ### Adding a sample page 44 | 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: 45 | ``` 46 | docker exec -it litespeed bash 47 | ``` 48 | 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. 49 | ``` 50 | echo ' localhost/html/index.php 51 | ``` 52 | 53 | ### Stopping a Container 54 | Feel free to substitute the "litespeed" to the "Container_ID" if you did not define any name for the container. 55 | ``` 56 | docker stop litespeed 57 | ``` 58 | 59 | ## Customization 60 | 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: 61 | 1. Download the dockerfile project 62 | 2. `cd` into the project directory 63 | 3. Edit the Dockerfile here if necessary 64 | 4. Build, feeling free to substitute server and PHP versions to fit your needs 65 | 66 | For example, 67 | ``` 68 | git clone https://github.com/litespeedtech/lsws-dockerfiles.git 69 | cd lsws-dockerfiles/template 70 | bash build.sh -L 6.2.2 -P lsphp83 71 | ``` 72 | 73 | ## Support & Feedback 74 | If you still have a question after using LiteSpeed Docker, you have a few options. 75 | * Join [the GoLiteSpeed Slack community](https://litespeedtech.com/slack/) for real-time discussion 76 | * Post to [the LiteSpeed Forums](https://www.litespeedtech.com/support/forum/) for community support 77 | * Reporting any issue on [Github lsws-dockerfiles](https://github.com/litespeedtech/lsws-dockerfiles/issues) project 78 | 79 | **Pull requests are always welcome** -------------------------------------------------------------------------------- /template/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:24.04 2 | ARG LSWS_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 tzdata cron -y 10 | 11 | COPY lsws-install.sh / 12 | RUN chmod +x /lsws-install.sh 13 | 14 | RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ 15 | bash /lsws-install.sh --lsws $LSWS_VERSION --arch x86_64; \ 16 | elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ 17 | bash /lsws-install.sh --lsws $LSWS_VERSION --arch aarch64; \ 18 | else \ 19 | echo "$TARGETPLATFORM is not supported"; \ 20 | fi 21 | 22 | RUN wget -O - https://repo.litespeed.sh | bash 23 | 24 | RUN apt-get install mysql-client $PHP_VERSION $PHP_VERSION-common $PHP_VERSION-mysql $PHP_VERSION-opcache \ 25 | $PHP_VERSION-curl $PHP_VERSION-imagick $PHP_VERSION-redis $PHP_VERSION-memcached $PHP_VERSION-intl -y 26 | 27 | RUN sed -i 's/memory_limit = 128M/memory_limit = 1024M/g' $PHPINI_PATH && \ 28 | sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 1024M/g' $PHPINI_PATH && \ 29 | sed -i 's/post_max_size = 8M/post_max_size = 1024M/g' $PHPINI_PATH && \ 30 | sed -i 's/max_execution_time = 30/max_execution_time = 300/g' $PHPINI_PATH 31 | 32 | RUN ["/bin/bash", "-c", "if [[ $PHP_VERSION == lsphp7* ]]; then apt-get install $PHP_VERSION-json -y; fi"] 33 | 34 | RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \ 35 | chmod +x wp-cli.phar && mv wp-cli.phar /usr/bin/wp && \ 36 | ln -s /usr/local/lsws/$PHP_VERSION/bin/php /usr/bin/php 37 | 38 | RUN wget -O - https://get.acme.sh | sh 39 | 40 | EXPOSE 7080 41 | ENV PATH="/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin" 42 | 43 | ADD docker.xml $LS_FD/conf/templates/docker.xml 44 | ADD setup_docker.sh $LS_FD/bin/setup_docker.sh 45 | ADD htpasswd $LS_FD/admin/conf/htpasswd 46 | 47 | RUN $LS_FD/bin/setup_docker.sh $PHP_VERSION && rm $LS_FD/bin/setup_docker.sh 48 | RUN chown 994:994 $LS_FD/conf -R 49 | RUN cp -RP $LS_FD/conf/ $LS_FD/.conf/ 50 | RUN cp -RP $LS_FD/admin/conf $LS_FD/admin/.conf/ 51 | RUN ["/bin/bash", "-c", "if [[ $PHP_VERSION == lsphp8* ]]; then ln -sf $LS_FD/$PHP_VERSION/bin/lsphp $LS_FD/fcgi-bin/lsphp8; fi"] 52 | RUN ["/bin/bash", "-c", "if [[ $PHP_VERSION == lsphp8* ]]; then ln -sf $LS_FD/fcgi-bin/lsphp8 $LS_FD/fcgi-bin/lsphp; fi"] 53 | RUN ["/bin/bash", "-c", "if [[ $PHP_VERSION == lsphp7* ]]; then ln -sf $LS_FD/$PHP_VERSION/bin/lsphp $LS_FD/fcgi-bin/lsphp7; fi"] 54 | RUN ["/bin/bash", "-c", "if [[ $PHP_VERSION == lsphp7* ]]; then ln -sf $LS_FD/fcgi-bin/lsphp7 $LS_FD/fcgi-bin/lsphp; fi"] 55 | COPY entrypoint.sh /entrypoint.sh 56 | RUN chmod +x /entrypoint.sh 57 | ENTRYPOINT ["/entrypoint.sh"] 58 | WORKDIR /var/www/vhosts/ -------------------------------------------------------------------------------- /template/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | LSWS_VERSION='' 3 | PHP_VERSION='' 4 | PUSH='' 5 | CONFIG='' 6 | TAG='' 7 | BUILDER='litespeedtech' 8 | REPO='litespeed' 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 '-L, --lsws [VERSION] -P, --php [lsphpVERSION]' 21 | echo "${EPACE}${EPACE}Example: bash build.sh --lsws 6.3.1 --php lsphp83" 22 | echow '--push' 23 | echo "${EPACE}${EPACE}Example: build.sh --lsws 6.3.1 --php lsphp83 --push, will push to the dockerhub" 24 | echow '--arch' 25 | echo "${EPACE}${EPACE}Example: build.sh --lsws 6.3.1 --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 "${1} ${2}" 40 | #docker build . --tag ${BUILDER}/${REPO}:${1}-${2} --build-arg LSWS_VERSION=${1} --build-arg PHP_VERSION=${2} 41 | docker buildx build . --platform ${ARCH} --tag ${BUILDER}/${REPO}:${1}-${2} --build-arg LSWS_VERSION=${1} --build-arg PHP_VERSION=${2} --output=type=registry 42 | fi 43 | } 44 | 45 | test_image(){ 46 | ID=$(docker run -d ${BUILDER}/${REPO}:${1}-${2}) 47 | sleep 1 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 >/dev/null ' 51 | 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 | push_image(){ 66 | if [ ! -z "${PUSH}" ]; then 67 | if [ -f ~/.docker/litespeedtech/config.json ]; then 68 | CONFIG=$(echo --config ~/.docker/litespeedtech) 69 | fi 70 | #docker ${CONFIG} push ${BUILDER}/${REPO}:${1}-${2} 71 | if [ -z "${TAG}" ]; then 72 | docker buildx build . --platform ${ARCH} --tag ${BUILDER}/${REPO}:${1}-${2} --build-arg LSWS_VERSION=${1} --build-arg PHP_VERSION=${2} --output=type=registry --push 73 | else 74 | #docker tag ${BUILDER}/${REPO}:${1}-${2} ${BUILDER}/${REPO}:${3} 75 | #docker ${CONFIG} push ${BUILDER}/${REPO}:${3} 76 | docker buildx build . --platform ${ARCH} --tag ${BUILDER}/${REPO}:${3} --build-arg LSWS_VERSION=${1} --build-arg PHP_VERSION=${2} --output=type=registry --push 77 | fi 78 | else 79 | echo 'Skip Push.' 80 | fi 81 | } 82 | 83 | main(){ 84 | build_image ${LSWS_VERSION} ${PHP_VERSION} 85 | test_image ${LSWS_VERSION} ${PHP_VERSION} 86 | push_image ${LSWS_VERSION} ${PHP_VERSION} ${TAG} 87 | } 88 | 89 | check_input ${1} 90 | while [ ! -z "${1}" ]; do 91 | case ${1} in 92 | -[hH] | -help | --help) 93 | help_message 94 | ;; 95 | -[lL] | -lsws | --lsws) shift 96 | check_input "${1}" 97 | LSWS_VERSION="${1}" 98 | ;; 99 | -[pP] | -php | --php) shift 100 | check_input "${1}" 101 | PHP_VERSION="${1}" 102 | ;; 103 | -[tT] | -tag | -TAG | --tag) shift 104 | TAG="${1}" 105 | ;; 106 | -[aA] | -arch | --arch) shift 107 | check_input "${1}" 108 | ARCH="${1}" 109 | ;; 110 | --push ) 111 | PUSH=true 112 | ;; 113 | *) 114 | help_message 115 | ;; 116 | esac 117 | shift 118 | done 119 | 120 | main 121 | -------------------------------------------------------------------------------- /template/docker.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | /var/www/vhosts/$VH_NAME/ 4 | $SERVER_ROOT/conf/$VH_NAME.xml 5 | 1 6 | 1 7 | 1 8 | 2 9 | 0 10 | 11 | $VH_ROOT/html/ 12 | 1 13 | 14 | 15 | 1 16 | 17 | 18 | 0 19 | $SERVER_ROOT/logs/$VH_NAME.access.log 20 | 100M 21 | 7 22 | 1 23 | 24 | 25 | 26 | 0 27 | index.html, index.php 28 | 0 29 | /_autoindex/default.php 30 | 31 | 32 | 33 | php 34 | lsapi 35 | $VH_NAME_lsphp 36 | 37 | 38 | 39 | 31 40 | .htaccess 41 | 42 | 43 | 1 44 | 45 | 46 | 47 | 0 48 | gif, jpeg, jpg 49 | 1 50 | 1 51 | 52 | 53 | * 54 | 55 | 56 | 57 | 7 58 | 59 | /var/www/vhosts/lscache/ 60 | 1 61 | 62 | 63 | 1 64 | 65 | 66 | 67 | 68 | lsapi 69 | $VH_NAME_lsphp 70 |
uds://tmp/lshttpd/$VH_NAME_lsphp.sock
71 | 35 72 | PHP_LSAPI_CHILDREN=35 73 | LSAPI_AVOID_FORK=200M 74 | 60 75 | 0 76 | 0 77 | 1 78 | /usr/local/lsws/fcgi-bin/lsphp 79 | 100 80 | 1 81 | -1 82 | 0 83 | 84 | 85 | 86 | 87 |
88 |
89 | 90 | 1 91 | 0 92 | 93 | 94 | 95 | /root/.acme.sh/certs/$VH_NAME_ecc/$VH_NAME.key 96 | /root/.acme.sh/certs/$VH_NAME_ecc/fullchain.cer 97 | 1 98 | 99 | 100 | 0 101 | 0 102 | 103 | 104 | 0 105 | $VH_ROOT/awstats 106 | /awstats/ 107 | localhost 108 | 127.0.0.1 localhost 109 | 86400 110 | 0 111 | 112 |
113 |
114 | -------------------------------------------------------------------------------- /template/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | LSDIR='/usr/local/lsws' 3 | 4 | if [ -z "$(ls -A -- "${LSDIR}/conf/")" ]; then 5 | cp -R ${LSDIR}/.conf/* ${LSDIR}/conf/ 6 | fi 7 | if [ -z "$(ls -A -- "${LSDIR}/admin/conf/")" ]; then 8 | cp -R ${LSDIR}/admin/.conf/* ${LSDIR}/admin/conf/ 9 | fi 10 | if [ ! -e ${LSDIR}/conf/serial.no ] && [ ! -e ${LSDIR}/conf/license.key ]; then 11 | rm -f ${LSDIR}/conf/trial.key* 12 | wget -P ${LSDIR}/conf/ http://license.litespeedtech.com/reseller/trial.key 13 | fi 14 | chown 994:994 ${LSDIR}/conf/ -R 15 | chown 994:1001 ${LSDIR}/admin/conf/ -R 16 | 17 | /usr/local/lsws/bin/lswsctrl start 18 | $@ 19 | while true; do 20 | if ! ${LSDIR}/bin/lswsctrl status | grep 'litespeed is running with PID *' > /dev/null; then 21 | break 22 | fi 23 | sleep 60 24 | done -------------------------------------------------------------------------------- /template/htpasswd: -------------------------------------------------------------------------------- 1 | admin:$1$RaqgGtmd$81EhmoqpWhiJJtCDRp0FX/ -------------------------------------------------------------------------------- /template/lsws-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | USER='nobody' 3 | GROUP='nogroup' 4 | ADMIN_PASS='litespeed' 5 | LSDIR='/usr/local/lsws' 6 | LSWS_MAIN='6' 7 | LSWS_VERSION='' 8 | EPACE=' ' 9 | ARCH='x86_64' 10 | 11 | echow(){ 12 | FLAG=${1} 13 | shift 14 | echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}" 15 | } 16 | 17 | help_message(){ 18 | echo -e "\033[1mOPTIONS\033[0m" 19 | echow '-L, --lsws [VERSION]' 20 | echo "${EPACE}${EPACE}Example: bash lsws_install.sh --lsws 6.3.1" 21 | echow '--arch' 22 | echo "${EPACE}${EPACE}Example: build.sh --lsws 6.3.1 --arch [x86_64|aarch64], will build image for amd64 or arm64" 23 | exit 0 24 | } 25 | 26 | check_input(){ 27 | if [ -z "${1}" ]; then 28 | help_message 29 | fi 30 | } 31 | 32 | basic_install(){ 33 | apt-get update && apt-get install net-tools apt-utils openssl -y 34 | } 35 | 36 | add_trial(){ 37 | wget -q --no-check-certificate http://license.litespeedtech.com/reseller/trial.key 38 | } 39 | 40 | del_trial(){ 41 | rm -f ${LSDIR}/conf/trial.key* 42 | } 43 | 44 | get_main_ver(){ 45 | LSWS_MAIN=${LSWS_VERSION:0:1} 46 | } 47 | 48 | lsws_download(){ 49 | wget -q --no-check-certificate https://www.litespeedtech.com/packages/${LSWS_MAIN}.0/lsws-${LSWS_VERSION}-ent-${ARCH}-linux.tar.gz 50 | tar xzf lsws-*-ent-${ARCH}-linux.tar.gz && rm -f lsws-*.tar.gz 51 | cd lsws-${LSWS_VERSION} 52 | add_trial 53 | } 54 | 55 | 56 | update_install(){ 57 | sed -i '/^license$/d' install.sh 58 | sed -i 's/read TMPS/TMPS=0/g' install.sh 59 | sed -i 's/read TMP_YN/TMP_YN=N/g' install.sh 60 | } 61 | 62 | update_function(){ 63 | sed -i '/read [A-Z]/d' functions.sh 64 | sed -i 's/HTTP_PORT=$TMP_PORT/HTTP_PORT=8080/g' functions.sh 65 | sed -i 's/ADMIN_PORT=$TMP_PORT/ADMIN_PORT=7080/g' functions.sh 66 | sed -i "/^license()/i\ 67 | PASS_ONE=${ADMIN_PASS}\ 68 | PASS_TWO=${ADMIN_PASS}\ 69 | TMP_USER=${USER}\ 70 | TMP_GROUP=${GROUP}\ 71 | TMP_PORT=''\ 72 | TMP_DEST=''\ 73 | ADMIN_USER=''\ 74 | ADMIN_EMAIL='' 75 | " functions.sh 76 | } 77 | 78 | gen_selfsigned_cert(){ 79 | KEYNAME="${LSDIR}/admin/conf/webadmin.key" 80 | CERTNAME="${LSDIR}/admin/conf/webadmin.crt" 81 | openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ${KEYNAME} -out ${CERTNAME} </dev/null 2>&1 97 | } 98 | 99 | check_version(){ 100 | SERVERV=$(cat /usr/local/lsws/VERSION) 101 | echo "Version: ${SERVERV}" 102 | } 103 | 104 | run_install(){ 105 | echo 'Main LSWS install ...' 106 | /bin/bash install.sh >/dev/null 2>&1 107 | echo 'Main LSWS install finished !' 108 | } 109 | 110 | lsws_restart(){ 111 | ${LSDIR}/bin/lswsctrl start 112 | } 113 | 114 | check_input ${1} 115 | while [ ! -z "${1}" ]; do 116 | case ${1} in 117 | -[lL] | -lsws | --lsws) shift 118 | check_input "${1}" 119 | LSWS_VERSION="${1}" 120 | ;; 121 | -[aA] | -arch | --arch) shift 122 | check_input "${1}" 123 | ARCH="${1}" 124 | ;; 125 | *) 126 | help_message 127 | ;; 128 | esac 129 | shift 130 | done 131 | 132 | main(){ 133 | basic_install 134 | get_main_ver 135 | lsws_download 136 | update_install 137 | update_function 138 | run_install 139 | lsws_restart 140 | gen_selfsigned_cert 141 | rpm_install 142 | check_version 143 | del_trial 144 | } 145 | 146 | main ${1} ${2} -------------------------------------------------------------------------------- /template/setup_docker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | LS_FD='/usr/local/lsws' 3 | WEBCF="${LS_FD}/conf/httpd_config.xml" 4 | VHCF="${LS_FD}/conf/templates/docker.xml" 5 | PHP_VER='lsphp83' 6 | 7 | check_php_input(){ 8 | if [ -z "${1}" ]; then 9 | echo "Use default value ${PHP_VER}" 10 | else 11 | echo ${1} | grep lsphp >/dev/null 12 | if [ ${?} = 0 ]; then 13 | PHP_VER=${1} 14 | fi 15 | fi 16 | } 17 | 18 | cleanup_listener(){ 19 | echo 'Remove listeners' 20 | grep '' ${WEBCF} >/dev/null 2>&1 21 | if [ ${?} = 0 ]; then 22 | FIRST_LINE_NUM=$(grep -n -m 1 '' ${WEBCF} | awk -F ':' '{print $1}') 23 | LAST_LINE_NUM=$(grep -n '' ${WEBCF} | tail -n 1 | awk -F ':' '{print $1}') 24 | echo 'Remove the default listener from serevr config' 25 | sed -i "${FIRST_LINE_NUM},${LAST_LINE_NUM}d" ${WEBCF} 26 | else 27 | echo " does not found, skip!" 28 | fi 29 | } 30 | 31 | update_listener(){ 32 | sed -i '//a\ 33 | \ 34 | HTTP \ 35 |
*:80
\ 36 | 0 \ 37 |
\ 38 | \ 39 | HTTPS \ 40 |
*:443
\ 41 | 1 \ 42 | 1 \ 43 | /usr/local/lsws/admin/conf/webadmin.key \ 44 | /usr/local/lsws/admin/conf/webadmin.crt \ 45 |
46 | ' ${WEBCF} 47 | } 48 | 49 | update_template(){ 50 | sed -i '//a\ 51 | \ 52 | docker \ 53 | $SERVER_ROOT/conf/templates/docker.xml \ 54 | HTTP, HTTPS \ 55 | \ 56 | localhost \ 57 | *, localhost \ 58 | \ 59 | 60 | ' ${WEBCF} 61 | } 62 | 63 | php_path(){ 64 | if [ -f ${VHCF} ]; then 65 | sed -i "s/lsphpver/${1}/" ${VHCF} 66 | else 67 | echo 'docker.xml template not found!' 68 | exit 1 69 | fi 70 | } 71 | 72 | create_doc_fd(){ 73 | mkdir -p /var/www/vhosts/localhost/{html,logs,certs} 74 | chown 1000:1000 /var/www/vhosts/localhost/ -R 75 | } 76 | 77 | main(){ 78 | check_php_input ${1} 79 | php_path ${PHP_VER} 80 | cleanup_listener 81 | update_listener 82 | update_template 83 | create_doc_fd 84 | } 85 | main ${1} --------------------------------------------------------------------------------