{"id":116,"date":"2023-08-05T08:16:46","date_gmt":"2023-08-05T08:16:46","guid":{"rendered":"http:\/\/it4home.dk\/?p=116"},"modified":"2023-08-06T09:11:34","modified_gmt":"2023-08-06T09:11:34","slug":"setting-up-wordpress-with-mariadb-using-docker","status":"publish","type":"post","link":"https:\/\/it4home.dk\/index.php\/2023\/08\/05\/setting-up-wordpress-with-mariadb-using-docker\/","title":{"rendered":"Setting Up WordPress with MariaDB Using Docker"},"content":{"rendered":"<div class=\"pdfprnt-buttons pdfprnt-buttons-post pdfprnt-top-right\"><a href=\"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/116?print=pdf\" class=\"pdfprnt-button pdfprnt-button-pdf\" target=\"_blank\" ><\/a><a href=\"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/116?print=print\" class=\"pdfprnt-button pdfprnt-button-print\" target=\"_blank\" ><img decoding=\"async\" src=\"https:\/\/it4home.dk\/wp-content\/plugins\/pdf-print\/images\/print.png\" alt=\"image_print\" title=\"Print Content\" \/><\/a><\/div>\n<p class=\"wp-block-paragraph\">Introduction:<br>WordPress is a popular content management system for building websites and blogs. In this guide, we&#8217;ll show you how to set up WordPress with MariaDB (MySQL database) using Docker, allowing you to easily create and manage your website.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Step 1: Install and Run MariaDB Container<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To install MariaDB and run it in Docker, use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -e MYSQL_ROOT_PASSWORD=wordpress -e MYSQL_DATABASE=wordpress \\\n  --name wordpressdb -v mariadb_data:\/var\/lib\/mysql -d mariadb:latest<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Explanation of options used:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>-e MYSQL_ROOT_PASSWORD=wordpress<\/code>: Set the root password for the MariaDB database to &#8220;wordpress&#8221;.<\/li>\n\n\n\n<li><code>-e MYSQL_DATABASE=wordpress<\/code>: Create a database named &#8220;wordpress&#8221; for the WordPress installation.<\/li>\n\n\n\n<li><code>--name wordpressdb<\/code>: Assign the name &#8220;wordpressdb&#8221; to the MariaDB container for easy management.<\/li>\n\n\n\n<li><code>-v mariadb_data:\/var\/lib\/mysql<\/code>: Create a Docker volume named &#8220;mariadb_data&#8221; and mount it to the &#8220;\/var\/lib\/mysql&#8221; directory inside the container. This volume allows you to persist MariaDB&#8217;s data.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Step 2: Install and Run WordPress Container<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To install WordPress and run it in Docker, use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=wordpress \\\n  --name wordpress --link wordpressdb:mysql -p 80:80 -v wordpress_data:\/var\/www\/html -d wordpress:latest<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Explanation of options used:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>-e WORDPRESS_DB_USER=root<\/code>: Set the WordPress database user to &#8220;root&#8221; (linked to the MariaDB container).<\/li>\n\n\n\n<li><code>-e WORDPRESS_DB_PASSWORD=wordpress<\/code>: Set the WordPress database password to &#8220;wordpress&#8221; (linked to the MariaDB container).<\/li>\n\n\n\n<li><code>--name wordpress<\/code>: Assign the name &#8220;wordpress&#8221; to the WordPress container for easy management.<\/li>\n\n\n\n<li><code>--link wordpressdb:mysql<\/code>: Link the WordPress container to the MariaDB container, allowing WordPress to connect to the database.<\/li>\n\n\n\n<li><code>-p 80:80<\/code>: Map port 80 from the container to port 80 on the host system. This allows you to access WordPress at <code>http:\/\/localhost<\/code>.<\/li>\n\n\n\n<li><code>-v wordpress_data:\/var\/www\/html<\/code>: Create a Docker volume named &#8220;wordpress_data&#8221; and mount it to the &#8220;\/var\/www\/html&#8221; directory inside the container. This volume allows you to persist WordPress&#8217;s data.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Conclusion:<br>By following these steps and using Docker, you have successfully set up WordPress with MariaDB on your system. You can now access and manage your WordPress website by visiting <code>http:\/\/localhost<\/code> in your web browser.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Enjoy creating and managing your WordPress website with ease using Docker! Happy blogging!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction:WordPress is a popular content management system for building websites and blogs. In this guide, we&#8217;ll show you how to set up WordPress with MariaDB (MySQL database) using Docker, allowing you to easily create&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":194,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[2],"tags":[35],"class_list":["post-116","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker","tag-ok"],"_links":{"self":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/comments?post=116"}],"version-history":[{"count":2,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/116\/revisions"}],"predecessor-version":[{"id":121,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/116\/revisions\/121"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/media\/194"}],"wp:attachment":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/media?parent=116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/categories?post=116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/tags?post=116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}