dboettger's Blog

Archive for the ‘PHP’ Category

As we are decided to use the great AEgir hosting system for all upcoming Drupalprojects i needed to migrate some sites from standalone installations to our new Aegir hosting system.

First i needed to backup the tables in my mysql database. My database’s name was drupal ( not that good idea ) and i was using table prefixes ( this idea was even worse 😉 ).
The tableprefix of the website was website_
Only the tables were exported, not the CREATE DATABASE!
After exporting the tables into the drupal.sql file i opened the file with a editor, searched for website_ and replaced it with an empty string.

I created the folder /var/aegir/drupal-website as user aegir on myaegirHost.

su - aegir
mkdir drupal-website

Then i copied all the content of the drupalfolder from my standalone drupalsystem to my aegirhost.

cd /var/www/drupal
scp -r * aegir@myaegirHost:/var/aegir/drupal-website

Then i needed to copy and import the mysql database.

Source host:
scp drupal.sql aegir@myaegirHost:/var/aegir/

Target host:
mysql -u root -p
CREATE DATABASE drupal;
GRANT ALL ON drupal.* TO 'drupal'@localhost IDENTIFIED BY 'drupal';
exit
mysql -u root -p -D drupal < drupal.sql

After the database and all the files has been created i created a new platform in Aegir called drupal-website and entered the folder /var/aegir/drupal-website.
Aegir then creates the new platform and imports all sites from the platform.

Then i migrated all the sites to another platform. The manually created database called drupal gets renamed to the Aegir – style site_NUMBER scheme.

If there are any missing modules for a single site (shown under the migration tab), it’s possible to add the modules on a per site base with drush.

su - aegir
cd /var/aegir/drupal-website/sites/website
/var/aegir/drush/drush.php dl modulename

After installing the missing modules it was still showing missing in the Aegir migration tab. I ignored that and clicked on the button migrate. After two minutes the site was moved to the new platform.

If u need any further assistance, don’t hesitate to contact me!

Greetings,

Dom

Advertisements

Again a quick documentation about my installation on my Macbook


