Skip to content

Setup WordPress

Setup WordPress

This example installs WordPress 6.x from inside the Devilbox PHP container and serves it through a standard Devilbox virtual host.

example wordpress documentation

Overview

The following configuration will be used:

Project nameVirtualHost directoryDatabaseTLD_SUFFIXProject URL
my-wp/shared/httpd/my-wpmy_wplochttp://my-wp.loc br https://my-wp.loc

[!NOTE] Inside the Devilbox PHP container, projects are always in /shared/httpd/. On your host, projects are stored in ./data/www/ by default. This path can be changed via env-httpd-datadir.

Walk through

It will be ready in seven steps:

  1. Start Devilbox
  2. Enter the PHP container
  3. Create a new VirtualHost directory
  4. Download WordPress 6.x
  5. Symlink the webroot directory
  6. Create the MySQL database and DNS record
  7. Open WordPress in your browser

1. Start Devilbox

Terminal window
host> ./dvl.sh up

2. Enter the PHP container

All work will be done inside the PHP container:

Terminal window
host> ./dvl.sh shell

* enter-the-php-container * work-inside-the-php-container * available-tools

3. Create new vhost directory

The vhost directory defines the name under which your project will be available.

Terminal window
[email protected] in /shared/httpd $ mkdir my-wp
[email protected] in /shared/httpd $ cd my-wp

env-tld-suffix

4. Download WordPress 6.x

Use Git to download the current WordPress branch:

Terminal window
[email protected] in /shared/httpd/my-wp $ git clone --branch 6.8 https://github.com/WordPress/WordPress wordpress.git

How the directory structure looks after installation:

Terminal window
[email protected] in /shared/httpd/my-wp $ tree -L 1
.
└── wordpress.git
1 directory, 0 files

The web server expects every project document root in <vhost dir>/htdocs/. WordPress serves directly from the checkout directory, so symlink it to htdocs:

Terminal window
[email protected] in /shared/httpd/my-wp $ ln -s wordpress.git/ htdocs
Terminal window
[email protected] in /shared/httpd/my-wp $ tree -L 1
.
├── wordpress.git
└── htdocs -> wordpress.git
2 directories, 0 files

6. Database and DNS record

Create the WordPress database:

Terminal window
[email protected] in /shared/httpd/my-wp $ mysql -u root -h 127.0.0.1 -p -e 'CREATE DATABASE my_wp;'

If Auto DNS is configured you can skip the hosts entry. Otherwise add this line to your host operating system’s hosts file:

Terminal window
127.0.0.1 my-wp.loc
  • howto-add-project-hosts-entry-on-mac
  • howto-add-project-hosts-entry-on-win
  • setup-auto-dns

7. Open your browser

Open http://my-wp.loc or https://my-wp.loc and follow the WordPress setup:

  1. Choose a language.
  2. Enter database name my_wp, user root, your database password, and host 127.0.0.1.
  3. Run the installation.
  4. Create the site title and administrator account.
  5. Log in to the WordPress admin panel.

Next steps

Use bundled batteries

* devilbox-intranet-adminer * devilbox-intranet-phpmyadmin * devilbox-intranet-phppgadmin * devilbox-intranet-phpredmin * devilbox-intranet-phpmemcachedadmin

Enhance the Devilbox

* setup-valid-https * setup-auto-dns * configure-php-xdebug

Add services

  • custom-container-enable-blackfire
  • custom-container-enable-rabbitmq
  • custom-container-enable-solr
  • custom-container-enable-varnish