Tag Archives: WordPress

Tips for choosing right server

How to choose right server for your app?

I need to start with the short statement - you probably don't need hosting or server. This article is dedicated mostly to tech people. If you are looking for tips how to pick a server for your website and you don't know what Shell, SSH or FTP is, please read only the chapter below:) If you want to jump to strictly tech stuff - click here.

You don't need hosting/server

If you are just starting a blog, small business website or e-commerce, don't bother looking for hosting and a developer who can create your website. These days we have great alternatives that will take care of your website from start to finish.

They will care about server infrastructure, security, backups, servers performance, updates to CMS, bug fixes and everything you need for having website up and running. You won't have to ask a developer to fix a bug or change a text on your website.

If you are just starting and you don't want to spend hundred of $$$ for a website you can try some services I will mention about. All you need is to have some time to configure everything. Most of them have free trial, so you can try it first for free. Some of them offers free features that are sufficient for lot of websites. Remember, you can always change it in the future to your self-hosted website.

If you plan to go with a blog and you want to focus on writing I suggest you get yourself familiar with https://wordpress.com and https://medium.com/

Medium is awesome alternative to popular WordPress. IMHO they have much nicer editor. If you care only about writing, try it first before going with WordPress:) You can always try both and decide which works better for you.

If you want to sell stuff online, go with https://www.shopify.com/  Super useful e-commerce with number of options. In general you need to buy a plan. Cheapest one is 29$ per month, but it's still cheaper and safer than running custom e-commerce like WooCommerce or Magento. They also have trial version:)

If you want to create a website for your business/company try WIX first - http://www.wix.com/ It's a website builder when you can create your own site with Drag&Drop. Lot of small businesses have websites build with WIX.

If you are fine with features that mentioned services are offering, you can stop reading here. Such services are great until you really need something custom. The feature that none of the services can offer. In such case you need to find someone who can build your website. You will need a hosting or server. If you need to look for server for your small website, make sure that you will choose right hosting plan.

If the website is small and it won't receive lot of traffic you should only pay attention to few details. I know that price will be important here, but remember. Sometimes the cheap comes out as expensive.

If you decide to go with shared hosting, your website will be slow or even unaccessible if lot of visitors will go to your website at the same time. You will need to change plan to something better or go with VPS/dedicated server. Make sure that you will choose such server with management (your server will have dedicated administrator). Trust me, if you don't know a thing about server administration and security, you don't want to choose unmanaged server:)

Make sure that they have backup plan, or do your own from time to time. Recently in Poland we have situation when one of the bigger hosting provider deleted all websites and thousands of people lost they websites permanently. They hosting plans were quite cheap so they got lot of clients. But after the incident all websites was down for 2 months. People who made backups on they own, rescued they websites quite fast, but rest lost their websites forever.

You can stop reading here. Rest of the things are for tech people! Unless you want to get some knowledge about servers:)

To cloud, or not to cloud?

Yes, you should go with cloud, but only if your website earns money. And I mean MONEY, not few dollars every month. Cloud is not cheap. It's expensive. And sometimes it can get really expensive. Like hundred of dollars every month. You pay the price, but you get a value.

We had a website that was mostly image based and got quite a lot of traffic. We were using Amazon AWS. Two EC2 instances (prod + stage), Elastic IP, S3. We paid around 500-600$ every month. Most of costs were traffic (around 2-3TB every month) and EC2. I felt like that's a lot of money for such website. Fortunately we didn't pay for it. Our client was big, was cloud oriented and money didn't matter, so we used AWS. But for my personal website and for lot of other websites 500$ every months is a killer.

So can you lower the costs somehow and still use cloud? Yes, you can. But first thing first.

Serverless maybe?

First you need to think about two important points.

  1. Do you have time to take care about server architecture, regular updates, configuration etc?
  2. Think about your application. Does it need specific server architecture, or you only care to have it up and running?

Most of people thinks - installing LAMP stack and setting some basic configuration is no brainer. Well, server management is unfortunately not that easy. Of course, your server will work for some time until you will get hacked or you will get some performance issues. And trust me, you will if you won't pay attention to your servers. We've been hacked twice, because we thought that server management doesn't require time and attention. Our servers has enormous load because of older version of few libraries. We were not even able to SSH to our servers;/

So if you only care about your app, try Heroku first. It's running in the cloud (on AWS actually), has support for tons of technologies and you don't need to care about server infrastructure at all. They will care everything for you. It feels that it might be expensive, but think if setting custom server + hiring server admin will not be more expensive?

Heroku is super convenient and powerful. You can setup and deploy your up within minutes. Their uptime is pretty good, scalability is nice and easy to configure. Give it a shot (they have free trial), maybe it will be much better than setting up a server 😀

Our solution

We go with old fashion way, with servers that we manage on our side. Downsides? We need to spend time to configure and maintain them. But from the other side we have full control of our server. And we don't pay $$$$$$$$$$$ for them:)

We adapt infrastructure to our projects. But in most cases it goes like that - VPS/Dedicated server/Cloud based server + Amazon S3 + CDN/Amazon CloudFlare.

Server features

When we are looking for server we are looking mostly at such features:

  1. SSH+Root
  2. OS and OS version
  3. CPU
  4. RAM
  5. SSD
  6. Transfer
  7. Additional IP address

SSH+Root - server must have SSH access. Era of FTP and manually uploaded files to server is fortunately behind us. So if server doesn't have SSH access it's not the right choice. Also, pay attention for full root access. We saw servers where you can login via SSH and do only basic stuff like GIT, creating files etc. But it was not possible to install anything. If it doesn't have root, you shouldn't use it.

OS - It's important to see what operating system they support. We are mostly looking for CentOS 7, as this is our OS of choice. If you want to go with Ubuntu, that's OK. We prefer CentOS. Version of the system is really important. Sometimes you can't install latest available version, like CentOS 7. If for instance latests supported version for server is CentOS6, we are looking for something different. Also make sure that it is x64 os. 32 has lot of limitations and you should avoid it.

CPU - we are mostly looking for processors with 2 or more cores. 1 core is enough if you want to run small app or only one website. But if you plan to go with something bigger, 2 or more cores will get you significant performance boost.

RAM - 1GB is minimum, but if it has much more RAM it's great. We avoid 512MB, it's way to small and you can get issues when you try to compile PHP from source for instance. Basically for optimisation, caching etc, it should have as much RAM as possible. We usually goes with 2GB and above. But 1GB is minimum you should aim for.

SSD - if it has SSD, that's great. We switched all our servers from HDD to SSD. Machines are much faster and more performant. Downside is that usually they are bit more expensive and have smaller disk sizes. If you need lot of disk space you should go with SSD + HDD.

Transfer - it is really important factor. If you will serve images from your server or you expect lot of traffic and you won't use CDN, you should go with 1-2TB per month. It really depends on the website and traffic, so it's hard to say how much transfer you will really need.

Additional IP addresses - if you plan to host multiple websites on single server make sure that it allows you to add additional IP address. If you want to go with SSL, and I'm sure you will want to do that, 1 IP address is not enough. You can't have two SSL websites on single IP address.

Your server does not have to be in Cloud, unless you want to get easier access to automatic scalability etc. We are using two providers mostly. For smaller apps/websites, we are using DigitalOcean. Simple pricing, nice servers, easy to use. Most of our servers are 10$ or 20$ per month. We don't go higher as it becomes more costly.

However if we need more horsepower, more RAM, CPU cores we are looking for something more performant. We are using dedicated servers for that. We tried multiple solutions but our favourite so far is Hetzner. They have really nice value for the money. For instance for around 50$ you can get 4 cores, 32GB rams and 30TB of traffic. Uptime is pretty high and their support is awesome. Highly recommended:)

How about pure cloud solutions?

You can of course go 100% with AWS, but as I mentioned above, it will cost you significant amount of money. It will have it's benefits, but I feel that AWS is dedicated to large companies and websites. I especially don't like their pricing as it's hard to predict how much you will pay for given configuration.

We however use AWS for two purposes.

Backup - it's important factor. Most of users that runs their own servers, usually forget about making backups. Guys, if you don't do backups, start today. Hard drives can break, you or someone else can delete something etc. Backup are super important thing! We are using S3/Glacier from AWS for this purpose. Once per day or every couple of hours we are making full backup of DBs/Images/Important data to AWS. It's really easy to setup and to use. After an hour or so, you should get your backups up and running. Glacier is relatively cheap and Amazon is taking care of persistence of our data.

CDN - If MaxCDN or CloudFront is not enough, we go with CloudFlare. IMHO they offer enormous number of features and configuration gives us much more power.

Should I use CDN?

Speaking about CDN. Should you use one? The answer is yes. It will give your website significant boost if your users are connecting from different countries. Hetzner has their servers in Germany, but some of our websites are worldwide oriented. CDN is a must here.

You can have CDN for free by using CloudFlare. They don't offer much options but it's for free:) If you have a blog with lot of images, it will also takes some of the transfer for you from the server. Images will be served from CDN instead of your server.

If free is not enough, you can use paid plan from CloudFlare or try MaxCDN.

If you need detailed control, we suggest to go with Amazon and their CloudFront:)

Summary

So it's all come down to how much time and money do you want to spend here. If you don't plan to run your own servers for your app, you should go with Heroku. If you want to play around with servers and want to have bigger control, go with DigitalOcean/Dedicated Server + S3/Backup server + CDN. It's the best value for money. If you have lot of money and you want best scalability and performance, go with AWS and all the features it offers;)

If you will go with DigitalOcean or custom server, you should learn about Ansible. It will save you lot of time when it comes to configuration of the server. Read the tutorial about Ansible.

If you want to learn how to configure your own server, you should read our series about setting up LAMP on steroids.

Wordpress won't send emails

WordPress won’t send emails

It's been long time since I wrote something here. But today I decided to wrote the story of my problem with WordPress. In short words - WordPress won't send email. The problem was raised by the clients, they didn't receive emails from WooCommerce with downloadable item. It was huge problem, as payment was processed successfully, but they didn't receive email with PDF they bought.

Research about not working emails in WordPress

I read tons of threads, articles about problems with WordPress emails. Lot of solutions but none of them actually fixed the problem. It pissed me off, because something like that should work without any problems!

Solving the problem with WordPress emails.

I checked few things:

First of all I wasn't sure if it's a problem with WordPress or with WooCommerce. I'm using PayPal only so i turned on debugging in WooCommerce PayPal settings. I tested the transaction, no email sent. I checked the log, and transaction was completed, but no errors on sending email or anything like that.
Error log from apache was empty so it wasn't pure PHP problem or anything like that.
WordPress use default PHP mail() function for sending emails. In hundreds of threads I checked they suggesting using SMTP protocol instead of using mail function. I installed plugin called Check Email. It's simple plugin that checks if WordPress is sending email correctly. I used standard headers for that, typed the email. Check Email told me that email was sent successfully, but it doesn't mean that email will be delivered. I checked my gmail account and no email at all ;/

So I thought, OK, I will switch to SMTP. I installed plugin called WP-Mail-SMTP. All i need was email account where from I will be able to send emails. So I logged in to my server admin panel (DirectAdmin in my case) and created some dummy email. I received all required information for WP-Mail-SMTP plugin like host and port. I filled all require settings field in plugin's settings. Plugin has also great feature where you can test the email. Everything was great, email should be delivered. I checked my gmail account. Still nothing.

Right direction

That was pretty weird for me. It should have work like a charm! So I decided to log in to fresh created email address and try to send email from there. My server provider has Roundcube system as email system. I created new email and it wasn't delivered. But! I received response email with title: Mail delivery failed: returning message to sender. Email says:

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

*****@gmail.com
SMTP error from remote mail server after end of data:
host aspmx.l.google.com [2a00:1450:4013:c01::1a]:
550-5.7.1 [2a01:4f8:101:324d::2 12] Our system has detected that this
550-5.7.1 message is likely unsolicited mail. To reduce the amount of spam sent
550-5.7.1 to Gmail, this message has been blocked. Please visit
550-5.7.1 http://support.google.com/mail/bin/answer.py?hl=en&answer=188131 for
550 5.7.1 more information. i49si3865415eem.12 - gsmtp

I checked the link in the email. Title of this page is Why has Gmail blocked my messages?

