Install MySQL, Apache, PHP, Java, Subversion, TWiki on Ubuntu 10.04 64bit

Linux No Comments

ubuntuWe decided to migrate from a virtual OpenSuSE Linux server running on my desktop to a dedicated server hosting company. Unfortunately, I missed the OpenSuSE selection as an operating system choice and ended up choosing Ubuntu 64bit. Below are the initial steps I took to setup our development environment on Ubuntu.

(You can skip this section if you wish to.) For those interested, we picked CalPOP – California Point of Presence as our dedicated server hosting company for three reasons:

  • They were located locally in Los Angeles, CA.
  • They offered the best bang for the buck: a Dual Core Server with 4GB memory for just $69/month.
  • After calling and talking to their sales and support (to ask some technical questions), I found them responsive and friendly. They seem to really care about getting our business.

Install MySQL 5

  1. Run the following commands as root user:
    apt-get install mysql-server
    update-rc.d mysql defaults
    service mysql status
    mysql --version
  2. “apt-get” stands for Advanced Packaging Tool and is Ubuntu’s RPM package manager.
  3. The “update-rc.d” command above will configure the MySQL Server to start on bootup.

Install Apache HTTP Server

  1. Run the following commands as root user:
    apt-get install apache2
    update-rc.d apache2 defaults
    service apache2 status
  2. Some Apache related directories:
    • Configuration Directory: /etc/apache2
    • Debug Log Directory: /var/log/apache2
    • Default Document Root Directory: /var/www

Install PHP 5

  1. Run the following commands as root user:
    apt-get install php5
    apt-get install libapache2-mod-php5
    apt-get install php5-mysql
    apt-get install php5-cli
    php -version
    service apache2 restart
  2. The PHP configuration files are located under the “/etc/php5” directory.
  3. When you restart Apache, you might see this warning: “Could not reliably determine the server’s fully qualified domain name”. To resolve this warning, edit the “/etc/apache2/httpd.conf” file (strangely, it is an empty file), add a new line containing “ServerName replace_with_your_hostname”, save and restart Apache.

Install Sun Java JDK 6

  1. Edit “/etc/apt/sources.list”.
  2. Uncomment the two lines referring to the partner repository:
    deb lucid partner
    deb-src lucid partner
  3. Run the following commands as root user:
    apt-get update
    apt-get install sun-java6-jdk
  4. Double-check that the sun jdk is configured properly by running:
    java -version
    javac -version
  5. If you have multiple JRE/JDKs installed, you can configured which one to use by running this command and selecting the default java installation to use:
    update-alternatives --configure java
  6. Some useful directories to know:
    • Configuration Directory: /etc/java-6-sun
    • Installation Parent Directory: /usr/lib/jvm

Install Subversion

  1. Run the following commands as root user:
    apt-get install subversion libapache2-svn
    svn --version
  2. Create the repository directory:
    mkdir -p /var/svn/repos
    svnadmin create /var/svn/repos
    chown -R www-data:www-data /var/svn/repos
    chmod -R g+w /var/svn/repos
  3. Optionally, if you are moving a subversion repository from an old server, do the following:
    (On old server)
    svnadmin dump /srv/svn/repos > backup.svn
    (Suggest that you gzip the result, copy it to the new server, and gunzip it there.)
    (On new server)
    svnadmin load /var/svn/repos < backup.svn
    chown -R www-data:www-data /var/svn/repos
    chmod -R g+w /var/svn/repos

Enable Apache HTTPS/SSL

  1. Create a vhost config for SSL:
    cp /etc/apache2/sites-available/default-ssl /etc/apache2/sites-enabled/
  2. Edit the “/etc/apache2/sites-enabled/default-ssl” file and modify so the SSL uses a different directory than “/var/www” and a different error log file:
    DocumentRoot /var/www-ssl
    <Directory /var/www-ssl>

    ErrorLog /var/log/apache2/ssl_error.log
  3. Enable the SSL module and restart apache:
    a2enmod ssl
    service apache2 restart

    The “a2enmod ssl” command just adds the “ssl.conf” and “ssl.load” files to the “/etc/apache/modes-enabled” directory so that the ssl module will be loaded by Apache on startup.

  4. Browse to your server using the secured “https://localhost/” URL.

