01 July 2011

Installing openSuse as a Web Server

I recently set up a webserver using openSuse. Whilst I used to use Debian Linux for Java web hosting that was a while ago and I’ve forgotten a lot of the things that were a bit annoying to figure out/remember. If you’re like me and have been dealing with Windows machines for a bit too long I hope these pointers come in handy.

For the uninitiated openSuse is an open source version (distribution) of Linux. It is distributed as 32bit or 64 bit so you need to know which version to choose. If you don’t know then it’s likely to be 32 bit.

These instructions are for the latest version (11.4) as at writing.

A Note on System Administration with YaST

OpenSuse uses a program called YaST to manage the computer’s setup. To load the YaST control center: click on Application Launcher (green orb bottom left); select computer and YaST. It will ask for an admin/root password before loading. If you don’t supply one it will time out and not load.

Sometimes I find it looks like it’s going to load and then just simply doesn’t! Annoying, but you can run it from a terminal window by typing:
sudo /sbin/yast2
and entering the root password.

A note for Windows users

penSuse uses one-click to select, not two, so the Application Launcher is selected by clicking but the sub menus are selected by hovering over the icon, however their sub menus are selected by clicking!

OpenSuse Installation

  1. Download it here:
    http://www.opensuse.org/
    This will take a while so come back after you’ve had some tea!
  2. Install by mounting the ISO e.g. if you’re using a virtual machine or ripping the image to a CD/DVD.
  3. Boot from the image.

Desktop Effects

I like to disable these as I don’t think they add much and they really slow things down, especially via a remote connection:

  1. Load Applications/System Settings.
  2. Under ‘Workspace Appearance and Behaviour’ click ‘Desktop Effects’ and select disable at the top.

Network Access

Before you can do anything you need to update it… before you do that you need to check you have network access. Load up a browser and see if you can load Google or BBC home page. You can also run the command: /sbin/ifconfig to show the IP config information.
If not then in YaST:

    1. Select Network Devices/Network Settings
    2. Under Overview, select the relevant ethernet controller and ensure it is starting at boot, assigned DHCP and assigned to the ‘External Zone’ (if these settings are appropriate).
    3. Under Hostname/DNS enter the Hostname (I use server name) and Domain Name (I have a domain name I use for internal stuff or you can make one up).
    4. Check you have network access using a browser.

VNC

I needed remote access as I run the machine headless (without monitor). In YaST:

  1. Select Network Services/Remote Administration (VNC) and enable, also enable the rules in the firewall.
  2. Connect using a client like TightVNC and connecting to [openSuse IP address]:1 (the :1 essentially denotes ‘desktop 1’)
    You can find the IP address by running /sbin/ifconfig

As of writing there seems to be a problem between TightVNC client and IPv4 and IPv6 entries in the /etc/hosts file. To fix this give the IPv4 line an alias:

  1. sudo vi /etc/hosts
  2. Edit the line: 127.0.0.1 localhost
    to become: 127.0.0.1 localhost ipv4-localhost
    (press i to insert then Esc :wq to save and exit)
  3. Then in YaST/Network Services/Network Services (xinetd) edit the Service vnc1 to be:
    -noreset -inetd -query ipv4-localhost -geometry 1024×768 -depth 16

I found the solution here: http://dx3webs.com/wordpress/2010/03/how-to-fix-vnc-in-opensuse-11-2/

Updates

  1. Either configure auto updates or apply manually. In YaST.
    1. Configure automatic updates (I’d recommend):
      1. Select Software in the left hand pane and ‘Software Management’ in the right hand one.
      2. In the search box that appears enter ‘update’ without the quotes and click search.
      3. Scroll to the bottom of the search results and tick ‘yast2-online-update-configuration
      4. Restart YaST and you should see
    2. OR apply manually:
      1. Select YaST/Software/Online Update
      2. It will come up with a list of updates (mine had 90+). Click Apply.
        It may ask for the root password and some T&Cs acceptance, more than once… hence the recommendation to auto update.

Time Sync (UTP)

I like to set up a time server sync so that the system always remains up to date:

  1. YaST/Network Services/NTP Configuration
  2. Start NTP Daemon ‘Now and on Boot’
  3. Add Server Sync with a suitable address (when entering choose ‘Select’ to choose from a list) e.g. uk.pool.ntp.org

Web Server

I use Apache but their are other alternatives out there. In YaST:

    1. Open Software/Software Management.
    2. Enter http and click search.
    3. Select yaast2-htttp-server (a configuration package). It will require other packages (the actual apache server ones) so just accept those too.
    4. Once installed restart YaST and run the configuration wizard under Network Services/HTTP Server.

AppCache files

AppCache manifest files are part of HTML5 and need to be served as mime type text/appcache which unfortunately they are not by either IIS or Apache by default as of writing (er why?!). Add:
AddType text/cache-manifest .appcache
to the relevant config file (server config, virtual host, directory or .htaccess). e.g.

  • In a terminal window type: sudo vi /etc/apache2/httpd.conf.local
  • Press i to enter insert mode
  • Type: AddType text/cache-manifest .appcache
  • Press Esc then type :wq Enter to save and quit
  • sudo vi /etc/sysconfig/apache2
  • Navigate to APACHE_CONF_INCLUDE_FILES=””
  • Enter /etc/apache2/httpd.conf.local
  • Esc :wq Enter to quit, then restart Apache

putting its name into APACHE_CONF_INCLUDE_FILES in
#       /etc/sysconfig/apache2 -- this will make system updates
#       easier :)


See:
http://httpd.apache.org/docs/current/mod/mod_mime.html#AddType
For more information on appcache files see:
http://www.html5rocks.com/en/tutorials/appcache/beginner/

Mono

To run .Net applications you’ll need Mono (http://www.mono-project.com/) installed:

  1. Open Software/Software Management.
  2. Enter mono and click search.
  3. Install apache2-mod_mono and other packages
  4. Run command:
    sudo a2enmod mono
    to load the module into Apache.

Or you can use the installer: http://www.mono-project.com/InstallerInstructions

More on Mod_mono here: http://www.mono-project.com/Mod_mono

FTP Server

I wanted an FTP server so I can upload files tot he server without having to configure file sharing. In YaST:

  1. Open Software/Software Management.
  2. Enter ftp and click search.
  3. Click the boxes next to pure-ftp and yast2-ftp-server (the latter is used to configure pure) and click Accept.
  4. Restart YaST and under Nework Services you should now be able to configure FTP.

TFTP

I also wanted to be able to boot machines from this, using TFTP:

  1. YaST/Software Management/Search: tftp
  2. Select yast2-tftp-server (Configuration), accept and install.
  3. Restart YaST and go to Network Services/TFTP, and it will request installing more packages, so install them.
  4. Configure as enabled and open port in firewall

You might also like to configure your local DNS to resolve tftp.[your domain] to resolve to that server’s IP.

No comments:

Post a Comment