How docker deploys lnmp-wordpress
This article mainly shows you "docker how to deploy lnmp-wordpress", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "docker how to deploy lnmp-wordpress" this article.
1. Experimental environment
System: centos7 ip:192.168.238.133
# turn off the firewall [root@localhost ~] # systemctl stop firewalld [root@localhost ~] # systemctl disable firewalld [root@localhost ~] # setenforce "add dns [root@localhost ~] # cat / etc/resolv.confnameserver 114.114.114.11" modify the hostname [root@localhost ~] # hostnamectl set-hostname docker-lnmp [root@localhost ~] # su II. Install docker source # install dependent environment [root@docker-lnmp ~] # yum install-y yum-utils device-mapper-persistent-data lvm2# install Ali docker source [root@docker-lnmp ~] # yum-config-manager-- add-repo source III. Install docker [root @ docker-lnmp ~] # yum install-y docker-ce # install community version [root@docker-lnmp ~] # systemctl enable docker# setup boot self-boot Created symlink from / etc/systemd/system/multi-user.target.wants/docker.service to / usr/lib/systemd/system/docker.service. [root@docker-lnmp ~] # systemctl start docke # enable service # create dockerfile directory [root@docker-lnmp ~] # mkdir docker & & cd docker# Dockerfile directory of MySQL and Nginx [root@docker-lnmp docker] # mkdir nginx mysql
Deploy Nginx and PHP1, upload / extract software packages and configuration files
# decompression package [root@docker-lnmp nginx] # tar zxvf wordpress-4.9.4-zh_ CN.tar.gz [root @ docker-lnmp nginx] # tar zxvf nginx-1.12.2.tar.gz [root@docker-lnmp nginx] # tar zxvf libmcrypt-2.5.7.tar.gz [root@docker-lnmp nginx] # tar zxvf php-5.5.38.tar.gz2, Create dockerfile file [root@docker-lnmp nginx] # vim DockerfileFROM docker.io/centos:7RUN yum-y updateRUN yum-y install gcc gcc-c++ openssl-devel openssl autoconf cmake autoconf zlib zlib-devel libtool pcre pcre-devel wget net-tools makeRUN groupadd-g 900 nginx & & useradd nginx-g nginx-s / sbin/nologinFROM docker.io/centos:7RUN yum-y updateRUN yum-y install gcc gcc-c++ openssl-devel openssl autoconf cmake autoconf zlib zlib-devel libtool pcre pcre-devel wget net-tools makeRUN groupadd-g 900 Nginx & useradd nginx- g nginx- s / sbin/nologinADD nginx-1.12.2 nginx-1.12.2RUN cd / nginx-1.12.2/ & &. / configure-- prefix=/usr/local/nginx-- with-http_dav_module-- with-http_stub_status_module-- with-http_addition_module-- with-http_sub_module-- with-http_flv_module-- with-http_mp4_module-- with-http_ssl_module -- with-http_gzip_static_module-- user=nginx-- group=nginxRUN cd / nginx-1.12.2/ & & make & & make installRUN ln-s / usr/local/nginx/sbin/nginx / usr/local/sbin/RUN sed-I '1afastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name '/ usr/local/nginx/conf/fastcgi_paramsADD nginx.conf / usr/local/nginx/conf/ADD wordpress / usr/local/nginx/html/wordpressADD wp-config.php / usr/local/nginx/html/wordpressRUN yum-y install gcc gcc-c++ libxml2-devel libcurl-devel openssl-devel bzip2-devel openssl automake make autoconf libtool zlib-devel make pcre-devel wget net-toolsADD libmcrypt-2.5.7 libmcrypt-2.5.7RUN cd libmcrypt-2.5.7/&&. / configure-- Prefix=/usr/local/libmcrypt & & make & & make installADD php-5.5.38 php-5.5.38RUN cd php-5.5.38/ &. / configure-- prefix=/usr/local/php5.5-- with-pdo-mysql=mysqlnd-- with-mysqli=mysqlnd-- with-openssl-- enable-fpm-- enable-sockets-- enable-sysvshm-- enable-mbstring-- with-freetype-dir-- with-jpeg-dir-- with-png-dir-- With-zlib-- with-libxml-dir=/usr-- enable-xml-- with-mhash-- with-mcrypt=/usr/local/libmcrypt-- with-config-file-path=/etc-- with-config-file-scan-dir=/etc/php.d-- with-bz2-- enable-maintainer-zts & & make & & make installRUN cd php-5.5.38 & cp php.ini-production / etc/php.iniRUN cd / php-5.5.38 & & cp sapi/fpm/init. D.php-fpm / etc/init.d/php-fpmRUN chmod + x / etc/init.d/php-fpm & & chkconfig-- add php-fpm & & chkconfig php-fpm onRUN cp / usr/local/php5.5/etc/php-fpm.conf.default / usr/local/php5.5/etc/php-fpm.confRUN sed-I's * Pid = run/php-fpm.pid*pid = run/php-fpm.pid*g' / usr/local/php5.5/etc/php-fpm.confRUN sed-I 's/user = nobody/user = nginx/g' / usr/local/php5.5/etc/php-fpm.confRUN sed-I' s/group = nobody/group = nginx/g' / usr/local/php5.5/etc/php-fpm.confRUN sed-I 's/pm.max_children = 5/pm .max _ children = 50 usr/local/php5.5/etc/php-fpm.confRUN sed g'/ usr/local/php5.5/etc/php-fpm.confRUN sed-I 's/pm.start_servers = 2/pm.start_servers = 5max g' / usr/local/php5.5/etc/php-fpm.confRUN sed-I 's/pm.min_spare_servers = 1/pm.min_spare_servers = 5max g' / usr/local/php5.5/etc/php-fpm.confRUN sed-I 's/pm. Max_spare_servers = 3/pm.max_spare_servers = 30max g'/ usr/local/php5.5/etc/php-fpm.confEXPOSE 9000EXPOSE 803, Build the image [root@docker-lnmp nginx] # docker build-t "centos:nginx-php".
View the list of images
4. Create the container and run [root@docker-lnmp nginx] # docker run-dit-p 80:80-m 500m-- memory-swap 1G 3efb4e2c79b5 / bin/bash49c5b69ce7012579f4b024ef6be88ff5de8057ccc7f81583fcf04f1c3ec6a79c
View a list of containers
5 、 Enable the service [root@docker-lnmp nginx] # docker exec-it 49c5b69ce701 / bin/bash [root@49c5b69ce701 /] # / etc/init.d/php-fpm start & & nginx [root@49c5b69ce701 /] # netstat-antp | grep phptcp 00 127.0.0.1it 49c5b69ce701 9000 0.0.0.0 * LISTEN 32/php-fpm: master [root@49c5b69ce701 /] # netstat-antp | grep nginxtcp 0 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 00. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0
Verify:
Deploy MySQL1 and create the dockerfile file of MySQL [root@docker-lnmp mysql] # vim DockerfileFROM docker.io/centos:7RUN yum-y install gcc gcc-c++ make autoconf make cmake wgetRUN groupadd mysql; useradd-r-M-u 3306-s / sbin/nologin-g mysql mysqlRUN mkdir / usr/local/mysql Mkdir / data/mysql-pvRUN yum install gcc gcc-c++ ncurses-devel bison bison-devel-yRUN wget-c http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.29.tar.gzRUN tar xf mysql-5.6.29.tar.gz-C / usr/local/src/WORKDIR / usr/local/src/mysql-5.6.29RUN cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data/mysql-DSYSCONFDIR=/etc-DMYSQL_TCP_PORT=3306-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MYISAM_STORAGE_ENGINE=1-DENABLED_LOCAL_INFILE=1-DWITH_PARTITION_STORAGE_ENGINE=1-DDEFAULT_CHARSET=utf8-DEXTRA_CHARSETS=all-DDEFAULT_COLLATION=utf8_general_ci-DWITH-MYSQLD-LDFLAGS=-all-static-DWITH-CLIENT-LD-FLAGS=-all-static-DWITH_DEBUG=0 & & Gmake & & gmake installRUN chown-R root:mysql / usr/local/mysql/ & & chown-R mysql:mysql / data/mysqlRUN chmod 755 / usr/local/src/mysql-5.6.29/scripts/mysql_install_db.shRUN / usr/local/src/mysql-5.6.29/scripts/mysql_install_db.sh-basedir=/usr/local/mysql-- datadir=/data/mysql-- no-defaults-- user=mysqlRUN cp / usr/local/src/mysql-5.6.29 / support-files/my-default.cnf / etc/my.cnfRUN cp / usr/local/src/mysql-5.6.29/support-files/mysql.server / etc/init.d/mysqldRUN chmod 775 / etc/init.d/mysqld & & / etc/init.d/mysqld startRUN echo-e'#! / bin/bash\ nexport PATH=$PATH:/usr/local/mysql/bin' > / etc/profile.d/mysql.shRUN source / etc/profileEXPOSE 33062, Build the image [root@docker-lnmp mysql] # docker build-t "centos:mysql-5.6".
View the list of images
3. Create the container and run [root@docker-lnmp mysql] # docker run-dit-p 3306 device-write-bps / dev/sda:10M 704e5b978518 / bin/bash960645a296e3e8795c344a8037b0641f8b5baf8e2214453214359071480c379d
View a list of containers
4. Start the service [root@docker-lnmp mysql] # docker exec-it 960645a296e3 / bin/bash [root@960645a296e3 mysql-5.6.29] # / etc/init.d/mysqld startStarting MySQL. SUCCESS!5 、 Database authorization # change password [root@960645a296e3 mysql-5.6.29] # mysql- uroot-p123456Warning: Using a password on the command line interface can be insecure.ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) [root@960645a296e3 mysql-5.6.29] # mysqladmin-uroot-p passwordEnter password: New password: Confirm new password: # authorization [root@960645a296e3 mysql-5.6.29] # mysql- uroot-p123456mysql > create database wordpress default charset utf8 COLLATE utf8_general_ci # create wordpress table Query OK, 1 row affected (0.00 sec) mysql > grant all privileges on wordpress.* to 'wordpress'@'%' identified by' 123456 'with grant option; # Authorization Query OK, 0 rows affected (0.00 sec) mysql > flush privileges; # Refresh permission Query OK, 0 rows affected (0.01 sec)
Visit: http://192.168.238.133/wordpress/index.php
These are all the contents of the article "how docker deploys lnmp-wordpress". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!