Archive

Archive for the ‘Web server’ Category

Create a custom linux-source-2.6.31 ubuntu 9.10 kernel

November 10th, 2009 2 comments

This is a quick and very dirty how to about building a custom kernel for ubuntu 9.10, it’s based on this how to.

First we make sure our system is up to date:

sudo apt-get update
sudo apt-get upgrade

Now we install all needed packages:

sudo apt-get install linux-source-2.6.31 kernel-package fakeroot kernel-wedge build-essential \
makedumpfile build-dep linux linux libncurses5 libncurses5-dev linux-headers-generic

We unpack the source files to a custom directory in our home directory:

mkdir ~/src
cd ~/src
tar xjvf /usr/src/linux-source-2.6.31.tar.bz2
cd linux-source-2.6.31

We want to reuse the existing config:

cp -vi /boot/config-`uname -r` .config

Now you can customize the kernel:

make menuconfig

Then we can build it:

make-kpkg clean
fakeroot make-kpkg --initrd --append-to-version=custom-1 kernel-image kernel-headers

Ensure that frame buffer drivers are loaded:

echo vesafb | sudo tee -a /etc/initramfs-tools/modules
echo fbcon | sudo tee -a /etc/initramfs-tools/modules

Install the new packages:

dpkg -i linux-image-2.6.31.4custom-1_2.6.31.4custom-1-10.00.Custom_i386.deb
dpkg -i linux-headers-2.6.31.4custom-1_2.6.31.4custom-1-10.00.Custom_i386.deb
Categories: Web server Tags:

Managing apache users on Ubuntu via shell scripts

October 17th, 2009 No comments

I created some shell scripts to add and delete apache web users. You can download them via this post.

This script creates users and requires this webserver setup:
addweb

You also need the following default files:
default-vhost
default-php5-fcgi-starte
php.ini

There is another script to delete users from apache and the system:
dellweb

Installation:

All files have to be saved in the same directory, to run the .sh files they must have proper rights:

chmod +x addweb.sh
chmod +x dellweb.sh

To run the scrips type:

sudo ./addweb username
sudo ./dellweb username

Then follow the dialog. On request the script could be writen dialog free as well.

Categories: Web server Tags:

Install phpPgAdmin on Ubuntu

October 16th, 2009 No comments

In order to use this how to you have to install apache first following this how to. Also postgresql has to be installed, therefore you can follow this how to.

First we create a new user:

