Category Archives: Ubuntu

Enable image caching in apache for better Google Page Speed results


High page speed and short page load times of your website are essential for good search engine rankings. To enable Image caching and http requests in apache, you need to enable the expires module on Ubunto or Debian. This module allows the apache web server to set HTTP headers. It sets the modification header for static assets like image and CSS files that do not change often.


a2enmod headers expires

Add the following directives inside the vhost file of the web site or at the end of the file /etc/apache2/apache2.conf to enable it globally.

Header set Cache-Control "max-age=3024000, public"
</FilesMatch

On ISPConfig 3 servers, this can be added in the “Apache Directives” field of the website instead. There is no apache reload required as ISPConfig takes care about that

Advertisements

Nokia N900


My Nokia N900 suddenly started losing battery charge fast. I have updated the latest beta repositories and installed as much as new (useful) applications I can. The situation became so bad, that I cannot use my phone for even few calls. I was charging my phone more rather than using it. So, I decided to do something about it.

I then flashed my phone from one of the US kernels, i downloaded before. It was successful but I was not getting any network at all and hence could not make any calls. After pulling my hair for several days and going through abundant resources from the net, I downloaded the latest US kernel and did the flashing once again. This time I was successful.

Guess, what was the problem. Never downgrade from the previous version of kernel or whatever on the N900. The same kernel worked for me before, now it didn’t because. I have updated to the latest kernel after installing it and hence applying the old kernel do not work 🙂

Customizing Gedit as Web Developer’s IDE


These tips I followed from Micah Carrick’s blog

1. get the tag for gedit
wget http://www.micahcarrick.com/files/gedit_webdev_tags-0.1.tar.gz
tar -xzf gedit_webdev_tags-0.1.tar.gz
sudo mkdir /usr/share/gedit-2/plugins/taglist
sudo cp *.tags /usr/share/gedit-2/plugins/taglist/
rm -rf *.gz *.tags

2. get current version of PHP_Beautifier and other useful stuffs

sudo apt-get install csstidy linkchecker
sudo pear install PHP_Beautifier-0.1.14

3. use external tools plugin
for beautifying PHP (add command)

php_beautifier -s4 -l “ArrayNested() IndentStyles(style=bsd) NewLines(before=if:switch:while:for:foreach:function:T_CLASS:return:break,after=T_COMMENT)”

check PHP code for parse error (add command)
php -l

PHP function look up in browser firefox (add command)
xargs -I '{}' firefox \
'http://www.php.net/search.php?lang=en&show=quickref&pattern={}'

“Not working for me in Jaunty Jackalope”

4. get ftp support
run gconf-editor add ftp to the list at
/apps/gedit-2/preferences/editor/save/writable_vfs_schemes/

“Already updated in Jaunty Jackalope”

5.get symbol browser plugin

cd ~/.gnome2/gedit/
wget http://sourceforge.net/projects/symbol-browser/files/symbol-browser-bin/gedit-symbol-browser-plugin-bin-ubuntu-i386-0.1/gedit-symbol-browser-plugin-bin-ubuntu-i386-0.1.tar.gz
tar -xzf gedit-symbol-browser-plugin-bin-ubuntu-i386-0.1.tar.gz
rm -rf *.gz
sudo apt-get install libgnomeprintui2.2-0 ctags

Now enable from menu Edit->Preferences-Plugins

6. get tidy plugin
cd plugins
wget http://www.eng.tau.ac.il/~atavory/gedit-plugins/html-tidy/html-tidy-gedit-plugin.tar.gz
tar -xzf html-tidy-gedit-plugin.tar.gz
sudo apt-get install tidy

7. get PHP autocomplete
wget http://downloads.sourceforge.net/project/gedit-autocomp/gedit-autocomp/gedit-autocomplete-0.9.6/gedit-autocomplete-0.9.6.tar.gz
tar -xzf gedit-autocomplete-0.9.6.tar.gz
cd gedit-autocomplete-0.9.6
mv *.* ../.
cd ..
rm -rf gedit-autocomplete
*

8. get python plugin for posting code into snipplr.com remotely.


wget http://geditsnipplr.googlecode.com/files/snipplrpy-0.4.tar.gz
tar -xzf snipplrpy-0.4.tar.gz
cd snipplrpy-0.4/
sudo python setup.py install
cd ..
wget http://geditsnipplr.googlecode.com/files/gedit_snipplr_plugin-1.0.tar.gz
tar -xzf gedit_snipplr_plugin-1.0.tar.gz
cd plugin
mv snipplr* ../.
cd ..
rm -rf plugin

if you have not signed up already, sign up with snipplr.com and get the api key from the site.

9. cleanup
rm -rf *.gz

Continue reading Customizing Gedit as Web Developer’s IDE

