You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

190 lines
7.1 KiB

5 years ago
# OpenLiteSpeed WordPress Docker Container
5 years ago
[![Build Status](https://travis-ci.com/litespeedtech/ols-docker-env.svg?branch=master)](https://hub.docker.com/r/litespeedtech/openlitespeed)
5 years ago
[![docker pulls](https://img.shields.io/docker/pulls/litespeedtech/openlitespeed?style=flat&color=blue)](https://hub.docker.com/r/litespeedtech/openlitespeed)
5 years ago
[<img src="https://img.shields.io/badge/slack-LiteSpeed-blue.svg?logo=slack">](litespeedtech.com/slack)
[<img src="https://img.shields.io/twitter/follow/litespeedtech.svg?label=Follow&style=social">](https://twitter.com/litespeedtech)
5 years ago
5 years ago
Install a lightweight WordPress container with OpenLiteSpeed Edge or Stable version based on Ubuntu 18.04 Linux.
5 years ago
### Prerequisites
1. [Install Docker](https://www.docker.com/)
2. [Install Docker Compose](https://docs.docker.com/compose/)
## Configuration
5 years ago
Edit the `.env` file to update the demo site domain, default MySQL user, and password.
5 years ago
Feel free to check [Docker hub Tag page](https://hub.docker.com/repository/docker/litespeedtech/openlitespeed/tags) if you want to update default openlitespeed and php versions.
5 years ago
## Installation
5 years ago
Clone this repository or copy the files from this repository into a new folder:
```
git clone https://github.com/litespeedtech/ols-docker-env.git
```
5 years ago
Open a terminal, `cd` to the folder in which `docker-compose.yml` is saved, and run:
5 years ago
```
docker-compose up
```
5 years ago
5 years ago
Note: If you wish to run a single web server container, please see the [usage method here](https://github.com/litespeedtech/ols-dockerfiles#usage).
5 years ago
5 years ago
## Components
5 years ago
The docker image installs the following packages on your system:
5 years ago
5 years ago
|Component|Version|
| :-------------: | :-------------: |
|Linux|Ubuntu 18.04|
|OpenLiteSpeed|[Latest version](https://openlitespeed.org/downloads/)|
5 years ago
|MariaDB|[Stable version: 10.3](https://hub.docker.com/_/mariadb)|
5 years ago
|PHP|[Latest version](http://rpms.litespeedtech.com/debian/)|
5 years ago
|LiteSpeed Cache|[Latest from WordPress.org](https://wordpress.org/plugins/litespeed-cache/)|
5 years ago
|ACME|[Latest from ACME official](https://github.com/acmesh-official/get.acme.sh)|
5 years ago
|WordPress|[Latest from WordPress](https://wordpress.org/download/)|
5 years ago
|phpMyAdmin|[Latest from dockerhub](https://hub.docker.com/r/bitnami/phpmyadmin/)|
5 years ago
5 years ago
## Data Structure
5 years ago
Cloned project
```bash
├── acme
├── bin
│   └── container
├── data
│   └── db
├── logs
│   ├── access.log
│   ├── error.log
│   ├── lsrestart.log
│   └── stderr.log
├── lsws
│   ├── admin-conf
│   └── conf
5 years ago
├── sites
5 years ago
│ └── localhost
├── LICENSE
├── README.md
5 years ago
└── docker-compose.yml
```
5 years ago
5 years ago
* `acme` contains all applied certificates from Lets Encrypt
5 years ago
5 years ago
* `bin` contains multiple CLI scripts to allow you add or delete virtual hosts, install applications, upgrade, etc
5 years ago
5 years ago
* `data` stores the MySQL database
5 years ago
5 years ago
* `logs` contains all of the web server logs and virtual host access logs
5 years ago
5 years ago
* `lsws` contains all web server configuration files
5 years ago
5 years ago
* `sites` contains the document roots (the WordPress application will install here)
5 years ago
5 years ago
## Usage
5 years ago
### Starting a Container
Start the container with the `up` or `start` methods:
5 years ago
```
docker-compose up
```
5 years ago
You can run with daemon mode, like so:
5 years ago
```
docker-compose up -d
```
5 years ago
The container is now built and running.
### Stopping a Container
5 years ago
```
docker-compose stop
```
5 years ago
### Removing Containers
To stop and remove all containers, use the `down` command:
5 years ago
```
docker-compose down
```
5 years ago
### Setting the WebAdmin Password
We strongly recommend you set your personal password right away.
5 years ago
```
5 years ago
bash bin/webadmin.sh my_password
5 years ago
```
5 years ago
### Starting a Demo Site
5 years ago
After running the following command, you should be able to access the WordPress installation with the configured domain. By default the domain is http://localhost.
5 years ago
```
bash bin/demosite.sh
```
5 years ago
### Creating a Domain and Virtual Host
5 years ago
```
5 years ago
bash bin/domain.sh [-A, --add] example.com
5 years ago
```
5 years ago
> Please ignore SSL certificate warnings from the server. They happen if you haven't applied the certificate.
5 years ago
### Deleting a Domain and Virtual Host
```
5 years ago
bash bin/domain.sh [-D, --del] example.com
5 years ago
```
5 years ago
### Creating a Database
You can either automatically generate the user, password, and database names, or specify them. Use the following to auto generate:
5 years ago
```
5 years ago
bash bin/database.sh [-D, --domain] example.com
5 years ago
```
5 years ago
Use this command to specify your own names, substituting `user_name`, `my_password`, and `database_name` with your preferred values:
5 years ago
```
5 years ago
bash bin/database.sh [-D, --domain] example.com [-U, --user] USER_NAME [-P, --password] MY_PASS [-DB, --database] DATABASE_NAME
5 years ago
```
5 years ago
### Installing a WordPress Site
To preconfigure the `wp-config` file, run the `database.sh` script for your domain, before you use the following command to install WordPress:
5 years ago
```
5 years ago
./bin/appinstall.sh [-A, --app] wordpress [-D, --domain] example.com
5 years ago
```
### Install ACME
5 years ago
We need to run the ACME installation command the **first time only**.
With email notification:
5 years ago
```
5 years ago
./bin/acme.sh [-I, --install] [-E, --email] EMAIL_ADDR
5 years ago
```
5 years ago
Without email notification:
5 years ago
```
5 years ago
./bin/acme.sh [-I, --install] [-NE, --no-email]
5 years ago
```
5 years ago
### Applying a Let's Encrypt Certificate
Use the root domain in this command, and it will check for a certificate and automatically apply one with and without `www`:
5 years ago
```
5 years ago
./bin/acme.sh [-D, --domain] example.com
5 years ago
```
5 years ago
### Update Web Server
5 years ago
To upgrade the web server to latest stable version, run the following:
5 years ago
```
5 years ago
bash bin/webadmin.sh [-U, --upgrade]
5 years ago
```
5 years ago
### Apply OWASP ModSecurity
5 years ago
Enable OWASP `mod_secure` on the web server:
5 years ago
```
5 years ago
bash bin/webadmin.sh [-M, --mod-secure] enable
5 years ago
```
5 years ago
Disable OWASP `mod_secure` on the web server:
5 years ago
```
5 years ago
bash bin/webadmin.sh [-M, --mod-secure] disable
5 years ago
```
5 years ago
>Please ignore ModSecurity warnings from the server. They happen if some of the rules are not supported by the server.
5 years ago
### Accessing the Database
5 years ago
After installation, you can use phpMyAdmin to access the database by visiting `http://127.0.0.1:8080` or `https://127.0.0.1:8443`. The default username is `root`, and the password is the same as the one you supplied in the `.env` file.
5 years ago
5 years ago
## Customization
If you want to customize the image by adding some packages, e.g. `lsphp74-pspell`, just extend it with a Dockerfile.
1. We can create a `custom` folder and a `custom/Dockerfile` file under the main project.
2. Add the following example code to `Dockerfile` under the custom folder
```
FROM litespeedtech/openlitespeed:latest
RUN apt-get update && apt-get install lsphp74-pspell -y
5 years ago
```
3. Add `build: ./custom` line under the "image: litespeedtech" of docker-composefile. So it will looks like this
```
litespeed:
image: litespeedtech/openlitespeed:${OLS_VERSION}-${PHP_VERSION}
build: ./custom
```
4. Build and start it with command:
```
docker-compose up --build
```
5 years ago
## Support & Feedback
If you still have a question after using OpenLiteSpeed Docker, you have a few options.
4 years ago
* Join [the GoLiteSpeed Slack community](https://litespeedtech.com/slack) for real-time discussion
5 years ago
* Post to [the OpenLiteSpeed Forums](https://forum.openlitespeed.org/) for community support
* Reporting any issue on [Github ols-docker-env](https://github.com/litespeedtech/ols-docker-env/issues) project
**Pull requests are always welcome**