Install Subversion for Apache SSL

  1. Enable the apache subversion modules:
    a2enmod dav
    a2enmod dav_svn
  2. Edit the “/etc/apache2/mods-enabled/dav_svn.conf”, uncomment the lines below, and also add the “SSLRequireSSL” keyword to force only SSL access.
    <Location /repos>
      DAV svn
      SVNPath /var/svn/repos/


      AuthType Basic
      AuthName "Subversion Repository"
      AuthUserFile /var/svn/dav_svn.passwd

      Require valid-user

    “Require valid-user” causes Apache to require the user to login to do any action including viewing the repository.

  3. To create subversion users, use this command to generate the “var/svn/dav_svn.passwd” file:
    (For first user only)
    htpasswd -mc /var/svn/dav_svn.passwd <i>username1</i>
    (For subsequent users)
    htpasswd -m /var/svn/dav_svn.passwd <i>username2</i>

    You will be prompted to input the password for the user. Be careful to only use the “-c” create flag the first time because it will overwrite any existing password file.

  4. Restart the apache server with “service apache2 restart”.
  5. Browse to your subversion repository using the secured “https://localhost/repos/” URL.

Install TWiki

  1. TWiki requires the Perl RCS library. Also, we want to enable the Apache Rewrite module. Run the following as the root user:
    apt-get install librcs-perl
    a2enmod rewrite
  2. You can setup a secured TWiki using information from my previous post, Install TWiki on the OpenSUSE Linux Development Server.
  3. Alternatively, to migrate the TWiki from the old OpenSuSE server to the new Ubuntu server, I did the following:
    (On old server, under /srv/www/htdocs-ssl)
    tar czvf twiki.tar.gz twiki
    (Copy the twiki.tar.gz to the new server.)
    (On new server, under /var/www/htdocs-ssl)
    tar xzvf twiki-files.tar.gz

    chown -R www-data:www-data /var/www/htdocs-ssl/twiki
    chmod -R u+rw /var/www/htdocs-ssl/twiki
    chmod -R g+rw /var/www/htdocs-ssl/twiki

    I also migrated the twiki.conf:

    • Copied it to “/etc/apache2/twiki.conf”.
    • Updated the paths in it from “/srv/www/htdocs-ssl/twiki” to “/var/www/htdocs-ssl/twiki”.
    • To allow running the TWiki configure script remotely, be sure to comment out the restriction below. When you are done, you can uncomment it back.
      #<FilesMatch "^(configure)$">
      #    SetHandler cgi-script
      #    Order Deny,Allow
      #    Deny from all
      #    Allow from localhost
    • Added the following line to “/etc/apache2/sites-enabled/default-ssl”, inside the “VirtualHost” section: “Include /etc/apache2/twiki.conf”.
    • And restarted Apache with “service apache2 restart”.

    Finally, I had to run “https://localhost/twiki/bin/configure” in order to adjust the paths as follows:

    • Under “General path settings”, update {PubDir}, {TemplateDir}, {DataDir}, {LocalesDir}, and {WorkingDir}.
    • Under “Log files”, update {ConfigurationLogName}, {DebugFileName}, {WarningFileName} and {LogFileName}.

    If you encounter problems (like the TWiki not rendering your content), you can refer to the TWiki Upgrade Guide for alternative methods to migrate your TWiki. In the end, I downloaded the latest TWiki version, installed it, configured it, and then merged my “twiki/data” and “twiki/pub” content from the old to the new TWiki.

The info above is consolidated from the following sources:

No Comments

