Introduction
This article depicts, after a long time away from Aemi WordPress theme development, how to completely set up a local WordPress on XAMPP instance on macOS. This checklist provides me a clean and reliable way to have it working on all my Apple computers. I suppose it needs a bit of edit to convert it to Windows or Linux. Perhaps I’ll take time to do it later.
So below, you’ll find all the steps to make it work. If you have question, feel free to leave a comment.
Install WordPress
- Download WordPress latest version here
- Uncompress and move
wordpress
folder wherever you want
Install XAMPP
- Download it from official website
or
- Install it with Homebrew by running
brew install xampp
inTerminal.app
Start XAMPP
- From
Terminal.app
, you can run command:sudo /Applications/XAMPP/xamppfiles/xampp start
. - Alternatively, you can just open
manager-osx
app in Applications folder and start from there.
Create a new Database User
- Go to
https://localhost/phpmyadmin
. - Go to
User Accounts
tab. Click onAdd user account
. - Fill user name.
- Fill password.
- Tick
Grant all privileges on wildcard name (username\_%).
- Tick
Check all
forGlobal privileges
part. - Click on
Go
button at bottom.
Then:
- Go to
User Accounts
tab. Click onAdd user account
. - Fill the same user name.
- Fill the same password.
- Change
Host name
tolocalhost
or127.0.0.1
. - Tick
Grant all privileges on wildcard name (username\_%).
- Tick
Check all
forGlobal privileges
part. - Click on
Go
button at bottom.
Create a DB
- Go to
Databases
tab. - Fill
Database name
. - You can let encoding set to
utf8mb4_general_ci
. - Click
Create
.
Edit XAMPP PHP Config
- Go to
/Applications/XAMPP/xamppfiles/phpmyadmin/
. - Copy
config.inc.php
into a new fileconfig.inc.bak.php
. It is intended to be a save. - Open
config.inc.php
. Edit the following line:
$cfg['blowfish_secret'] = 'xampp';
...
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
...
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = true;
It should look like this after your edits:
$cfg['blowfish_secret'] = 'ESWs=88b3hN}B7:w?C.iA87+FJ5wT[&cf'; // Cryptographically random passphrase
...
$cfg['Servers'][$i]['user'] = '<same previously created user name>';
$cfg['Servers'][$i]['password'] = '<same previously created password>';
...
$cfg['Servers'][$i]['compress'] = true;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
Restart XAMPP
From command line or graphical interface.
Edit /etc/hosts
to add your local domain
- Add a custom local domain to
/etc/hosts
. - Open
/etc/hosts
in a code editor or IDE. - Add a new line like this one:
127.0.0.1 aemi.local
Create local certificates
- Install
[mkcert](https://github.com/FiloSottile/mkcert)
- You can use
brew install nss mkcert
- You can use
mkcert -install
- Create a
.ssl
directory in your user home folder.mkdir ~/.ssl
- Create certificate for your local domains:
mkcert --cert-file "/path/to/.ssl/cert.pem" --key-file "/path/to/.ssl/key.pem" "*.your.domain" your.domain localhost 127.0.0.1 ::1
Add virtual hosts to your XAMPP configuration
Enable Virtual Hosts support
- Go to
/Applications/XAMPP/xamppfiles/etc
. - Edit
httpd.conf
. - Change
User daemon
withUser <macOS session username>
. - Go to end of file and uncomment (remove starting
#
)Include etc/extra/httpd-vhosts.conf
.
Effectively add virtual hosts
- Go to
/Applications/XAMPP/xamppfiles/etc/extra
. - Edit
httpd-vhosts.conf
, add:
<VirtualHost *:80>
ServerName your.domain
DocumentRoot "/path/to/your/wordpress/installation"
<Directory "/path/to/your/wordpress/installation">
AllowOverride All
Require all granted
</Directory>
ServerAlias your.domain
</VirtualHost>
- Edit
httpd-ssl.conf
, add:
<VirtualHost *:443>
ServerName your.domain
DocumentRoot "/path/to/your/wordpress/installation"
<Directory "/path/to/your/wordpress/installation">
AllowOverride All
Require all granted
</Directory>
ServerAlias your.domain
SSLEngine on
SSLCertificateFile "/path/to/.ssl/cert.pem"
SSLCertificateKeyFile "/path/to/.ssl/key.pem"
</VirtualHost>
Restart XAMPP
Prepare WordPress Configuration
- Go to your
wordpress
folder. - Copy
wp-config-sample.php
into a new filewp-config.php
in the same directory. - Edit
wp-config.php
and update field with data we previously created: Database user name and password, database name… - Change the keys and salts to random character strings.
- Then change table prefix.
- Add the code below to
wp-config.php
:
define( 'WP_LOCAL_DEV', true );