Code Monkey home page Code Monkey logo

wordpress-heroku-php's Introduction

How to setup WordPress on Heroku with the Heroku Buildpack for PHP

This will set up a fresh WordPress install on Heroku with the newly released Heroku Buildpack for PHP.

  • nginx - Nginx for serving web content.
  • PHP - PHP-FPM for process management.
  • WordPress - Downloaded from the Github WordPress Repo.
  • MySQL - ClearDB for the MySQL backend.
  • Sendgrid - Sendgrid for the email backend.
  • MemCachier - MemCachier for the memcached backend.
  • New Relic- Monitoring

Getting started

Use the Deploy to Heroku button, or use the old fashioned way described below.

Deploy

Clone this repository into a new directory.

Create your Heroku app.

heroku apps:create application-name --stack cedar --buildpack https://github.com/heroku/heroku-buildpack-php --region eu

--region eu is for deploying your app in the European region.

or on to add this buildpack to an existing app, run

heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php

Before you push to Heroku make sure to add the following add-ons.

heroku addons:add cleardb
heroku addons:add sendgrid
heroku addons:add memcachier
heroku addons:add papertrail
heroku addons:add newrelic

Define your AWS keys for the AWS S3 Media Uploader plugin.

heroku config:set AWS_ACCESS_KEY_ID=123
heroku config:set AWS_SECRET_ACCESS_KEY=123

Some default configurations. WP_CACHE=true will enable Batcache with the Memcachier addon.

heroku config:set DISABLE_WP_CRON=true
heroku config:set WP_CACHE=true

Deploy your WordPress site to Heroku.

git add .
git commit -am "Initial commit"
git push heroku master

Overview

└── public                 # Heroku webroot
    ├── content            # The wp-content directory. Renamed to content to avoid confusion with wp-content - and it looks prettier
    │   ├── plugins        # Plugins
    │   ├── mu-plugins     # Required plugins
    │   └── themes         # Your custom themes
    │
    └── wp                 # Where the actual WordPress install will be installed by Composer

Upgrade WordPress

Update the version number for the WordPress package in composer.json, then run composer update and commit the changes in composer.json and composer.lock. Do not upgrade WordPress from the admin-interface as it will not survive a restart or dyno change.

Setup local development

Make sure you have Composer installed first, then run

composer install

Create a local .env file.

CLEARDB_DATABASE_URL=mysql://root:[email protected]/my_wordpress_heroku_database_name

or install the heroku config plugin from https://github.com/ddollar/heroku-config and pull your environment variables from Heroku. The second option is to use the provided local-sample-config.php and rename it local-config.php. Update it with your local MySQL credentials, and you're good to go.

NOTE: If you don't have a command-line mysql accessible and working, Mac/Homebrew users can brew install mysql and then follow the directions to have launchd start mysql at login. I believe the default username is root and the default password is blank.

Install PHP 5.5 on Mac OS X with Homebrew if you don't already have it installed.

brew install --with-fpm php55

Follow the instructions in the output to complete the setup. Most importantly check your .bash_profile or .zshrc and make sure you've set your paths correctly.

brew install php55-mcrypt
brew install nginx

Open a new shell and run php -v and php-fpm -v and make sure they both read PHP 5.5… If you're still on PHP 5.4 then check your paths again. Make sure /usr/local/sbin is before /usr/sbin in your PATH:

Mountain Lion comes with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH:

PATH="/usr/local/sbin:$PATH"

Add this below Heroku Toolbelt setting in .bashrc or .bash_profile to swap the PHP you use on the command line.

export PATH="$(brew --prefix homebrew/php/php55)/bin:$PATH"

Now to start your local dev environment run to start WordPress on http://localhost:5000/

foreman start

If you don't have foreman installed, you can do so with gem install foreman assuming you have Ruby running on your system. If it fails, try adding sudo in front of the command.

Known Issues

If you try to develop locally without syncing your external MemCachier envvars you might see a 500 error or a You do not have sufficient permissions to access this page. - message. Workaround is to simply remove object-cache.php and advanced-cache.php from the content dir while doing local dev. In a future release I'll try to have these files added on deploy with Composer.

Sources

This would not have been possible without the work and resources provided by the following people:

wordpress-heroku-php's People

Contributors

ellefsen avatar jerinjacob1999 avatar magnobiet avatar sbstjn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

wordpress-heroku-php's Issues

Compatibility with php-fpm7.0 ?

When I try to run foreman for local instanse I got:

'02:04:59 web.1  | started with pid 21960
02:04:59 web.1  | Usage: /etc/init.d/php-fpm7.0 {start|stop|status|restart|reload|force-reload}
02:04:59 web.1  | This program requires PHP 5.5.11 or newer; check your 'php-fpm' command.
02:04:59 web.1  | exited with code 1
02:04:59 system | sending SIGTERM to all processes

How to add plugins and themes?

Hello, I just deployed an app with this Heroku button and now I'm trying to install plugins and themes.

However, when I heroku git:clone -a my-app, the Heroku CLI tells me that it appears that I have cloned an empty repository. My attempt here was to clone the heroku repository and add my theme in the Wordpress configuration, but it seems to be that is not the way.