Install Mysql, Apache, and PHP on CentOS 5.6 Linux

Linux 1 Comment

centosRecently, I had to setup a LAMP environment on a temporary CentOS 5.6 Linux server. (CentOS is the open source equivalent to the Red Hat Linux operating system.) Pleasantly, using Yum (Yellow dog Update, Modified), which is the CentOS and Red Hat RPM package manager, makes the task super simple. I did the following tasks while logged into a SSH shell as the root user.

Note: CentOS does not officially support the Sun Java SDK due to a licensing issue (I think). You will need to go through some hoops to get Sun Java SDK working on the CentOS. I attempted to install the latest JDK by downloading and executing the .bin, but it failed with dependency errors. I found this alternative approach, Installing Java (Sun JDK 1.6.0) on CentOS 5, but couldn’t complete it because my CentOS server started throwing segmentation faults and freezing (probably due to OS corruption or a hardware issue).

Change Hostname (Optional)

Run the command line tool “system-config-network” to change the hostname entry. This tool will update “/etc/sysconfig/network” and “/proc/sys/kernel/hostname”. You can run the “hostname” command to double-check.

Install Mysql

Run the following commands:

yum install mysql-server
yum install mysql
yum install mysql-devel

service mysqld start
chkconfig mysqld on

The last two commands will start the MySQL server and configure it to run on boot.

Install Apache

Run the following commands:

yum install httpd mod_ssl

service httpd start
chkconfig httpd on

The Apache Server will have HTTPS/SSL access enabled by default. However, it will use the same htdocs directory “/var/www/html” as the HTTP. To change the HTTPS to use a different document root directory, edit the “/etc/httpd/conf.d/ssl.conf” and add the following:

DocumentRoot "/var/www/html-ssl"
<Directory "/var/www/html-ssl">
   Options Indexes FollowSymLinks
   AllowOverride None
   Order allow,deny
   Allow from all

To have the change take effect, restart the Apache Server by running “service httpd restart”. Check the “/var/log/httpd/ssl_error_log” for errors specific to the HTTPS service.

Install PHP

Run the following commands:

yum install php-common php-gd php-mcrypt php-pear php-pecl-memcache
yum install php-mhash php-mysql php-xml

(You can combine the above packaged into one line if you wish to.)

If you need json_encode and json_decode methods, you will need to install the PHP JSON package. Unfortunately, the CentOS 5.6 Yum installs PHP 5.1 so you cannot run “yum install php-json” because it requires PHP 5.3. To install the JSON package onto PHP 5.1, run the following:

pear install pecl/json
echo "" > /etc/php.d/json.ini
service httpd restart

Good luck and have fun!

The info above is consolidated from:

1 Comment

Setup Android Development on Windows 7 64bit

Windows Development 39 Comments

androidwindowsRecently, I started looking into Android development. What I found was that it was very easy to do Android application development and best of all, it is free (unlike Apple’s $99/year development fee). All you need is a computer, your Android phone, and a USB cable to connect the two. (Actually, you don’t even need a phone because you can use an emulated Android phone.)

