I recently have been on an incredible optimization kick server and application side and tonight I came across a module for Apache written by Google. Its actually freaking amazing and its running on this site right now. Right now its combining and minifying my css (had a problem with the js and one of these shitty wordpress modules so I left it out), removing whitespace, and caching (yes, awesome.) the list goes on and it improved performance quite a bit (fuck ya?). It’s all done automagically with just a bit of configuration (takes like what, 2 fucking minutes?).
Now I have APC, and Memcache doing some dirty work for me and believe me those two make a HUGE difference already, but after installing this I saw about an average of 33%ish speed improvments. from about 4-5 second page loads (have a lot of external shit on here that im about to get rid of). to about 1.8-3 second page loads. Believe me it makes a huge difference, and I hope this Google Gold helps you out.
If you view the source of this page you’ll notice that there is a lack of whitespace, just one of the optimizations.
Download it. The commands below are straight from Google’s site where the download is located. But I’m going to give you a quickstart to configure it, down and dirty, even simple.
From what Google says on their page, the Google repository will be added to your system to keep mod_pagespeed upt o date. If you dont want that, just run the following code before you install
sudo touch /etc/default/mod-pagespeed
As root run these if you are in a Debian/Ubuntu Enviornment.
dpkg -i mod-pagespeed-*.deb apt-get -f install
If you are using Fedora/CentOS
yum install at rpm -i mod-pagespeed-*.rpm
Debian/Ubuntu Linux distributions
sudo nano /etc/apache2/mods-available/pagespeed.conf
On CentOS/Fedora:
sudo nano /etc/httpd/conf.d/pagespeed.conf
Now that we’re in the file, just paste this configuration in and restart apache and you’re good to go, the automagic happens and it fucking works. Place the code below right before the closing tag so you have your own block of configurations.
ModPagespeedEnableFilters combine_css ModPagespeedEnableFilters rewrite_css,rewrite_javascript ModPagespeedEnableFilters inline_css,inline_javascript ModPagespeedEnableFilters rewrite_images ModPagespeedEnableFilters insert_img_dimensions ModPagespeedEnableFilters remove_comments ModPagespeedEnableFilters extend_cache ModPagespeedEnableFilters remove_quotes ModPagespeedDomain http://www.whateveryoursiteis.com
Save the file, and restart apache and notice the huge improvement.
If you want more options, and believe me there are some go to Google directly and read a bit.
Enjoy.
-Wes
Ok so I’m going to make this article quick, simple and to the point. Fuck the bullshit, lets get ya’ll setup with nginx with a reverse proxy to apache in less than an hour. Now this article is made for VPS type system such as linode or slicehost. We’re starting at the point in which you have Fedora 13 actually installed, base system. So lets get started.
Lets start by installing nginx, start the service and configure it to start at boot.
yum install nginx service nginx start chkconfig nginx on
Was going to use fast-cgi but it crashes so often, so I created a reverse proxy into apache.
yum install httpd httpd-devel php php-cli php-devel mysql php-mysql mysql-server php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy sendmail
nano /etc/nginx/nginx.conf
Once inside the file, change these two values
worker_processes 5; keepalive_timeout 2;
Similar to apache you can set virtual hosts. First lets start by editing the example in the nginx.conf file.
You can define the vhost in server {} containers. Now lets modify the default vhost:
server_name _; makes this a default vhost ( so lets change this to specify a certain domain e.g. www.something.com).
In the location / part, add index.php to the index line. root /usr/share/nginx/html;
This is your DocumentRoot in an apache virtual host, so you can change it to whatever you want..I prefer the /var/www/ directories.
The important part for PHP is the location ~ \.php$ {} container. You need to uncomment it to enable it. Change the root line to the web site’s document root (e.g. root /usr/share/nginx/html; or whatever you directory you chose.). Be sure to pass .php to 127.0.0.1:8080 to proxy php files to apache (we’ll edit httpd.conf later).
nano /etc/httpd/conf/httpd.conf
Pass through to apache port 8080
Listen 127.0.0.1:8080
configure the virtualhost to reflect the same path as the nginx vhost.
Make sure its ready for startup and start it up
chkconfig mysqld on /etc/init.d/mysqld start
mysql_secure_installation
>Enter Current Root Password : Hit Enter
>Set Root Password : Hit Enter
Now enter your password twice
The rest are your choice, I hit enter all the way through.
Lets install some dependencies, most are just needed on a dev server anyway, so group install. Fail2ban is to keep users from attacking your site, they will be banned after 5 failed attemps to login for 10 mins. You can change the configuration in /etc/fail2ban/
yum groupinstall 'Development Tools' yum groupinstall 'Development Libraries' yum install php-pecl-apc yum install fail2ban yum install mlocate chkconfig fail2ban on chkconfig httpd on chkconfig nginx on chkconfig mysqld on updatedb
In the fail2ban configuration file you can change additional settings, they are very self explanatory. To edit fail2ban configuration go to:
nano /etc/fail2ban/jail.conf
Now guess what, you’re done. If you have any questions, just leave a comment and I’ll be sure to answer it, enjoy the nginx server.
Sign up for a linode VPS, I pay $20 a month and it fucking rocks
My Linode.com Referral Code 2bf9ae77ecd8e759a2b79bf1011e1c3147d93525
-Wes