Archive

Archive for October, 2009

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 postgresql on Ubuntu with php5

October 16th, 2009 No comments

In this installation we integrate postgresql into this apache installation.

First we refresh our package management and our packages:

apt-get update
apt-get upgrade

Then we have to install the basic packages:

apt-get install postgresql postgresql-server-dev-8.3 php5-pgsql

Now we have to do the basic setup of the postgresql server:

sudo -u postgres psql template1

Now you can define a passwort for the postgres user:

\password postgres

To leave the prompt enter:

\q
Categories: PHP, Ubuntu, postgresql 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 a dyndns client on Ubuntu

October 16th, 2009 No comments

This how to will guide you through the process of installing a dynamic dns service client on Ubuntu.

First we update our package manager:

apt-get update
apt-get upgrade

Now that we have a current system we can install the new package:

apt-get install ddclient

Select your dyndns provider from the list, for me it’s www.dyndns.com.

Enter the domain name that should be updated into the following field.

Enter your user name and password.

In the next dialog you have to enter the network device whos ip where the domain name should be resolved to.

For me this is eth0.

You can change the settings also via the config file:

vim /etc/ddclient.conf

My file looks as follows:

# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf

pid=/var/run/ddclient.pid
protocol=dyndns2
use=if, if=eth0
server=members.dyndns.org
login=username
password='password'
host.dyndns.biz
Categories: Ubuntu, dyndns Tags: