Attach your blog address
- blog.kele.red
The preparatory work
- A server (such as Ali Cloud ECS) or Choose Windows as the test environment of the blog
- A Docker environment is required on the server or Windows
First of all, why do we use docker to deploy our blog
- Docker is a containerization technology, which can package the environment required by a project into an image, and this image can be run directly on other servers or Windows to generate a container to start our project.
- Docker does not rely on our external environment (the external environment here refers to the host), because the environment needed for the project to run is already packaged in the image.
Who is the host of Docker
- Docker in fact, it is also an application, the application must be running on the basis of a certain environment, when running on the Linux server, Linux server is its host. On Windows, Windows is its host.
How to set up a blog on Windows
How to quickly install docker environment on Windows
- Visit docker at www.docker.com/get-started
- Select the Docker client installation environment, and select the Windows version
- Once the download is complete, it’s all the way to Next!
Deploy the mysql environment using Docker
Pull mysql5.7 mirror
- Execute the command
docker pull hub.c.163.com/library/mysql
Copy the code
- Using the Docker images command, you can see the images we pulled
Run the mysql image to generate the container
- Run the following command
docker run -p 23308:3306 --name mysql5 --restart always -v C:/dev/software/mysql-master5/conf:/etc/mysql/conf.d -v C:/dev/software/mysql-master5/logs:/var/logs -v C:/dev/software/mysql-master5/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=localDocker@mysql -d hub.c.163.com/library/mysql
Copy the code
- Command and dismantling
- Docker run: Runs the container prefix command
- -p: Specifies a port number for the container on the host. The port number on the left is the port number on the host (for external access), and the port number on the right is the port number of the mysql inside the container
- –restart always: starts the container when the host starts. (After Windows restarts, easy starts with it.)
- -v: indicates the directory to which the host is mounted. You can use this command to map dependent or output data inside a container to the directory on the host. Here, I have mounted the mysql configuration file, database data, and log directory to the host computer. After mysql runs, you can see the corresponding data under these directories. If you specify the mysql configuration file under the conf directory, the container will use that configuration file when it starts.
- -e MYSQL_ROOT_PASSWORD: initializes the database password
- -d: indicates the background startup container
- In the name of the mirror hub.c.163.com/library/mysql: need to generate container. The name of the image can be followed by commands such as: Hub.c.163.com/library/mysql:latest, by default without words is the latest, the corresponding is the mirror of the version number, if you are a mirror image of the corresponding TAG is the version number, this must be specified, For example, you pull a TAG is mysql 5.7 mirror, there should be a hub.c.163.com/library/mysql:5.7.
- Conf configuration file information
[mysqld]
## Handling mysql indicates case sensitivity
lower_case_table_names=1
Copy the code
View the container startup log
docker logs -f -t mysql5
Copy the code
- Command and dismantling
- Docker logs: Command prefix to view logs
- -f: Tracks the output of the log (that is, the output of the log is displayed)
- -t: displays the timestamp when viewing logs
- Mysql5: The container name specified when mysql is started
Use the remote connection tool to connect to mysql
The port number is the port number specified for the host when the container is created. The password is the password set when creating the container!
Pull typEcho blog image
- Execute the command
docker pull 80x86/typecho
Copy the code
Start the TypEcho blog image
docker run -d --name typecho-blog --restart always -e PHP_TZ=Asia/Shanghai -e PHP_MAX_EXECUTION_TIME=600 -v C:/dev/software/typecho-blog/themes:/app/usr/themes -p 28054:80 80x86/typecho:latest
Copy the code
- Command and dismantling
- -e PHP_TZ=Asia/Shanghai: Sets the time zone
- -e PHP_MAX_EXECUTION_TIME=600: Sets the maximum time for a single PHP request
- – v/usr/local/software/typecho – blog/themes: deposit blog theme directory, I mount it here, is to increase the new subject for the convenience of their.
C:/dev/software/typecho-blog/themes C:/dev/software/typecho-blog/themes C:/dev/software/typecho-blog/themes C:/dev/software/typecho-blog/themes C:/dev/software/typecho-blog/themes
Viewing startup Logs
Configure the blog
- Visit http://localhost:28054 to view the configuration page
- See the above interface, on behalf of your blog has run successfully!
- Configure the database
-
Here we select mysql database, enter the corresponding account password, and click OK
-
Enter the following interface, it indicates that our blog has been configured successfully!
Don’t panic, continue to read if you have any problems
- The following error appears after clicking here to view your Blog
- The error that caused this problem was our blog theme configuration problem
- When starting the image, we have mounted a directory for themes to the container. Now all you need to do is download the theme you need, unzip the zip file, and place the decompressed folder under the mounted theme directory.
- Download subject address: typecho. Me
- After placing the theme, click on the Access control panel
- Click change appearance