Please help me solve this :) ty

Clarify readme

The readme states

Add this below Heroku Toolbelt setting to swap the PHP you use on the command line.

export PATH="$(brew --prefix homebrew/php/php55)/bin:$PATH"

I don't quite understand what I'm supposed to do. Can you clarify a little?

XML Sitemap Rewrite Issue

I have installed a plugin to generate sitemap, but it saying "Since you are using Nginx as your web-server, please configure the following rewrite rules in case you get 404 Not Found errors for your sitemap:"

rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;

Can someone guide me how to setup these rewrite rules?

App crashes when I try to log in

I installed the app and created a user. When I click Log In the app crashed. Here are the logs:

2016-12-13T21:24:50.484145+00:00 heroku[router]: at=info method=GET path="/wp/wp-login.php" host=testtest-wordpress.herokuapp.com request_id=febc36ad-a4d7-4eba-acd6-654c1e7e72bf fwd="78.52.131.150" dyno=web.1 connect=0ms service=825ms status=500 bytes=443
2016-12-13T21:24:50.498979+00:00 app[web.1]: [13-Dec-2016 21:24:50 UTC] PHP Warning:  Illegal string offset 'remember' in /app/public/wp/wp-includes/user.php on line 39
2016-12-13T21:24:50.499139+00:00 app[web.1]: [13-Dec-2016 21:24:50 UTC] PHP Warning:  Cannot assign an empty string to a string offset in /app/public/wp/wp-includes/user.php on line 39
2016-12-13T21:24:50.499288+00:00 app[web.1]: [13-Dec-2016 21:24:50 UTC] PHP Warning:  Illegal string offset 'user_login' in /app/public/wp/wp-includes/user.php on line 54
2016-12-13T21:24:50.500035+00:00 app[web.1]: [13-Dec-2016 21:24:50 UTC] PHP Fatal error:  Uncaught Error: Cannot create references to/from string offsets in /app/public/wp/wp-includes/user.php:54
2016-12-13T21:24:50.500086+00:00 app[web.1]: Stack trace:
2016-12-13T21:24:50.500149+00:00 app[web.1]: #0 /app/public/wp/wp-login.php(775): wp_signon('', '')
2016-12-13T21:24:50.500172+00:00 app[web.1]: #1 {main}
2016-12-13T21:24:50.500256+00:00 app[web.1]:   thrown in /app/public/wp/wp-includes/user.php on line 54

Not able to see Add new theme

I am new to word press and I have deployed WordPress to heroku and I cant see the add new theme option.
Any help is appreciated

Error when running locally.

Works fine when deployed to Heroku however, running locally gives me this error:

14:58 ~/github/blog-towbook-com (master) ✕ $ foreman start
14:58:46 web.1  | started with pid 25217
14:58:46 web.1  | Booting on port 5000...
14:58:46 web.1  | DOCUMENT_ROOT changed to 'public/'
14:58:46 web.1  | Using Nginx server-level configuration include 'nginx_app.conf'
14:58:46 web.1  | vendor/bin/heroku-php-nginx: line 21: /Users/mattgraham/github/blog-towbook-com/load Gem.bin_path('composer', 'composer', version)/heroku/heroku-buildpack-php/conf/nginx/heroku.conf: No such file or directory
14:58:47 web.1  | Starting php-fpm...
14:58:47 web.1  | Starting nginx...
14:58:47 web.1  | [16-Dec-2014 14:58:47] ERROR: failed to open configuration file '/Users/mattgraham/github/blog-towbook-com/load Gem.bin_path('composer', 'composer', version)/heroku/heroku-buildpack-php/conf/php/php-fpm.conf': No such file or directory (2)
14:58:47 web.1  | [16-Dec-2014 14:58:47] ERROR: failed to load configuration file '/Users/mattgraham/github/blog-towbook-com/load Gem.bin_path('composer', 'composer', version)/heroku/heroku-buildpack-php/conf/php/php-fpm.conf'
14:58:47 web.1  | [16-Dec-2014 14:58:47] ERROR: FPM initialization failed
14:58:47 web.1  | Process exited unexpectedly: php-fpm
14:58:47 web.1  | Going down, terminating child processes...
14:58:47 web.1  | vendor/bin/heroku-php-nginx: line 267: 25283 Terminated: 15          tail -qF -n 0 "${logs[@]}" 1>&2
14:58:47 web.1  | vendor/bin/heroku-php-nginx: line 275: 25280 Terminated: 15          sleep 2
14:58:47 web.1  | exited with code 1
14:58:47 system | sending SIGTERM to all processes

this is over my frontend processing. any thoughts?

Error on first install

Hi there, thanks for this awesome work.

I'm having an issue after I followed the install steps, Heroku log gives me :

[04-Aug-2017 09:54:28 Europe/Oslo] PHP Fatal error: Uncaught Dotenv\Exception\InvalidPathException: Unable to read the environment file at /app/public/../.env. in /app/vendor/vlucas/phpdotenv/src/Loader.php:75

I don't understand why it's looking for a .env file if it's gitignored and that my Heroku Environment variables have the CLEARDB_DATABASE_URL set.

Can anyone help me ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.