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
wordpressfolder wherever you want
Install XAMPP
- Download it from official website
or
- Install it with Homebrew by running
brew install xamppinTerminal.app
Start XAMPP
- From
Terminal.app, you can run command:sudo /Applications/XAMPP/xamppfiles/xampp start. - Alternatively, you can just open
manager-osxapp in Applications folder and start from there.
Create a new Database User
- Go to
https://localhost/phpmyadmin. - Go to
User Accountstab. Click onAdd user account. - Fill user name.
- Fill password.
- Tick
Grant all privileges on wildcard name (username\_%). - Tick
Check allforGlobal privilegespart. - Click on
Gobutton at bottom.
Then:
- Go to
User Accountstab. Click onAdd user account. - Fill the same user name.
- Fill the same password.
- Change
Host nametolocalhostor127.0.0.1. - Tick
Grant all privileges on wildcard name (username\_%). - Tick
Check allforGlobal privilegespart. - Click on
Gobutton at bottom.
Create a DB
- Go to
Databasestab. - 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.phpinto 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/hostsin 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
.ssldirectory 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 daemonwithUser <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
wordpressfolder. - Copy
wp-config-sample.phpinto a new filewp-config.phpin the same directory. - Edit
wp-config.phpand 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 );