Webserver with CMS

From Teknologisk videncenter
Revision as of 10:52, 3 May 2012 by Okdios (talk | contribs) (Created page with "'''Ubuntu:''' The first thing we did, was to install Ubuntu. We used the new LTS version, 12.04. '''Apache (LAMP):''' Next thing was to install Apache, MySQL and PHP. We used ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Ubuntu: The first thing we did, was to install Ubuntu. We used the new LTS version, 12.04.


Apache (LAMP): Next thing was to install Apache, MySQL and PHP. We used the easy way, by selecting the LAMP stack during installation of Ubuntu. If you forget to select it during installation, simply type 'tasksel' in a shell, and you get the same menu where you can select LAMP.


SSL: We have set up our server to be apple to work with encrypted traffic. To do this we had to enable SSL. Commands to do this: generate keys for CSR (Certificate Signing Request)

  • openssl genrsa -des3 -out server.key 1024

Create insecure key

  • openssl rsa -in server.key -out server.key.insecure
  • mv server.key server.key.secure
  • mv server.key.insecure server.key

Create the CSR

  • openssl req -new -key server.key -out server.csr

Sign the certificate

  • openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Copy the files to the right dirs

  • cp server.crt /etc/ssl/certs
  • cp server.key /etc/ssl/private

Enable SSL

  • a2enmod ssl

enable certifikate file

  • a2ensite "filename"

disable certifikate file

  • a2dissite "filename"

Reload apache server

  • service apache2 reload


Tomcat: To install Tomcat, we first had to make sure Java was installed:

  • apt-get install openjdk-7-jre

Then we could install Tomcat, with these commands (including documentation):

Drupal (CMS): We read about different CMS', and we agreed that Drupal seemed to be the best choice for us.

  • It s very easy to install.
  • The administrator panel is quite easy to navigate in.
  • It is easy to create new content.
  • There are themes/plugins for every need.
  • It is possible to include php and javascript code directly in your page content.

The installation was done in a few easy steps.

  1. Download and extract latest version of Drupal from their website.
  2. Create a database.
  3. Point a browser to your server, and follow instructions.

That's it!


NOAA Weather information: We have created a script, which we run hourly on the server. The script fetches a textfile with weather information from Karup. The information from this textfile is parsed, and formatted to be easier to read (This is done with a small php script).


DNS: To setup our server to act as a DNS server, we installed bind9 (apt-get install bind9). To configure it, we needed to change some configuration files to look like this: /etc/bind/named.conf.local looks like this:

# Our domain zone
zone "mo-web.local"
{
    type master;
    file "/etc/bind/zones/mo-web.local.db";
};
# For reverse DNS
zone "0.0.10.in-addr-arpa"
{
    type master;
    file "/etc/bind/zones/rev.0.0.10.in-addr.arpa";
};

in /etc/bind/named.conf.options, uncomment this section, and add some DNS servers:

forwarders {
		8.8.8.8;
                8.8.4.4;
                0.0.0.0;
	};

/etc/bind/zones/mo-web.local.db looks like this:

$TTL  604800
@     IN       SOA      ns.mo-web.local.   root.mo-web.local. (
                                 8                ; Serial
                            604800                ; Refresh
                             86400                ; Retry
                           2419200                ; Expire
                            604800  )             ; Negative Cache TTL
;
@       IN      NS         mo-web.local.
@	IN	A	   192.168.139.128	
ns      IN      A          192.168.139.128
www	IN	A	   192.168.139.128

And finally /etc/bind/zones/rev.0.0.10.in-addr.arpa:

$TTL 3D
@        IN         SOA         ns.mo-web.local.   admin.mo-web.local.  (
                    2007062001  
                    28800
                    604800
                    604800
                    86400
)
         IN         NS           ns.mo-web.local.
2        IN         PTR          ubuntu.mo-web.local

FTP: We used vsftpd as ftp server:

  • apt-get install vsftpd

Then we changed the configuration file (/etc/vsftpd.conf) on the following lines:

// disable anonymous logins
anonymous_enable=NO
// enable login for local users
local_enable=YES
// local users will only have access to their home dir
chroot_local_user=YES

restart ftp server

  • service vsftpd restart

Finally we created a user with rights to /var/www/ (by setting home dir to /var/www/):

  • useradd -d /var/www/ -m paul
  • passwd paul