Skip to content

Instantly share code, notes, and snippets.

@artmouse
artmouse / nginx_ssl_spdy
Created November 25, 2014 13:39
Enabling and testing SPDY support on Nginx
Enabling SPDY is pretty straightforward, all we need to do is to add the spdy parameter in the listen directives :
listen 443 ssl spdy;
listen [::]:443 ipv6only=on ssl spdy;
Header compression level is customizable using the spdy_headers_comp directive, for example :
spdy_headers_comp 1;
Check the SPDY module documentation for more details.
@artmouse
artmouse / startSSL_install_nginx
Last active August 29, 2015 14:10
Obtain and install a free SSL certificate on Nginx
Go to https://www.startssl.com. Click Control Panel in the upper right of the screen.
On the Authenticate or Sign-up? screen click Express Lane.
You’ll arrive at a Personal Enrollment Details screen. Because this a class 1 certificate, you’ll enter your personal information here rather than that of a business or organization. The email address entered here will be sent a verification code .
Shortly after submitting your registration, you’ll receiver an email with the verification code needed to complete your registration.
With your account active, you’re prompted to generate your initial private key. This certificate is just for authenticating with StartSSL’s control panel. Select 2048 (High Grade) and click Generate. When the key is done generating, click Install.
@artmouse
artmouse / DKIM_SPF_Sendmail
Created November 25, 2014 13:48
DKIM + SPF + Sendmail for multiple domains (Ubuntu)
DKIM is DomainKeys Identified Mail and is used in mail servers, such as Postfix or Sendmail to sign e-mails and thus authenticating the sender so that a forgery can be detected. It also reduces the possibility of an e-mail being flagged as spam, but it's not a definite prevention.
A much simpler method is using SPF (Sender Policy Framework) which, in a nutshell, verifies the sender IP address.
According to the internet, using both should result to ????, PROFIT !!!.
SPF does not need a specific configuration. Whitelisted servers are listed in a DNS record, TXT or SPF, and an example record is:
example.com. IN TXT "v=spf1 a mx ~all"
@artmouse
artmouse / nginx_htpasswd
Created November 25, 2014 13:55
How To Set Up HTTP Authentication With Nginx
Step 1: Apache Utils
We need htpasswd to create and generate an encrypted for the user using Basic Authentication. Install apache2-utils using the command below.
sudo apt-get install apache2-utils
Step 2: Create User and Password
Create a .htpasswd file under your website directory being served by nginx. The following command would create the file and also add the user and an encrypted password to it.
@artmouse
artmouse / clear_URL_rewrite_magento_ee
Created November 25, 2014 22:04
Clear All URL Rewrites - Magento Enterprise
Anyway to successfully truncate and rebuilt all rewrite tables you can execute:
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `core_url_rewrite`;
TRUNCATE TABLE `enterprise_catalog_category_rewrite`;
TRUNCATE TABLE `enterprise_catalog_product_rewrite`;
TRUNCATE TABLE `enterprise_url_rewrite`;
TRUNCATE TABLE `enterprise_url_rewrite_category_cl`;
TRUNCATE TABLE `enterprise_url_rewrite_product_cl`;
TRUNCATE TABLE `enterprise_url_rewrite_redirect_cl`;
##################################
# WORDPRESS NGINX CONFIGURATIONS
##################################
# /etc/nginx/wordpress.conf
#
# Contains a common configuration for use by nginx on a WordPress
# installation. This file should be included in any WordPress site
# nginx virtual host config located in sites-available with the following line:
#
# include /etc/nginx/wordpress.config;

I've had the opertunity to try a variety of different server configurations but never really got around to trying HHVM with Magento until recently. I thought I would share a detailed walkthrough of configuring a single instance Magento server running Nginx + Fast CGI + HHVM / PHP-FPM + Redis + Percona. For the purpose of this blog post I'm assuming you are using Fedora, CentOS, or in my case RHEL 6.5.

Please note: I'm 100% open to suggestions. If you see something I did that needs to be done a different way, please let me know. I haven't included my Perconca my.conf file yet. I will shortly. Also I plan on trying this same test with HHVM 3.3 and PHP 7.

Install the EPEL, Webtatic, and REMI repos

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
; Enable Zend OPcache extension module
zend_extension=opcache.so
; Determines if Zend OPCache is enabled
opcache.enable=1
; Determines if Zend OPCache is enabled for the CLI version of PHP
;opcache.enable_cli=0
; The OPcache shared memory storage size.
failed (104: Connection reset by peer) while reading response header from upstream, client:
If you are getting the above error in nginx logs running in from of upstream servers you may consider doing this as it worked for me:
check the ulimit on the machines and ensure it is high enough to handle the load coming in. 'ulimit' on linux, I am told determines the maximum number of open files the kernel can handle.
The way I did that?
modifying limits: for open files:
--------------------------------
add or change this line in /etc/systcl.conf
fs.file-max = <limit-number>
@artmouse
artmouse / gist:33742829f9490a14dfcc
Created May 14, 2015 07:52
Messages and Global Messages Blocks
Both use the same block, as we can see in page.xml:
<block type="core/messages" name="global_messages" as="global_messages"/>
<block type="core/messages" name="messages" as="messages"/>
When you add a message, you add it to the session, rather than to either of the
messages blocks, so the code below causes the Mage_Customer_Model_Session object
to have an error logged to it:
Mage::getSingleton('customer/session')->addError('Please enter all required information');