Here are the steps I took to setup an Android development environment on my Windows 7 64bit desktop:

  1. Download Java JDK 64bit. I downloaded “jdk-6u24-windows-x64.exe” and ran it to install the JDK.
    • Add these User environment variables by running “Edit the system environment variables”, clicking “Environment Variables” button, and setting the following under “User variables…”:
      JAVA_HOME=C:\Program Files\Java\jdk1.6.0_24
    • Test by opening a command prompt and running “javac -version” to check that Windows can successfully find the javac.exe executable in the PATH.
  2. Download Eclipse 64bit. I downloaded “” and unzipped it to a convenient directory. You can run Eclipse by launching “eclipse.exe”.
  3. Download the Android SDK. I downloaded “” and unzipped it to “C:\Bin\android-sdk-windows”.
    • Important: The Android SDK path must not contain a space!
    • Add these User environment variables using “Edit the system environment variables” like above:

      Note: We just appended the %SDK_ROOT% paths to the existing PATH definition which has the previous %JAVA_HOME% path.

  4. Download the platform files for the Android SDK using the SDK Manager (which is installed as part of the SDK) by following the instructions below.
    • Manually create two folders, “add-ons” and “platforms”, under the %SDK_ROOT% directory. If you don’t, you will see an error like “Error: Error parsing the sdk.” or “Error: C:\Bin\android-sdk-windows\platforms is missing.” in the next step.
    • Run the SDK Manager to download the SDK; look for “SDK Manager.exe” in the %SDK_ROOT% directory. Alternatively you could run from the command line: “android.bat update sdk”.
    • You can use the initial “Choose Packages to Install” dialog to select or reject packages, or you can cancel it and do the following:
      • Select “Available packages” on left.
      • Expand the “Android Repository” on right.
      • Check “Android SDK Platform-tools, revision 3”.
      • Check the Platform, Documentation, or Samples for the Android OS version you want to develop on (which should match the Android OS version on your Android phone). (Eclaire is 2.1, Froyo is 2.2, Gingerbread is 2.3.)
      • For more details on the packages, check the Android SDK Install Guide.
  5. Add the Android Eclipse Plugin (ADT) to Eclipse:
    • Run Eclipse.
    • Select Help->Install New Software…
    • In the “Work with:” field, replace the “type or select a site” with “”.
    • Expand “Developer Tools”.
    • Check the “Android Development Tools” box.
    • Click Next, Next, select Accept License…, click Next.
    • Accept the unsigned warning to continue installation.
    • Restart Eclipse.
  6. Configure the ADT:
    • Under Eclipse, go to menu Windows->Preferences.
    • Select Android
    • In the “SDK Location”, browse to your android install directory %SDK_ROOT%.
    • Hit Apply and you should see the Android platform versions you installed earlier populate the table.

Now that you are all setup, let’s use Eclipse to create a project, build it, and then test it.

  1. Create an Android project:
    • Under Eclipse, go to menu File->New->Project…->Android->”Android Project”.
    • Select the Android version in the “Build Target”.
    • Input the “Project name”, “Application name”, and Activity (the primary java class’s filename). (These can all be the same like “HelloWorld”.)
    • Input the Java package hierarchy like “”.
    • Input the “Min SDK Version” like the 8 for Froyo 2.2’s API Level.
    • Click Finish and the project will be created.
  2. Create an emulated Android for our development purpose.
    • Under Eclipse, go to menu Windows->”Android SDK and AVD Manager”.
    • Select “Virtual devices” on the left.
    • Click the New button on the right.
    • Input a name for your virtual device, select a target which should be the same as your project’s build target.
    • Click on “Create AVD” and close this dialog.
    • Click on the Workbench icon on the top-right or close the Welcome tab to see your newly-created project in the Package Explorer.
  3. Under Eclipse, to build and run the project, click on menu Run->Run.
    • The virtual android device should be selected automatically or you will be prompted to select it.
    • To modify this, check menu Run->”Run Configurations…” and select the Target tab for your Android application. Pick Manual so you can have the option to select a real Android phone instead of the virtual one later.
  4. Connecting an Android phone to your computer
    • You will need to find and install the USB drivers for your Android phone. You can usually find them on the phone manufacturer’s website.
    • Note: If you cannot find your Android phone’s USB drivers for your operating system (for example, Windows 7 64bit), try installing PDAnet. It is a free tethering application which comes with USB drivers for a bunch of phones. Make sure to disconnect the phone before installing PDANet.
    • On the phone, go to Settings->Applications->Development and enable “USB debugging” before reconnecting the phone to the computer. This will allow Eclipse to install onto and debug applications on your Android phone.

Hopefully the guide above will help you get started with Android Development. Have fun!

Info above derived from the following sources: