Wednesday, December 18, 2013

Enabling http gzip compression (mod_deflate) in apache

Installing apache on linux server took somewhat a bit long time, 'cause many additional libraries need  installation first.

Here is the list:

apr apr-1.5.0.tar.gz
apr-util apr-util-1.5.3.tar.gz
pcre libpcre
zlib zlib
apache (actually I'm using 2.4.6) httpd-2.4.7.tar.gz

Unzip the files and install them in your server. After installing apr, apr-util, libpcre, zlib, goto the unzipped httpd directory and run
./configure --enable-deflate
If you need enable other modules you can specify in the command. Running above command may tip you missing libraries (in my server I miss apr/apr-util/pcre), just install them. When the configuration is done, run
make
make install
Then apache should have been installed.

To enable HTTP gzip compression, modify the httpd config file:
cd /usr/local/apache2vim conf/httpd.conf
Add lines in the config files:
LoadModule deflate_module modules/mod_deflate.so
<IfModule mod_deflate.c>
        SetOutputFilter DEFLATE
        # You can't compress what is already compressed
        SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
        SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
        # Make proxies work as they should.
        <IfModule mod_headers.c>
                Header append Vary User-Agent
        </IfModule>
</IfModule>

Exit editting and restart apache
bin/apachectl restart

Now your server has enabled gzip compression! You can validate whether you have succeed or not in this website  HTTP gzip compression test .

Tuesday, December 17, 2013

Make TeamCity to work with git submodule

Recently I'm using TeamCity to build .ipa automatically from github, however when I ran project in TeamCity and came to the step checkout files into agent, it always reported an error:
Clone of 'git@github.com:cocos2d/cocos2d-html5.git' into submodule path 'external/cocos2d-html5' failed
I checked the account authority and even cloned files via terminal git, all things run well. So it mustn't be the authority problem.

At last this error was solved by changing git from SSH to HTTPS access.

1. Edit .gitmodules file in the root project, change the addresses of submodules to HTTPS addresses

2. Change directory in every submodule, set fetch and push address to HTTPS
cd $submodule
git remote -v
git remote origin set-url https://github.com/your_git_address

And then TeamCity works properly.