First thing that comes to my mind was that I'm on some kind of blacklist. Maybe I'm a spammer? I used http://mxtoolbox.com/ - great tool that checks if you're not blacklisted. My domain was OK, not blacklisted at all.

What comes to my mind, for test i was using @gmail.com email all the time. I tried to send email to other domain and... email was delivered! I read all that I could and it seems that gmail, yahoo, and few other bigger email providers have algorithms that sometimes block domain, server etc. I wasn't able to find complete solution for this problem. Also, i didn't want to contact Google Customer Center or anything like that. Also i was wondering why I've been blocked by Google?

Fixing Google issue

First of all, i had free domain that I got when I bought the server. I created new account to check if server or domain is blocked. I had the same problem with sending emails from this domain so it was obvious to me, that there's something wrong with the server.

Solution 1 - SPF

SPF is Sender Policy Framework that secure SMTP servers from email spam by email spoofing detection. First of all, I need to know what You must add and where. It should be somewhere in Your server admin panel where You can manage DNS settings. If You can't manage the DNS option You will have to ask Your hosting company to add SPF information to Your DNS records.

It's TXT record with this signature:

v=spf1 [server info here] ~all

Where you have to replace [server info here] with

if You have domain server for your mail server where emailserver.com is domain of Your server

include:emailserver.com

Or server IP address where 111.222.333.444 is mail server IP

ip4:111.222.333.444

Example:

v=spf1 ip4:180.4.140.130 ~all

Important note is that You must use "From" address, that belongs to SPF enabled domain. If You won't provide this information SPF won't work.

I added the record to my DNS panel. I read in 2 or 3 threads that it helped in WordPress not sending email case. But it didn't helped in my case unfortunately. Maybe it didn't worked but I had anti spoofing protection to non-gmail emails 😀

Solution 2 - DKIM

After some further research I finally found working solution DKIM - DomainKeys Identified Mail. It's a way of associating Your domain name with email message.

Unfortunately for the reader it requires integration with server. Simple DirectAdmin or other panel might be not enough in that case. The simplest way is to contact Your hosting provider and require to setup DKIM for Your domain(s).

If You have access to Your server you can do it by yourself. Here is great tool for generating DKIM keys: http://dkimcore.org/ Installation process is different for every server and it depends of the software and OS you're using. I bet that you can find tutorial for Your OS'x using Google Search. For instance here is the tutorial for Postfix and Debian:

https://www.digitalocean.com/community/articles/how-to-install-and-configure-dkim-with-postfix-on-debian-wheezy

Hope that one of this option will help You solve Your WordPress email sending problem. If You have any other solution that might help solve this issue please post it in comments below:)

 

 

How to open WordPress admin panel in iframe?

How to open wp-admin in iframe?Hello everybody,

You want to put WordPress in iframe? Sure, no problem. Now, are You trying to log in to wp-admin from iframe? Not possible? Here is the simple solution how to fix opening wp-admin in iframe.

How to open wp-admin in iframe?

Open this file in Your editor:

/YOUR_WORDPRESS_INSTALLATION/wp-includes/default-filters.php

Find and comment out this two lines:

add_action('login_init', 'send_frame_options_header', 10, 0);
add_action('admin_init', 'send_frame_options_header', 10, 0);

 

Background story of wp-admin in iframe problem

What problems we encountered? We had to create solution, that can manage multiple WordPress instances from one admin panel. The problem was, that all websites was on different servers, separate databases etc. So mutlisite is not an option here.

I did small research and found some good wordpress plugins that helps manage multiple wordpress instances:

All of them are really great solutions if You need quick and ready solution.

Both WP-Remote and ManageWP are based on admin panel that creators of these services provides. So You don't have to install anything on Your server. Just create an account on one of them, add Your websites and that's it. Really simple, but unfortunately due to some restrictions in the company I work it was impossible to use one of these solutions. We wanted to be able to change the logo, restyle the admin panels etc. And if we will need any additional functionality that these two solutions provides we will be screwed.

Third solution - InfiniteWP seemed to be best option. You can install it on Your server, you have access to source code, You are able to modify almost anything. I installed it on my localhost and have already some problems.

InifniteWP works like this: You install small plugin on the WordPress website You want to connect with InfiniteWP. It provides You connection data, some secret key etc. When I was trying to add one of the websites I was waiting and waiting and then BUM! Connection was reset. There was nothing in log files, I didn't get any errors and anything. So when I run it with error_reporting(E_ALL) - OMG. Hundreds of warnings etc. After two days of debugging finally I was able to add websites to the InfiniteWP. It works really great on local machine. Clients was satisfied when I showed them the solution via conference room and screen sharing.

More problems started when we putted it on our test server. First of all it worked sooooo slow. After adding website indicator was spinning like forever. All requests took about 5-20s to finish. I fought with that for another 2 days and there was nothing I could really do about it. Googling, reinstalling etc. Nothing!

My approach of dealing with wp-admin in iframe

When I was showing our clients InfiniteWP on my local machine they was quite happy, most of because I was able to run multiple websites without logging in to each website separately. They was able to switch between the websites. InfiniteWP is working kind of a windows with the taskbar where You can switch between applications.

So I thought, we not to create some really simple solution, when I will open WordPress in iframe? Simple switching on JavaScript between iframes. They was quite happy about this, as writing this solution took only 1 day. Fast and simple. The only problem was how to enable opening wordpress admin panel in iframe? But you know the solution already, don't you?:)

WordPress and good WordPress plugins (tech part about this blog)

WordPress and WordPress pluginsOK, lets learn something more about this site(blog) which is run on Worpress with couple WordPress plugins.

At the beginning I thought that I will write it completely from scratch with ZF. But hmmm, when I realize how many things I should create and time I should put into this project I decided for ready solution. If it's a blog, solution is pretty obvious - WordPress. I didn't use it for about 2 years, so I think it might be nice to back to some old solutions.

I downloaded WordPress 3.5.1 from wordpress.org page. Installation as always was very simple, after uploading whole stuff to the server and launching url of the blog we will find simple Step by Step installation. If you know a little bit about web, it shouldn't make you any troubles. After installation it's all about clicking through the configuration pages and set options which suits you best. I used default theme, it's pretty nice, has responsive version (where I found one, or two bugs already, i will fix them later).

OK, so thats it! We can start writing posts, create about me page etc:P W have fully functional blog in 10 minutes. But hey! WordPress has many plugins which increase WP power. So I decided to look around a little bit for some good wordpress plugins and I found really useful stuff. Here are the list of WordPress plugins that are used in this blog:

Akismet

Used by millions, Akismet is quite possibly the best way in the world to protect your blog from comment and trackback spam. It keeps your site protected from spam even while you sleep.

Its bundled with the WordPress installation but it's disabled by default. In order to make it active You need the API key (which is free) from Akismet website

Download link: http://wordpress.org/plugins/akismet/

Crayon Syntax Highlighter

Syntax Highlighter supporting multiple languages, themes, fonts, highlighting from a URL, local file or post text.

Very handful WordPress plugin for syntax highlighting. Tons of options and supported languages. A must have for any developer

Download link: http://wordpress.org/plugins/crayon-syntax-highlighter/

Sociable

Automatically add links on your posts, pages and RSS feed to your favorite social bookmarking sites.

If you want to have the blog it won't be good if you won't place share/like buttons on your page.

Download link: http://wordpress.org/plugins/sociable/

W3 Total Cache

Easy Web Performance Optimization (WPO) using caching: browser, page, object, database, minify and content delivery network support.

I tried Hyper Cache with WP Minify previously but I couldn't make it work properly on my WordPress installation so I changed it for W3 Total Cache - I think it was good choice, for now everything is working very nice. Even if you do not expect large traffic on your website it's good to have tool like that installed. It will speed up loading time of your website. Faster loading time = more satisfied user:) Very good WordPress plugin!

Download link: http://wordpress.org/plugins/w3-total-cache/

WordPress SEO by Yoast

The first true all-in-one SEO solution for WordPress, including on-page content analysis, XML sitemaps and much more.

Nice WordPress plugin for SEO, when you write post it shows you the SEO statistics and give you advices for optimization.

Download link: http://wordpress.org/plugins/wordpress-seo/

Thats all WordPress plugins I installed on my fresh installation. I will update this post when I will add some new plugins:) Do you know any good plugin for WordPress? Leave info in comments below:)