Archive

Archive for the ‘apache’ Category

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:

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.