useradd -g ftpuser -d /var/www/pga -s /bin/ftp -m pga
chown pga.www-data /var/www/pga
chmod 750 /var/www/pga
mkdir /var/www/pga/conf
mkdir -p /var/www/pga/domain/{cgi-bin,exec,html,log,session,temp}
chmod 770 /var/www/pga/domain/temp
chmod 777 /var/www/pga/domain/session
chmod 700 /var/www/pga/domain/exec
chown -R pga.ftpuser /var/www/pga/*
rm -rf /var/www/pga/.b*
rm -rf /var/www/pga/.p*

Then we create a vHost for the new pga user:

cd /etc/apache2/sites-available/
vim pga

We add the following configuration:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        SuexecUserGroup pga ftpuser
        ServerName www.domain.tld
        ServerAlias more.domains.tld
        DocumentRoot /var/www/pga/domain/html
        DirectoryIndex index.php index.html index.htm

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory />
                Order Deny,Allow
                Deny from All
        </Directory>

        <Directory /var/www/pga/domain/html>
                FCGIWrapper /var/www/php-fcgid-scripts/pga/php-fcgid-starter .php
                Options +ExecCGI
                order allow,deny
                allow from all
        </Directory>
        ErrorLog /var/www/pga/domain/log/apache_error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/www/pga/domain/log/apache_access.log combined
        ServerSignature On
</VirtualHost>

Now we create the fcgi configuration:

cd /var/www/php-fcgid-scripts/
mkdir pga
cd pga
touch php-fcgid-starter
chmod +x php-fcgid-starter
vim php-fcgid-starter

Now we add the configuration:

#!/bin/sh
PHPRC="/var/www/pga/conf"
export PHPRC
PHP_FCGI_CHILDREN=15
export PHP_FCGI_CHILDREN
exec /usr/bin/php5-cgi

We configure the proper rights:

chown -R pga.ftpuser /var/www/php-fcgid-scripts/pga
chmod 755 /var/www/php-fcgi-scripts/pga/php-fcgi-starter
chattr -V +i /var/www/php-fcgid-scripts/pga/php-fcgid-starter

We create a php.ini file for this vHost:

cd /var/www/pga/conf
wget http://www.naumann.cc/wp-content/uploads/2009/10/php.ini
chown root.root php.ini

Now we download the pgaPgAdmin interface:

cd /var/www/pga/domain/
su -m pga
wget http://downloads.sourceforge.net/project/phppgadmin/phpPgAdmin%20%5Bstable%5D/phpPgAdmin-4.2.2/phpPgAdmin-4.2.2.tar.bz2?use_mirror=mesh
tar xjvf phpPgAdmin-4.2.2.tar.bz2

Then we copy all files into the html directory:

mv phpPgAdmin-4.2.2/* html/

Now we have to configure the postgresql server for the usage of phpPgAdmin:

vim /etc/postgresql/8.3/main/postgresql.conf

Ennable the following line:

listen_addresses = 'localhost'

Create a new user for phpPgAdmin:

sudo -u postgres createuser -D -A -P myuser
sudo -u postgres createdb -O myuser mydb

Change the authentication settings in the following file to allow access via phpPgAdmin via this user:

vim /etc/postgresql/8.3/main/pg_hba.conf

Add this line:

local   all         myuser                             md5

before:

local   all         all                               ident sameuser
Categories: PHP, Ubuntu, apache, postgresql Tags:

Install Redmine 0.8.1 on Ubuntu Server 9.04

April 1st, 2009 7 comments

This howto is based on Chris’s howto. It has been tested and modified to work with ubuntu server 9.04.

First we change to root and install the base packages:

sudo su
apt-get install apache2 ruby rubygems subversion ruby-pkg-tools \
ruby1.8-dev build-essential postgresql libdbd-pg-perl libapache2-svn \
libapache-dbi-perl libapache2-mod-perl2 libdigest-sha1-perl \
libopenssl-ruby librmagick-ruby git-core git ruby-dev

Now we install the ruby gems:

gem install rails -v 2.1.2
gem install rake -v 0.8.3
gem install mongrel mongrel_cluster postgres-pr --include-dependencies

We add the gems to $PATH:

echo "export PATH=$PATH:/var/lib/gems/1.8/bin" >> ~/.bashrc

Now we setup the database, there for we first change to the postgres user:

su postgres

Now we create a database user and a database for redmine, in this howto we use redmine as password for the redmine user.

createuser redmine --no-superuser --no-createdb --no-createrole --login --pwprompt --encrypted
createdb --owner=redmine --encoding=utf-8 redmine
exit

We create a user for redmine and some user specific directories:

addgroup redmine
useradd -g redmine -s /bin/false -m redmine

Now we proceed installing redmine it self from svn into a new created directory:

cd /var/www/rails_apps/redmine
svn co http://redmine.rubyforge.org/svn/tags/0.8.1/
ln -s 0.8.1 redmine

We can now configure database access for redmine:

vim /var/www/rails_apps/redmine/config/database.yml

Add the following information:

production:
  adapter: postgresql
  database: redmine
  host: localhost
  username: redmine
  password: redmine

Now we boostrap the database:

rake rails:update
rake db:migrate RAILS_ENV="production"
rake redmine:load_default_data RAILS_ENV="production"

Change some rights:

cd /var/www/rails_apps/redmine
mkdir tmp public/plugin_assets
sudo chown -R redmine:redmine files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets

To configure your email settings change the following file:

vim /var/www/rails_apps/redmine/config/email.yml

Default content:

# Outgoing email settings

production:
  delivery_method: :smtp
  smtp_settings:
    address: smtp.example.net
    port: 25
    domain: example.net
    authentication: :login
    user_name: redmine@example.net
    password: redmine

development:
  delivery_method: :smtp
  smtp_settings:
    address: 127.0.0.1
    port: 25
    domain: example.net
    authentication: :login
    user_name: redmine@example.net
    password: redmine

Now we can try to run redmine from it’s directory:

cd /var/www/rails_apps/redmine
mongrel_rails start --environment=production
or we can use WebRick
ruby script/server webrick -e production

It uses port 3000 as default, thus you can call redmine at:


http://yourIP:3000

To logon, enter username admin and password admin.

If you want to use a svn repository via http you can configure it when creating a project via the redmine interface. If you use https for your repository, you should check it out once locally on the webserver first with the redmine user that has been used to start redmine. You have to accept the certificate permanently, and then redmine can use it as well.

I would suggest to run redmin in a screen session, there fore we install screen.

Using a webdav git repository on Leopard

February 17th, 2009 No comments

This howto should clarify how to use git as a versioning system on a mac.  We use a git repository that has bee installed as described in my previous how to. This how to is strongly based on this kernel.org howto.

First we have to setup our environment, assuming that you have macports installed:

sudo port selfupdate
sudo port install git-core

Now we add our user and host to our .netrc file, to avoid repeated authentication:

vim ~/.netrc

Add the following information to this file:

machine <servername>
login <username>
password <password>

Now set the proper permissions:

chmod 600 ~/.netrc

Now we can create our local git repository, first we add a folder somewhere in our file system:

cd
cd Documents
mkdir my-new-repo.git
cd my-new-repo.git

Before we actually initialize our repository you can add some global info about you to the git environment:

git config --global user.name "Your Name Comes Here"
git config --global user.email you@yourdomain.example.com

You have to add some initial files, by copying them in to:

~/Documents/my-new-repo.git/

And now we initialize our git repository:

cd ~/Documents/my-new-repo.git
git init

Now we can add and commit our files into the repository, you may know this concept from svn:

git add .
git commit

And now the interesting part, interaction with the webdav server, first we have to configure the access:

git config remote.upload.url \

http://<username>@<servername>/my-new-repo.git/

Attention: Keep the trailing slash!

Now we can do the initial push, as you may have noticed commit didn’t send data to the server, as you would have expected it from svn for example. Instead push does.

git push upload master

Hey now there is some data on the server! But probably we want do get data from the server as well, here we can use the pull command:

git pull upload master

But it fails… we have to switch to the server and run the following command in the repository directory:

cd /var/www/my-new-repo.git
git-update-server-info
chown -R www-data.www-data ../my-new-repo.git

It’s a bit strange, but… why not. Now we can pull from our Mac:

git pull upload master

If you initialized the repository others can just clone it, this is an example of cloning:

cd
cd Documents
git clone http://<username>@<servername>/my-new-repo.git

A quick note, if you want to install git on Windows you can use msysgit on linux the setup should be almost the same.

Some Links
tortoisegit
Git on windows
Git on Windows (kerneltrap.org)

Installing git for webdav access the kernel.org way

February 17th, 2009 No comments

This how to is strongly based on the official kernel.org howto. It has been applied to a Ubuntu server 8.10 installation.

First we install apache 2.2:

apt-get install apache2 git-core

We create our repository and the needed data structure:

cd /var/www
mkdir my-new-repo.git
cd my-new-repo.git
git --bare init
chown -R www-data.www-data .

We enable the dav module for apache:

a2enmod dav_fs

Now we configure apache:

vim /etc/apache2/conf.d/git.conf

We can add now the following configuration:

<Location /my-new-repo.git>
        DAV on
        AuthType Basic
        AuthName "Git"
        AuthUserFile /etc/apache2/passwd.git
        Require valid-user
</Location>

Now we can add a user to our git repository:

htpasswd -c /etc/apache2/passwd.git <user>

Now we can restart the apache web server in order to apply our changes:

/etc/init.d/apache2 restart

Installing apache 2.2, proftpd, fcgi and mysql on Ubuntu

February 16th, 2009 No comments

This how to shows you a way to install a LAMP system on a fresh Ubuntu server installation.

First we bring our package management into a current state:

sudo su
apt-get update
apt-get upgrade

Then we can install mysql, php, proftpd and apache:

apt-get install mysql-server mysql-client
apt-get install apache2.2-common apache2-mpm-worker apache2-threaded-dev
apt-get install php5-cgi libapache2-mod-fcgid apache2-suexec php-apc php5-gd php5-imagick
apt-get install proftpd
-> select "Servermode"

Now we create the users and group basic configuration:

addgroup ftpuser
cp /bin/false /bin/ftp
echo "/bin/ftp" >> /etc/shells

We create a user default, that receives all remaining requests:

useradd -g ftpuser -d /var/www/default -s /bin/ftp -m default
chown default.www-data /var/www/default
chmod 750 /var/www/default
mkdir /var/www/default/conf
mkdir -p /var/www/default/domain/{cgi-bin,exec,html,log,session,temp}
chmod 770 /var/www/default/domain/temp
chmod 777 /var/www/default/domain/session
chmod 700 /var/www/default/domain/exec
chown -R default.ftpuser /var/www/default/*
rm -rf /var/www/default/.b*
rm -rf /var/www/default/.p*

We can create now an Apache vHost for the default user:

cd /etc/apache2/sites-available/
a2dissite default
rm def* -> remove the old default configuration
vim default

You can insert this configuration for default:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        SuexecUserGroup default ftpuser
        ServerName www.domain.tld
        ServerAlias more.domains.tld
        DocumentRoot /var/www/default/domain/html
        DirectoryIndex index.php index.html index.htm

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory />
                Order Deny,Allow
                Deny from All
        </Directory>

        <Directory /var/www/default/domain/html>
                FCGIWrapper /var/www/php-fcgid-scripts/default/php-fcgid-starter .php
                Options +ExecCGI
                order allow,deny
                allow from all
        </Directory>
        ErrorLog /var/www/default/domain/log/apache_error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/www/default/domain/log/apache_access.log combined
        ServerSignature On
</VirtualHost>

First we make the general fcgi configuration:

cd /etc/apache2/mods-available
vim fcgid.conf

We can use the following configuration:

<IfModule mod_fcgid.c>
  AddHandler fcgid-script .php
  SocketPath /var/lib/apache2/fcgid/sock
  IPCConnectTimeout 20
</IfModule>

Then we can configure fcgi for the user:

a2enmod suexec
cd /var/www
mkdir php-fcgid-scripts
chown root:root /var/www/php-fcgid-scripts
cd php-fcgid-scripts
mkdir default
cd default
touch php-fcgid-starter
chmod +x php-fcgid-starter
vim php-fcgid-starter

We can use the following configuration:

#!/bin/sh
PHPRC="/var/www/default/conf"
export PHPRC
PHP_FCGI_CHILDREN=15
export PHP_FCGI_CHILDREN
exec /usr/bin/php5-cgi

Now you should assign the proper rights to it:

chown -R default.ftpuser /var/www/php-fcgid-scripts/default
chmod 755 /var/www/php-fcgid-scripts/default/php-fcgid-starter
chattr -V +i /var/www/php-fcgid-scripts/default/php-fcgid-starter

We create a php.ini file for this vHost:

cd /var/www/default/conf
wget http://www.naumann.cc/wp-content/uploads/2009/02/php.ini
chown root.root php.ini

Now we can test it:

cd /var/www/default/domain/html
touch index.php
echo "<? phpinfo(); ?>" >> /var/www/default/domain/html/index.php
chown default.ftpuser /var/www/default/domain/html/index.php
a2ensite default
/etc/init.d/apache2 restart

Now you can call www.domain.tld with your favorite browser.

Installing turbinado

February 9th, 2009 1 comment

This is a how to for all that want to install turbinado on a fresh Ubuntu server 8.10 with OpenSSH Server selected.

First get your distribution into a current state:

sudo su
apt-get update
apt-get upgrade

Install needed packages:

apt-get install libedit-dev darcs git-core libgmp3-dev zlib1g-dev postgresql postgresql-server-dev-8.3 happy make libffi-dev

Install the current 6.10.1 version of ghc, the version of the package system is currently still 6.8.2

cd /usr/local/src
wget http://haskell.org/ghc/dist/6.10.1/ghc-6.10.1-i386-unknown-linux-libedit2.tar.bz2
tar xjvf ghc-6.10.1-i386-unknown-linux-libedit2.tar.bz2
cd ghc-6.10.1
./configure
make install

The next step is to install cabal:

cd /usr/local/src
wget http://www.haskell.org/cabal/release/cabal-1.6.0.2/Cabal-1.6.0.2.tar.gz
tar xzvf Cabal-1.6.0.2.tar.gz
cd Cabal-1.6.0.2
ghc --make Setup
./Setup configure
./Setup build
sudo ./Setup install

Now install the helpfull cabal-install tool, which is a package management for haskell libraries.

We can install the latest version from darcs:

cd /usr/local/src
darcs get --partial http://darcs.haskell.org/cabal-install/
cd cabal-install
sh bootstrap.sh

Or install the tar package:

cd /usr/local/src
wget http://www.haskell.org/cabal/release/cabal-install-0.6.2/cabal-install-0.6.2.tar.gz
tar xzvf cabal-install-0.6.2.tar.gz
cd cabal-install-0.6.2
sh bootstrap.sh

Because we installed all packages to our home directory, we have to add this directory to our environment, we can do this by adding the path as follows:

vim /etc/environment
–> Add youre local bin path and reload the path (we have to reboot anyway because of previous kernel upgrades)
I had to add the following path: /root/.cabal/bin/
reboot

or:

echo "export PATH=$PATH: /root/.cabal/bin/" >> ~/.bashrc

Now we can use cabal to install libraries, but first we have to update cabal.

cabal update

Because of some problems with the cabal crypt package I had to build the crypt package directly from the repository:

cd /usr/local/src
darcs get http://code.haskell.org/crypto
cd crypto
cabal install

Now we install the HDBC driver that allows us to connect to databases:

cd /usr/local/src
wget http://hackage.haskell.org/packages/archive/HDBC/2.1.0/HDBC-2.1.0.tar.gz
tar xzvf HDBC-2.1.0.tar.gz
cd HDBC-2.1.0
cabal install

Now we can finally install the turbinado web server via cabal:

cd /usr/local/src
git clone git://github.com/alsonkemp/turbinado-website.git
cd turbinado-website
cabal install

Database setup info (to be added)

We have to hide the HTTP-4000 package:

ghc-pkg hide HTTP-4000.0.4

And now we can run it:

cd /usr/local/src/turbinado-website
turbinado -p 8080
-> this will start turbinado and makes it listen to port 8080

Now you can open the turbinado wesite in your favorite browser:

http://your-webserver-ip-or-name:8080/Home