In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
1. Download php-apache image
Do the following in the web server:
Docker pull php:7.2-apache
When the download is complete, use the docker images command to check the image in
2. Create scripts to generate mysql and httpd-php containers
In web:
Vim docker_web.sh
#! / bin/bash
Docker run-- name httpd-php-p 80:80\-v / data/docker/httpd/conf:/etc/apache2/sites-enabled\-v / data/docker/www:/var/www/html\-v / data/docker/httpd/logs:/var/log/apache2\-d php:7.2-apache
In mysql:
Vim docker_mysql.sh
#! / bin/bash
Docker run-- name mysql-p 3306 data/docker/mysql/data:/var/lib/mysql 3306\-v / data/docker/mysql/data:/var/lib/mysql\-v / data/docker/mysql/conf:/etc/mysql/conf.d\-v / data/docker/mysql/logs:/logs\
-e MYSQL_ROOT_PASSWORD=test123456\ # set the root password for mysql
-d mysql:latest-- character-set-server=utf8 # uses utf8 encoding
# Note that there are comments in the script that may cause an error docker: invalid reference format###
3. Start the mysql and httpd-php containers
In web:
Sh docker_web.sh
In mysql:
Sh docker_mysql.sh
4. Test the web server
Enter on the command line
Echo "" > / data/docker/www/index.php
Open a browser to access the ip address of the web server
5. Modify the password encryption method of mysql
Change the password encryption mode of mysql to mysql_native_password
Vim / data/docker/mysql/conf/docker_mysql.cnf
[mysqld] default-authentication-plugin=mysql_native_password
If the encryption method is not modified, the lower version of mysql client will report an error when logging in.
6. Database operation
Log in to the mysql container to create and configure wordpress database
Docker exec-it mysql / bin/bash mysql-uroot-ptest123456
Mysql > create database wordpress
Mysql > create user wps@localhost identified by '123456'
Mysql > grant all privileges on wordpress. To wps@localhost
Mysql > create user wps@192.168.8.126 identified by '123456'
Mysql > grant all privileges on wordpress. To wps@192.168.8.126
Mysql > alter user wps@192.168.8.126 identified with mysql_native_password by '123456'
Mysql > create user wps@192.168.8.127 identified by '123456'
Mysql > grant all privileges on wordpress.* to wps@192.168.8.127
Mysql > alter user wps@192.168.8.127 identified with mysql_native_password
By '123456'
Mysql > exit
7. Connection testing
In web1 and web2:
The mysql_connect () function is not recommended by PHP5.0 at the beginning, but it is discarded directly when it comes to php7.0, and the alternative function is mysqli_connect ().
Go to the mysql container and install the mysqli extension
Docker exec-it httpd-php / bin/bash
Apt-get update
Apt-get install libpng-dev
Cd / usr/local/bin/
. / docker-php-ext-install gd mysqli
. / docker-php-ext-enable gd mysqli
Exit
Docker restart httpd-php
Write a test php that connects to mysql
Vim / data/docker/www/con.php
Open a browser and enter 192.168.8.126/con.php
8. Download the wordpress blog system and configure
Wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
Tar-zxvf wordpress-4.9.4-zh_CN.tar.gz-C / data/docker/www/
Browsers access http://192.168.8.126/wordpress
As shown in the figure, note that the host writes ip to the virtual machine with mysql service installed.
After clicking submit, the following page will pop up and fill in as you want.
After clicking on the installation of WordPress, the successful installation page will pop up.
Landing
You can set up your own blog here!
9. Verify the wordpress database
Connect the database in the container of the mysql host:
Mysql-u root-ptest123456
Show database
Using the wordpress database
Display the tables in the wordpress database
Select everything in the wp_users table
You can see that you already have an lxc account.
10. Check the blog
Browsers access http://192.168.8.126/wordpress
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.