First Step before Creating a Webapp with YII


  1. Install LAMP Server
  2. Install PHPunit
  3. % sudo pear channel-discover pear.phpunit.de
    % sudo pear install phpunit/PHPUnit

  4. Install Selenium
  5. Download Selenium Remote Control (Selenium RC) zip file from http://seleniumhq.org/download/.
    Run Server from shell

    % java -jar selenium-server.jar

  6. Running the Functional Tests
  7. Before we can run this functional test, we need to make a couple of configuration changes to our application. First we need to alter protected/tests/WebTestCase. php to properly define our test URL that Selenium will attempt to open when it runs
    the tests. Open up that file and make sure the TEST_BASE_URL definition matches the URL to your webapp

    define(‘TEST_BASE_URL’,’http://localhost/webapp/index-test.php/&#8217;);

    The file protected/tests/phpunit.xml houses some configuration settings for Selenium Server. It is configured to use IE as the primary browser. We can remove the following highlighted line of code to ensure only Firefox will be used when running Selenium:

    name=”Internet Explorer” browser=”*iexplore”

    Now, as long as you have installed PHPUnitand have ensured that Selenium Server is running, and then we can navigate to our tests folder at the command prompt and run this functional test:

    % cd protected/tests/
    % phpunit functional/SiteTest.php

    What should happen is that you will see your browser being automatically invoked, as the Selenium Server platform is using the browser to access the end-user functionality of the site that we configured in the WebTestCase.php file. As it runs through the test methods, it actually automates the behavior of a real user of the site.

  8. Configure Gedit for PHP
  9. Install Netbeans
  10. SVN update the latest YII
  11. install the webapp in the webroot
  12. Testing the DB Connection
  13. we know we add our unit tests under protected/tests/unit/. Let’s create a simple database connectivity test file under this folder called DbTest.php. Create this new file with the following contents:

    class DbTest extends CTestCase
    {
    public function testConnection()
    {
    $this->assertTrue(true);
    }
    }

    Here we have added a fairly trivial test. The assertTrue() method, which is part of phpUnit, is an assertion that will pass if the argument passed to it is true, and it will fail if it is false. So, in this case, it will pass if true is true. Of course it is, so this test will pass. We are doing this to make sure our new application is working as expected for testing. Navigate to the tests folder and execute this new test:

    % cd /WebRoot/trackstar/protected/tests
    % phpunit unit/DbTest.php

    Change the trivial assertEquals(true) statement in the testConnection() test method to:

    $this->assertNotEquals(NULL, Yii::app()->db);

    And rerun the test:

  14. Configuring YII to use MySQL
  15. To customize our application configuration, we normally provide a configuration file
    to initialize its property values when the application instance is being created. The
    main application configuration file is located in /protected/config/main.php.

How to Install Apps from GetDeb


  1. Install the getdeb package.
  2. Or configure the repository manually:
  3. Go to System-Administration-Software Sources, Third-Party Software tab, Add

deb http://archive.getdeb.net/ubuntu lucid-getdeb apps

  1. Add the repository GPG key, open a terminal window and type:

wget -q -O- http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add –

  1. Click the “Install this now” button below the screenshot of the desired application.

Installing LAMP server to Ubuntu


  1. Installation
  2. If you have not already installed LAMP software, you can read my First steps after installing Ubuntu post, for installing the necessary Server software.

  3. Configuration
  4. if apache starts, you can see the below error in terminal.
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

    To rectify run the below code from terminal
    sudo echo "ServerName localhost" | sudo tee -a /etc/apache2/apache2.conf

  5. Adding Virtual Host
  6. By default, Ubuntu place its web root at /var/www. Since, we want to have have multiple hosts for development, add virtual host. We also want, to mimic the cpanel configuration we have at the production server.
    copy the default file to your new host name. It is not mandatory to have the host name, but it is easy to remember if you follow this convention.

    sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/example

    Now edit the example file so that it reads as below.

    ServerName “http://example&#8221;

    DocumentRoot /home/yourhomedir/public_html

    Options FollowSymLinks
    AllowOverride None

    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all

  7. Enabling the availble site http://example
  8. We want to have the production server name minus the .com or .net in the local development server, we can now enable our site using the command

    sudo a2ensite example

  9. Adding host name to the hosts file
  10. Since your Server does not know how to resolve the name http://example, configures the hosts file accordingly.

    gksu gedit /etc/hosts
    add the host name example next your existing machine name.

    127.0.0.1 yourmachine example

  11. Changing the process owner of Apache2
  12. It will be very difficult for us to change the username between apache default username ‘www-data’ and ‘your username’, every time you add a new webfolder/host, so change the apache process name to your username and group.

    gksu gedit /etc/apache2/envars

    change the two lines in file envars, so that it looks like below.

    export APACHE_RUN_USER=example
    export APACHE_RUN_GROUP=example