PhilippHeuer / wordpress-heroku

This project is a template for installing and running WordPress 5.x on Heroku.
MIT License
273 stars 316 forks source link

How setup local development? #8

Closed greyxp closed 7 years ago

greyxp commented 7 years ago

please describe how start local development with this template, for push to heroku later

PhilippHeuer commented 7 years ago

You can configure your local wordpress installation by adding a .env file in the directory root:

# DB Connection
CUSTOM_DB_URL=mysql://user:password@host:3306/databaseName

# WP Settings 
WP_ENV=development
WP_HOME=http://localhost
WP_SITEURL=${WP_HOME}/wp

# Generate your keys here: https://roots.io/salts.html
AUTH_KEY='generateme'
SECURE_AUTH_KEY='generateme'
LOGGED_IN_KEY='generateme'
NONCE_KEY='generateme'
AUTH_SALT='generateme'
SECURE_AUTH_SALT='generateme'
LOGGED_IN_SALT='generateme'
NONCE_SALT='generateme'

And then you can run it on any machine you have php installed on with WP CLI:

php wp-cli.phar server --host=localhost --port=80

You may have to install a database server locally, if you do not have any dedicated server and don't want to use heroku's.

Thanks for the issue, missed this part in the documentation.

If this didn't answer your question just respond here - closing it.

greyxp commented 7 years ago

Thanks for answer. Now I have a problem with the database. When install I choose "heroku addons:create cleardb:ignite" Locally i have mysql and create new db "wordpress" My "CUSTOM_DB_URL=mysql://root:root@localhost:3306/wordpress" When i start local server i have database connection error https://www.dropbox.com/s/ea71m5y0bc76l61/Screenshot%202017-06-15%2002.27.33.png?dl=0 Maybe I need to do something else to make everything work locally?

PhilippHeuer commented 7 years ago

I tested it locally, which worked fine with MySQL.

This error shows that it can't reach your mysql server at localhost:3306. Are you sure that it's 127.0.0.1 and the port is 3306 and that the service is reachable? Some packages use a non-default port.

It could also be caused by the deprecated mysql extension, since the mysqli extension is missing. Based on this error im guessing that you run PHP 5.5 or 5.6 without the mysqli extension, yes?

You can either install the mysqli extension or upgrade to PHP7 (which i recommend) - Both should fix your issue. Heroku is using PHP7 too.