curl -O ftp://ftp.cac.washington.edu/imap/imap.tar.gz
tar xvzf imap.tar.gz
cd imap-2007e
./configure
make
sudo mkdir -p /usr/local/imap-2007e/include /usr/local/imap-2007e/lib
sudo cp c-client/*.h /usr/local/imap-2007e/include/
sudo cp c-client/*.c /usr/local/imap-2007e/lib/
sudo cp c-client/c-client.a /usr/local/imap-2007e/lib/libc-client.a

curl -O http://heanet.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
curl -O http://www.ijg.org/files/jpegsrc.v8.tar.gz
curl -O http://freefr.dl.sourceforge.net/project/libpng/00-libpng-stable/1.2.42/libpng-1.2.42.tar.gz
curl -O http://de.php.net/distributions/php-5.3.1.tar.gz

tar xvzf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
sudo make install

tar xvzf jpegsrc.v8.tar.gz
cd jpeg-8
./configure
make
sudo make install

tar xvzf libpng-1.2.42.tar.gz
cd libpng-1.2.42
./configure
make
sudo make install

tar xvzf php-5.3.1.tar.gz
cd php-5.3.1
./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-apxs2=/usr/sbin/apxs --sysconfdir=/private/etc --with-config-file-path=/etc --with-ldap=/usr --with-ldap-sasl=/usr --with-libxml-dir=/usr --with-kerberos=/usr --with-curl=/usr --with-zlib-dir=/usr --enable-bcmath --enable-exif --enable-exif --with-bz2=/usr --enable-ftp --with-openssl=/usr --enable-mbstring --enable-mbregex --enable-calendar --enable-sockets --with-iodbc=/usr --with-curl=/usr --sysconfdir=/private/etc --with-mysqli=mysqlnd --with-mysql=mysqlnd --with-xmlrpc --with-xsl=/usr --with-pear --with-libxml-dir=/usr --with-iconv=/usr --with-pdo-mysql=mysqlnd --with-gd --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop --with-xsl=/usr --with-iconv-dir=/usr --with-iodbc=/usr --with-snmp=/usr --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-iconv=/usr --with-pcre-regex --with-imap=/usr/local/imap-2007e --with-imap-ssl --with-mcrypt=/usr/local --enable-soap --enable-cli --with-pear
make
sudo make install

sudo nano /etc/apache2/httpd.conf

Uncomment the following line:
#LoadModule php5_module libexec/apache2/libphp5.so
to
LoadModule php5_module libexec/apache2/libphp5.so

Restart Apache!

sudo apachectl restart

Updated Guide with php 5.3.1

MySQL

Just install the package from mysql.com.

Macports

First install the Macport from macports.org. You also need the Apple developer tools to compile software. The developmentkit from apple ships with the wonderful gcc compiler 😉 .

After you install macports ( a package management for MacOSX) you are able to install the needed libraries. Just execute the following commands:

sudo port install jpeg
sudo port install libpng
sudo port install freetype
sudo port install mcrypt
sudo port install libiconv
sudo port install cclient

Oracle Installation (Instantclient only):

Download the oracle client basic Version 10.2 and SDK 10.2 from the Oracle download page.
Move the extracted files to /opt/instantclient_10_2.

export LD_LIBRARY_PATH=/opt/oracle/instantclient_10_2/sdk/include/:/opt/oracle/instantclient_10_2:.

cd /opt/instantclient_10_2
ln -s libclntsh.dylib.10.1 libclntsh.dylib
ln -s libclntsh.dylib libclntsh.so

export NLS_LANG=”American_America.UTF8″
export DYLD_LIBRARY_PATH=/opt/instantclient_10_2

Download php 5.3.1 from php.net.
Extract the php sourcefile into a diretory.

./configure –prefix=/usr –with-apxs2=/usr/sbin/apxs –with-ldap=/usr –with-kerberos=/usr –with-zlib-dir=/usr –enable-exif –enable-ftp –enable-mbstring –enable-mbregex –enable-sockets –with-iodbc=/usr –with-curl=/usr –with-config-file-path=/etc/php5/php5.3.1-apache2 –sysconfdir=/private/etc –with-mysqli=mysqlnd –with-mysql=mysqlnd –with-openssl=shared,/opt/local –with-xmlrpc –with-xsl=/usr –with-pear –with-libxml-dir=/usr –with-iconv=shared,/opt/local –with-pdo-mysql=mysqlnd –with-gd –with-jpeg-dir=/opt/local –with-png-dir=/opt/local –with-freetype-dir=/opt/local –with-mcrypt=/opt/local –with-imap=/opt/local –with-imap-ssl –enable-soap –with-oci8=instantclient,/opt/instantclient_10_2 –with-pdo-oci=instantclient,/opt/instantclient_10_2,10.2.0.4 –enable-cli –with-pear

We have to edit the Makefile to run a successful compile.

nano Makefile
Edit the line with the EXTRA_LIBS = ….. stuff.
Add -lresolv to the line, save and exit the file.

After editing the Makefile we are able to compile the binaries. Just enter make to execute the compilation.

If make was successful we have to execute make install as superuser. The command sudo make install is our friend 😉 .

We have to create the following directory and link the library to it. Don’t ask just the strange oraclestuff.
mkdir -p /b/32_216/rdbms/lib
ln -s /opt/instantclient_10_2/libclntsh.dylib.10.1 /b/32_216/rdbms/lib/

Apache configuration

The last modification we have to add is the initconfiguration of the apacheservice. We need some variables set in the runtime environment.

We will edit the /System/Library/LaunchDaemons/org.apache.httpd.plist file like that or something similar for you locales.

nano /System/Library/LaunchDaemons/org.apache.httpd.plist

 

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple Computer//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”&gt;
<plist version=”1.0″>
<dict>
<key>Disabled</key>
<true/>
<key>Label</key>
<string>org.apache.httpd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/httpd</string>
<string>-D</string>
<string>FOREGROUND</string>
</array>
<key>OnDemand</key>
<false/>
<key>SHAuthorizationRight</key>
<string>system.preferences</string>
<key>EnvironmentVariables</key>
<dict>
<key>DYLD_LIBRARY_PATH</key>
<string>/opt/instantclient_10_2</string>
<key>TNS_ADMIN</key>
<string>/opt/oracle/tns</string>
<key>LANG</key>
<string>de_DE.UTF-8</string>
<key>NLS_LANG</key>
<string>GERMAN_GERMANY.UTF8</string>
</dict>
</dict>
</plist>

 

I hope i was able to help you guys. If you have any question, don’t hesitate to contact me or post some comments.

APC is a free, open, and robust framework for caching and optimizing PHP intermediate code. — http://pecl.php.net/package/APC

The Installation of APC – Cache is quite easy. I assume you already have the Xcode development tools installed on your system and possibly compiled php on your own.

Just open the Terminal.

sudo pecl install apc

The following question should pop up. Please answer with yes:

Use apxs to set compile flags (if using APC with Apache)? [yes] : yes

After the installation completes, just edit the php.ini under /etc.

nano /etc/php.ini

In the extensions subsection just add following line:

extension=apc.so

Last year on the PHP Conference in Mainz it was the first time i heard about couchdb. I was quite impressed, but had no use case for this database. In the near future i will need to improve our document handling in the applications. So i want to work with couchdb to improve versioning and searching.

You can find more information about couchdb on http://couchdb.apache.org.

As anybody know, the first step is to install the couchdb on the local system. As i am a apple follower ;-). I looked for a guide to install it on snow leopard.

Original information from http://blog.deadinkvinyl.com/2008/07/12/couchdb-on-macosx-leopard/

I did some corrections for the copy and paste guys like me ;-). But the original post has much more information about the single steps.

# Install needed packages via macports
sudo port install icu erlang spidermonkey

# Download the latest couchdb file
tar xvzf apache-couchdb-0.10.0.tar.gz
./configure
make

sudo make install

# Show all used userId’s
dscl . -list /Users UniqueID | awk ‘{print $2}’ | sort -n

# Show all used groupId’s
dscl . -list /Groups PrimaryGroupID | awk ‘{print $2}’ | sort -n

# We use groupid and userid 103 for the couchdbuser
sudo dseditgroup -o create -i 103 -r “CouchDB Users” couchdb
sudo dscl . -create /Users/couchdb
sudo dscl . -create /Users/couchdb UniqueID 103
sudo dscl . -create /Users/couchdb UserShell /bin/bash
sudo dscl . -create /Users/couchdb RealName “CouchDB Administrator”
sudo dscl . -create /Users/couchdb NFSHomeDirectory \
/usr/local/var/lib/couchdb
sudo dscl . -create /Users/couchdb PrimaryGroupID 103
sudo dscl . -create /Users/couchdb Password *

sudo chown -R couchdb:couchdb /usr/local/var/lib/couchdb
sudo chown -R couchdb:couchdb /usr/local/var/log/couchdb

# Startup couchdb

sudo -u couchdb couchdb

Create a copy of the plist file and edit it.

cp /usr/local/Library/LaunchDaemons/org.apache.couchdb.plist \
/var/tmp/org.apache.couchdb.plist
open /var/tmp/org.apache.couchdb.plist

1. Open Root → EnvironmentVariables
2. Click on Add Child
3. Name: PATH
4. Value: /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin
5. File → Save
6. Quit Property List Editor

sudo cp /var/tmp/org.apache.couchdb.plist \
/usr/local/Library/LaunchDaemons/org.apache.couchdb.plist

# To control the database, simply execute
sudo launchctl load \
/usr/local/Library/LaunchDaemons/org.apache.couchdb.plist
# to start
# or
sudo launchctl unload \
/usr/local/Library/LaunchDaemons/org.apache.couchdb.plist
# to stop the database

# Automatically launch
sudo ln -s /usr/local/Library/LaunchDaemons/org.apache.couchdb.plist \
/Library/LaunchDaemons/org.apache.couchdb.plist

MySQL

Just install the package from mysql.com.

Macports

First install the Macport from macports.org. You also need the Apple developer tools to compile software. The developmentkit from apple ships with the wonderful gcc compiler ;-).

After you install macports ( a package management for MacOSX) you are able to install the needed libraries. Just execute the following commands:

sudo port install jpeg
sudo port install libpng
sudo port install freetype
sudo port install mcrypt
sudo port install libiconv
sudo port install cclient

Oracle Installation (Instantclient only):

Download the oracle client basic Version 10.2 and SDK 10.2 from the Oracle download page.
Move the extracted files to /opt/instantclient_10_2.

export LD_LIBRARY_PATH=/opt/oracle/instantclient_10_2/sdk/include/:/opt/oracle/instantclient_10_2:.

cd /opt/instantclient_10_2
ln -s libclntsh.dylib.10.1 libclntsh.dylib
ln -s libclntsh.dylib libclntsh.so

export NLS_LANG=”American_America.UTF8″
export DYLD_LIBRARY_PATH=/opt/instantclient_10_2

Download php 5.2.11 from php.net.
Extract the php sourcefile into a diretory.

./configure –prefix=/usr –with-apxs2=/usr/sbin/apxs –with-ldap=/usr –with-kerberos=/usr –enable-cli –with-zlib-dir=/usr –enable-exif –enable-ftp –enable-mbstring –enable-mbregex –enable-sockets –with-iodbc=/usr –with-curl=/usr –with-config-file-path=/etc –sysconfdir=/private/etc –with-mysql-sock=/var/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-mysql=/usr/local/mysql –with-openssl=shared,/opt/local –with-xmlrpc –with-xsl=/usr –with-pear –with-libxml-dir=/usr –with-iconv=shared,/opt/local –with-pdo-mysql=/usr/local/mysql/bin/mysql_config –with-gd –with-jpeg-dir=/opt/local –with-png-dir=/opt/local –with-freetype-dir=/opt/local –with-mcrypt=/opt/local –with-imap=/opt/local –with-imap-ssl –enable-soap –with-oci8=instantclient,/opt/instantclient_10_2 –with-pdo-oci=instantclient,/opt/instantclient_10_2,10.2.0.4

We have to edit the Makefile to run a successful compile.

nano Makefile
Edit the line with the EXTRA_LIBS = ….. stuff.
Add -lresolv to the line, save and exit the file.

After editing the Makefile we are able to compile the binaries. Just enter make to execute the compilation.

If make was successful we have to execute make install as superuser. The command sudo make install is our friend ;-).

We have to create the following directory and link the library to it. Don’t ask just the strange oraclestuff.
mkdir -p /b/32_216/rdbms/lib
ln -s /opt/instantclient_10_2/libclntsh.dylib.10.1 /b/32_216/rdbms/lib/

Apache configuration

The last modification we have to add is the initconfiguration of the apacheservice. We need some variables set in the runtime environment.

We will edit the /System/Library/LaunchDaemons/org.apache.httpd.plist file like that or something similar for you locales.

nano /System/Library/LaunchDaemons/org.apache.httpd.plist

<code>

<!DOCTYPE plist PUBLIC “-//Apple Computer//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”&gt;
<plist version=”1.0″>
<dict>
<key>Disabled</key>
<true/>
<key>Label</key>
<string>org.apache.httpd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/httpd</string>
<string>-D</string>
<string>FOREGROUND</string>
</array>
<key>OnDemand</key>
<false/>
<key>SHAuthorizationRight</key>
<string>system.preferences</string>
<key>EnvironmentVariables</key>
<dict>
<key>DYLD_LIBRARY_PATH</key>
<string>/opt/instantclient_10_2</string>
<key>TNS_ADMIN</key>
<string>/opt/oracle/tns</string>
<key>LANG</key>
<string>de_DE.UTF-8</string>
<key>NLS_LANG</key>
<string>GERMAN_GERMANY.UTF8</string>
</dict>
</dict>
</plist>

</code>

I hope i was able to help you guys. If you have any question, don’t hesitate to contact me or post some comments.


Tweets

Advertisements