Skip to content

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

568ubuntuWe 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 http://archive.canonical.com/ubuntu lucid partner
    deb-src http://archive.canonical.com/ubuntu 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/

      SSLRequireSSL

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

      Require valid-user
    </Location>

    “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
      #</FilesMatch>
    • 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:

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *