2015年4月24日 星期五

12 Tips for Hosting WordPress on OpenShift


這是一篇WordPress在OpenShift上最佳化的安裝技巧。

超實用的!!




文章來源:https://www.blogger.com/blogger.g?blogID=1850530550163655395#editor/target=post;postID=8353709529886513621

12 Tips for Hosting WordPress on OpenShift

 
5
WordPress is the most popular QuickStart on OpenShift Hub. Here are some tips to make the most of it!

Tip 1: Use PHP 5.4 and MySQL 5.5

This is an easy win if you’re on PHP 5.3 or MySQL 5.1. The newer versions of PHP and MySQL came with bug fixes, new features, and performance enhancements.
For new deployments, make sure you use PHP 5.4 and MySQL 5.5. For anyone with an existing deployment, you can migrate your existing OpenShift/WordPress application to the latest version of PHP/MySQL with the following command:
$ rhc create-app <new app name> php-5.4 mysql-5.5 --from-app <existing app name>
Don’t run this yet! We started here to lead into tip #2.

Tip 2: Move your Database to a Separate Gear

Another easy win. It’s not immediately obvious how to do this in OpenShift Online, but it’s very easy once you’re aware it’s possible.
The solution: deploy WordPress as a ‘scalable’ application with PHP set to scale to a maximum of 1 gear. OpenShift will run PHP on one gear and MySQL on a separate gear. Your database will have a separate set of resources (memory, storage, and CPU).
For new deployments from the web console, select the option to “Scale with web traffic”:
Enable scaling to add a database gear
IMPORTANT: Make sure you update your scaling settings after your app is created! Click on your app, then click the link under ‘Scales’ to adjust your scaling settings. Set PHP to scale to a max of 1 gear.
Do not scale beyond one gear
For new deployments from the command line:
$ rhc create-app <app name> php-5.4 mysql-5.5 --from-code=https://github.com/openshift/wordpress-example -s
$ rhc cartridge scale php -a <app name> --min 1 --max 1
For users with an existing WordPress deployment, you can migrate your application with the following commands:
$ rhc create-app <new app name> php-5.4 mysql-5.5 --from-app <existing app name> -s
$ rhc cartridge scale php -a <new app name> --min 1 --max 1

Tip 3: Upgrade to Bronze to Disable Idling (it’s free)

If you live in the US, Canada, Europe, or Israel and you haven’t upgraded to the OpenShift Bronze Plan you’re missing out on a completely free upgrade. ‘Upgrading’ to the OpenShift Online Bronze Plan disables application idling for any gears running on your account. And, I can’t re-iterate this enough, it’s FREE. You get all the benefits of the Free Plan, but with application idling disabled, support for private SSL certificates, and team management with the OPTION to pay to use extra gears and storage.
If this isn’t absolutely clear on our pricing or plan comparison pages please let me know in the comments! If you live outside of our supported regions for OpenShift Online Bronze/Silver plans, help us help you by filling out theGeo Request Form to let us know you’re interested.

Tip 4: Enable Hot Deployment

If you’re using source control to manage your plugins and themes, you can enable hot deployment to prevent your WordPress site from having downtime when you push your changes. Learn how.

Tip 5: Install the W3 Total Cache Plugin

Using the W3 Total Cache plugin with your WordPress installation will significantly speed up your site. Install it from the WordPress admin panel or download it from wordpress.org and check it in through source control.
Update: I recommend enabling both page and database caching in the W3 Total Cache general settings menu with ‘Opcode: Alternative PHP Cache (APC)’ as the caching method for both.

Tip 6: Use CloudFlare

Have a custom domain name for your WordPress site? Route your custom domain through CloudFlare’s DNS service.
CloudFlare DNS Settings
CloudFlare will automatically detect images and static assets on your site and serve them to your visitors using their global CDN. CloudFlare also offers free SSL for custom domains. If you haven’t heard of CloudFlare, check out their features page.
If you followed tip #5, CloudFlare is provided as a W3 Total Cache extension. Setup instructions can be found here.
If you aren’t planning to use W3 Total Cache, follow this blog post.

Tip 7: Use SendGrid for Email Notifications

We recommend replacing the built-in WordPress mail system with SendGrid for improved deliverability and enhanced reporting. There’s even a note about this in our latest version of the WordPress QuickStart in the wp-config file.
Check out the Developer Portal article to learn how to install SendGrid for WordPress on OpenShift.

Tip 8: Add the WP Optimize Plugin

WordPress can generate a lot of waste in your database. Clean it up with WP Optimize. Install it from the WordPress admin panel or download it from wordpress.org and check it in through source control.

Tip 9: Enable ‘Development’ Mode During Development

The latest version of our WordPress QuickStart offers support for advanced debugging. Learn how to enable ‘development’ mode.

Tip 10: Throw Some Money at It

Need to support more traffic? Do you have resource-intensive plugins or themes? Step up to a larger gear size for PHP, your database, or both. We run this blog using the WordPress QuickStart with Large gears – one for the database and another for PHP.
Is your user base largely in Europe? Switch over to any of our Production gears (Small.highcpu, Medium, and Large gears) and re-deploy your site closer to your users in our European hosting region. Learn how.

Tip 11: Backup WordPress with OpenShift Backup Server

If you used tip #2, this step will require you to pay for an extra gear on your account. Still, it’s worth mentioning if you take your application seriously.
Use the OpenShift Backup Server to create one-time or scheduled backups for your WordPress site. It’s the easiest, most complete way to backup your OpenShift applications using OpenShift’s built-in snapshot system for backup/restore.

Tip 12: Risk it with Scaling (experts only)

I wouldn’t recommend scaling the current WordPress QuickStart (beyond separating the database from tip #2 or using larger gears from tip #10). For the more daring and hopefully expert users out there, we plan on releasing an experimental ‘Scalable WordPress’ QuickStart available on the OpenShift Hub shortly. There are quite a few downsides to scaling WordPress without a shared file system, namely that plugins, themes, and updates will have to be managed through source control. Nevertheless, we can try to create a workable solution…together :)

Have your own tips for using WordPress on OpenShift? Share your tips in the comments!

沒有留言:

張貼留言