Tuesday, July 25, 2006

Plesk and open_basedir

I'm using Plesk as a virtual server solution and have had some quesitons about accessing files outwith the vhosts home httpdocs directory.

This is not possible as default using Plesk. You need to override the open_basedir restriction by placing a file called vhost.conf in the /var/www/vhosts/**domain.com**/conf / directory.
<directory>
php_admin_value open_basedir "/var/www/vhosts/**domain**/httpdocs:/tmp:***directory/***"
</directory>
Save it and then restart the appropriate services with:
sudo /opt/psa/admin/sbin/websrvmng -v -a
You also need to ensure that the domain has PHP safe mode switched off:
Menu -> Domains -> domain.com -> Setup
uncheck the safe mode box (near the bottom of the page)
This will create configuration files for all domains and restart the appropraite services.

Friday, July 07, 2006

Hosting solution

I have been looking around for an appropriate hosting solution to use. I want to set up a server to allow clients to host domains. There are several examples of opensource and commercial software that offer such a facility. I tried a couple and decided that above all, stability was paramount. A close second came security and thirdly and very importantly, ease of use and customer satisfaction.

It boiled down to two solutions, cPanel (which I have used before) and Plesk. And... I decided on the latter. I'm afraid to say that I don't really have any evidence related to which is better - I think I just preferred the examples and demonstration implementations of Plesk.

Sunday, July 02, 2006

SSH tunnel

I needed to connect to a remote Postgres server and the serveradmin was appropriately reluctant to open up post 5432.

Simple solution was to create an ssh tunnel. I'm running a Postgres server locally, so I didn't want to forward port 5432 to the remote machine.
ssh -L5431:localhost:5432 server.with.the.postgres.db

Postgres 7.4

Another small fix for the installation of Postgres 7.4 on Ubuntu Dapper.

After installation and setting up users and a default database, psql got me into the terminal, but I couldn't connect from PgAdminIII.

I tried to connect to the localhost with:
psql -h localhost
This failed, because as default, the TCP/IP socket is set to false. The simple fix is to edit the config file and ensure that the port is set to 5432 and the tcpip_socket is set to true.
sudo pico /etc/postgresql/7.4/main/postgresql.conf
...
port = 5432
tcpip_socket = true

Thursday, June 29, 2006

Postgres setup

Installing Postgres isn't a problem using apt-get but setting up the first user and database had me foxed for a while.

First create a postgres user and database with your username. When using psql, you will open a database with your username as default, so its easier to create the table with your username at the start.
~$ sudo su postgres -c createuser yourusername
~$ sudo su postgres -c createdb yourusername
Now connect to your postgres database and alter the password the user that has just been created.
~$ sudo su postgres -c psql yourusername
=# ALTER USER yourusername WITH PASSWORD 'yourpassword';
=# \q
Don't forget the terminating ; in the SQL call. I found these helpful hints in the postgres manual for version 8.0:
http://www.postgresql.org/docs/8.0/interactive/user-manag.html

Dbase, PHP and Ubuntu

I needed to have PHP compiled with dBase for webdevelopment. dBase was dropped from the standard libraries of Ubuntu at version 5.04 and I couldn't find any solution for installing PHP with dBase support.

I don't imagine this will help the community much, but I had a specific need and finally worked out the solution. Its here mainly for my sanity should I need to replicate it in the future.

NB. It will work for the installation and removal of other PHP components.

Install some packages you'll need later on:
sudo apt-get install shtool dpkg-dev
Download the PHP source file
sudo apt-get source php5
We need to alter the rules to allow PHP compilation with dBase support.
Enter the new PHP directory
Edit the rules file ./debian/rules
Change the COMMON_CONFIG statement
add: "--enable-dbase \"
Now we need to build dependancies and then build PHP. The building of the dependancies requires a significant download and the PHP build tends to take a fair amount of time.
sudo apt-get build-dep php5
sudo dpkg-buildpackage
Once this has finally finished, the .deb files will have been created - if they aren't in the current directory try it's parent.

The final job is to install the new PHP library, copy it to the apache modules folder and then restart apache.
sudo dpkg -i php5*.deb
sudo cp ~/php5-*/apache2-build/libs/libphp5.so /usr/lib/apache2/modules/libphp5.so
sudo /etc/init.d/apache2 restart

Wednesday, June 28, 2006

Apache setup

I also want to be able to setup several virtual hosts on this machine, mainly for testing purposes. I want localhost to point to my website and localccc to point to my local version of www.carrubbers.org which is going to be a testbench.

I didn't want to have the document root as stipulated in the default setup and therefore needed to change the document root and directory definition in /etc/apache2/sites-enabled/000-default. For clarities sake, I also renamed it!