<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Johan&#039;s Blog &#187; PHP</title>
	<atom:link href="http://blog.johan-mares.be/category/ict/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.johan-mares.be</link>
	<description>A personal blog</description>
	<lastBuildDate>Sat, 24 Jul 2010 18:35:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Installing Zend Server CE on Ubuntu</title>
		<link>http://blog.johan-mares.be/ict/php/installing-zend-server-ce-on-ubuntu/</link>
		<comments>http://blog.johan-mares.be/ict/php/installing-zend-server-ce-on-ubuntu/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 09:49:44 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.johan-mares.be/?p=315</guid>
		<description><![CDATA[Just as I was finishing my review of the beta version of Zend Server CE, Zend proudly announced the release of Zend Server and Zend Server Community Edition (CE). So I had to start all over again with a fresh installation of Zend Server CE 4.0.1. I was pleased to see that they fixed some of the quirks and bugs I had encountered in the beta version, but oddly enough they introduced some new ones too.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.johan-mares.be%2Fict%2Fphp%2Finstalling-zend-server-ce-on-ubuntu%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.johan-mares.be%2Fict%2Fphp%2Finstalling-zend-server-ce-on-ubuntu%2F&amp;source=maresjohan&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Just as I was finishing my review of the beta version of Zend Server CE, Zend proudly announced the release of Zend Server and Zend Server Community Edition (CE). So I had to start all over again with a fresh installation of Zend Server CE 4.0.1. I was pleased to see that they fixed some of the quirks and bugs I had encountered in the beta version, but oddly enough they introduced some new ones too.<span id="more-315"></span></p>
<p>Zend has made quite a lot of noise about their latest products, namely Zend Server and Zend Server CE (Community Edition) and I felt tempted to try it out for myself.<br />
According to Zend, the Zend Server Community Edition (CE) is a free Web Application Server that is simple to install and easy to use. Well, you are about to find out, if you continue reading. It is intended as a community-supported product via the Zend support forums, and updates will be made available periodically. Still according to Zend, the Zend Server CE should be ideal for developing and running non-critical PHP applications. Replace free with commercial, non-critical with business-critical and add some extra features in the mix and you have the Zend Server. Since I do not need a commercial webserver I decided to try out the community edition.</p>
<h3>Ubuntu server</h3>
<p>At home I usually tinker with virtual Ubuntu servers, so I installed a basic virtual Ubuntu server (8.04 LTS) with OpenSSH server as the only extra software package, no <abbr title="Linux Apache MySQL PHP">LAMP</abbr>.  I already posted an <a title="Installing a virtual Ubuntu LAMP-server on Mac OS X using VirtualBox" href="http://blog.johan-mares.be/ict/linux/installing-a-virtual-ubuntu-lamp-server-on-mac-os-x-using-virtualbox/" target="_blank">article</a> on how to install a virtual Ubuntu server on Mac OS X using VirtualBox, so I will not repeat it here. I christened this server <em>zsce</em> and assigned the static IP-address 192.168.1.83 to it. I didn&#8217;t bother installing the linux guest additions for VirtualBox.</p>
<p>Zend Server CE doesn&#8217;t install a <abbr title="DataBase Management System">DBMS</abbr> and the manual doesn&#8217;t mention it either, but I thought it made sense to install MySQL before attempting to install Zend Server CE.</p>
<pre>sudo aptitude install mysql-server mysql-client</pre>
<p>You will be prompted to provide a root password for MySQL.</p>
<p>And now …</p>
<h3>Installing Zend Server CE</h3>
<p>I used the DEB installation method for installing Zend Server CE using aptitude. Installing on a Ubuntu server means using the command line only.</p>
<p>First you will have to add a repository to be able to download the Zend Server CE</p>
<pre>sudo vi /etc/apt/sources.list</pre>
<p>Add the following lines to the file:</p>
<pre># Zend Server CE
deb http://repos.zend.com/deb/ce ce non-free</pre>
<p>Add Zend&#8217;s repository public key. If you did not use the sudo -s command earlier, like mentioned in the manual, you will get the following error:</p>
<pre>johan@zsce:~$ sudo wget http://repos.zend.com/deb/zend.key -O- |apt-key add -
--10:31:23--  http://repos.zend.com/deb/zend.key
=&gt; `-'
Resolving repos.zend.com... 93.188.130.102
Connecting to repos.zend.com|93.188.130.102|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1,673 (1.6K) [text/plain]

100%[========================================================&gt;] 1,673         --.--K/s

10:31:24 (441.22 KB/s) - `-' saved [1673/1673]

gpg: no writable keyring found: eof
gpg: error reading `-': general error
gpg: import from `-' failed: general error</pre>
<p>Lesson learned: follow the manual to the letter or place the sudo command before the apt-key command.</p>
<pre>johan@zsce:~$ wget http://repos.zend.com/deb/zend.key -O- | <strong>sudo</strong> apt-key add -
--10:32:41--  http://repos.zend.com/deb/zend.key
=&gt; `-'
Resolving repos.zend.com... 93.188.130.102
Connecting to repos.zend.com|93.188.130.102|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1,673 (1.6K) [text/plain]

100%[========================================================&gt;] 1,673         --.--K/s

10:32:41 (104.95 KB/s) - `-' saved [1673/1673]</pre>
<p>To follow the manual more closely I now ran the sudo -s command, which makes me root.</p>
<pre>johan@zsce:~$ sudo -s
[sudo] password for johan:
root@zsce:~#</pre>
<p>Update the package repository info.</p>
<pre>aptitude update</pre>
<p>Install Zend Server CE. I copied most of the installation messages so you can see which packages are installed with Zend Server CE.</p>
<pre>root@zsce:~# aptitude install zend-ce
Reading package lists... Done
Building dependency tree
...
The following NEW packages will be installed:
apache2-mpm-prefork apache2-utils apache2.2-common libaio1 libapache2-mod-php5-zend-ce
libapr1 libaprutil1 libframework1-zend-ce libicu36 libmcrypt4 libmhash2 liboci-zend
libpng12-0 libpng3 libpq4 libpq5 libsqlite0 lighttpd-zend-ce openssl php-bcmath-zend-ce
php-bz2-zend-ce php-calendar-zend-ce php-ctype-zend-ce php-curl-zend-ce
php-data-cache-zend-ce php-debugger-zend-ce php-dev-zend-ce php-exif-zend-ce php-fcgi-zend-ce
php-ftp-zend-ce php-gd-zend-ce php-gettext-zend-ce php-imap-zend-ce php-intl-zend-ce
php-json-zend-ce php-ldap-zend-ce php-mcrypt-zend-ce php-mhash-zend-ce php-mime-magic-zend-ce
php-mysql-zend-ce php-mysqli-zend-ce php-oci8-zend-ce php-optimizer-plus-zend-ce
php-pdo-mysql-zend-ce php-pdo-oci-zend-ce php-pdo-pgsql-zend-ce php-pgsql-zend-ce
php-posix-zend-ce php-soap-zend-ce php-sockets-zend-ce php-sqlite-zend-ce php-tidy-zend-ce
php-tokenizer-zend-ce php-xmlreader-zend-ce php-xmlwriter-zend-ce php-xsl-zend-ce
php-zem-zend-ce php-zendutils-zend-ce php-zip-zend-ce php5-common-extensions-zend-ce sqlite
zend-base-ce zend-ce zend-ce-doc zend-extensions-ce zend-framework-ce zend-gui-ce
0 packages upgraded, 67 newly installed, 0 to remove and 10 not upgraded.
Need to get 48.5MB of archives. After unpacking 179MB will be used.
Do you want to continue? [Y/n/?] Y
...</pre>
<p>This can take a while depending on your connection.</p>
<pre>...
Setting up sqlite (2.8.17-4build1) ...
Setting up zend-extensions-ce (4.0.0-1+b60) ...
dpkg: dependency problems prevent configuration of zend-gui-ce:
zend-gui-ce depends on lighttpd-zend-ce; however:
Package lighttpd-zend-ce is not configured yet.
zend-gui-ce depends on php-fcgi-zend-ce; however:
Package php-fcgi-zend-ce is not configured yet.
dpkg: error processing zend-gui-ce (--configure):
dependency problems - leaving unconfigured
Setting up zend-framework-ce (1.7.8+b34) ...
Setting up zend-ce-doc (4.0.10+b20) ...
dpkg: dependency problems prevent configuration of zend-ce:
zend-ce depends on zend-gui-ce; however:
Package zend-gui-ce is not configured yet.
dpkg: error processing zend-ce (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc6 ...
ldconfig deferred processing now taking place
Errors were encountered while processing:
lighttpd-zend-ce
php-fcgi-zend-ce
zend-gui-ce
zend-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install.  Trying to recover:
Setting up lighttpd-zend-ce (1.4.18-1+b56) ...

Setting up php-fcgi-zend-ce (5.2.9+b36) ...
Setting up zend-gui-ce (4.0.16+b150) ...
Site zendserver_gui.conf installed; run /etc/init.d/apache2 reload to enable.
* Reloading web server config apache2

Setting up zend-ce (4.0.0-1+b60) ...
* Stopping web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
httpd (no pid file) not running
...done.
Starting ZendServer 4.0.0 ..

apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
spawn-fcgi.c.206: child spawned successfully: PID: 7700
Starting ZendServer GUI [Lighttpd] [OK]
[08.04.2009 10:44:59 SYSTEM] watchdog for lighttpd is running.
[08.04.2009 10:44:59 SYSTEM] lighttpd is running.
ZendServer started...</pre>
<p>This is a bug they fixed. In the beta version the installation stopped after &#8216;E: Sub-process /usr/bin/dpkg returned an error code (1)&#8217;. I then had to run the installation command again to get to the message &#8216;ZendServer started&#8230;&#8217;.</p>
<p>If you want to get rid of the &#8216;Could not reliably determine the server&#8217;s fully qualified domain name&#8230; &#8216;, just add a servername to the Apache configuration file.</p>
<pre>vi /etc/apache2/apache2.conf</pre>
<pre>ServerName zsce</pre>
<p>Restart all Zend Server Community Edition daemons.</p>
<pre>root@zsce:~# /usr/local/zend/bin/zendctl.sh restart
Stopping ZendServer GUI [Lighttpd] [OK]
spawn-fcgi.c.206: child spawned successfully: PID: 8359
Starting ZendServer GUI [Lighttpd] [OK]</pre>
<p>Check the Zend Server Community Edition status</p>
<pre>root@zsce:~# /usr/local/zend/bin/zendctl.sh status
[08.04.2009 10:04:54 SYSTEM] Apache is running.
[08.04.2009 10:48:54 SYSTEM] watchdog for lighttpd is running.
[08.04.2009 10:48:54 SYSTEM] lighttpd is running.</pre>
<p>Hurray!</p>
<p>Browsing, using Firefox, to https://192.168.1.83:10082 I got &#8216;Secure Connection Failed&#8217; error; &#8216;192.168.1.83:10082 uses an invalid security certificate &#8230;&#8217;. So confirm the exception and you will get a prompt to provide a password for Zend Server CE.</p>
<h3>Post-installation steps</h3>
<p>Adding the &lt;install_path&gt;/bin directory to the $PATH environment variable for all users.</p>
<p>Finding the &lt;install_path&gt; directory for your Zend Server (linux). I already know that the zendctl.sh script is located in that directory, so all I have to do is to find it.</p>
<pre>root@zsce:~# updatedb
root@zsce:~# locate zendctl
/usr/local/zend/bin/zendctl.sh</pre>
<p>By the way, the location is also mentioned in the manual. Just showing off. <img src='http://blog.johan-mares.be/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<pre>root@zsce:~# vi /etc/profile</pre>
<p>and add the following lines to the end of the file:</p>
<pre>PATH=$PATH:/usr/local/zend/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/zend/lib</pre>
<p>In order for the changes to take effect, run the following command:</p>
<pre>root@zsce:~# source /etc/profile</pre>
<p>I decided to install the extra extensions.</p>
<pre>root@zsce:~# aptitude install php5-extra-extensions-zend-ce
Reading package lists... Done
Building dependency tree
...
The following NEW packages will be installed:
libgif4 libgmp3c2 libltdl3 libming0 libmssql-zend odbcinst1debian1 php-fileinfo-zend-ce
php-gmp-zend-ce php-imagick-zend-ce php-mbstring-zend-ce php-memcache-zend-ce
php-ming-zend-ce php-mssql-zend-ce php-odbc-zend-ce php-pcntl-zend-ce php-shmop-zend-ce
php-sysvmsg-zend-ce php-sysvsem-zend-ce php-sysvshm-zend-ce php-wddx-zend-ce
php-xmlrpc-zend-ce php5-extra-extensions-zend-ce php5-unix-extensions-zend-ce unixodbc
0 packages upgraded, 24 newly installed, 0 to remove and 10 not upgraded.
Need to get 4311kB of archives. After unpacking 10.4MB will be used.
Do you want to continue? [Y/n/?] Y</pre>
<p>and also phpMyAdmin.</p>
<pre>root@zsce:~# aptitude install phpmyadmin-zend-ce
Reading package lists... Done
Building dependency tree
...
Setting up phpmyadmin (4:2.11.3-1ubuntu1.1) ...
<strong>Lighttpd not installed, skipping</strong>
invoke-rc.d: unknown initscript, /etc/init.d/lighttpd not found.
Setting up phpmyadmin-zend-ce (4.0.0-1+b17) ...
...</pre>
<p>I selected lighttpd as webserver for phpMyAdmin when prompted, this isn&#8217;t mentioned in the manual, but it produced a message stating that lighttpd is not installed. I ignored it and phpMyAdmin seems to be correctly installed and working. When you have ServerSpy installed in your Firefox browser you will notice that phpMyAdmin uses lighttpd as webserver. Strange, but it works, just keep going.</p>
<p>When I tried to access phpMyAdmin via my browser (still using my MacBook) I got the following message:</p>
<blockquote><p>&#8220;For security reasons, the link to the phpMyAdmin interface from Zend Server is locked for remote access and is only accessible from localhost. &#8220;</p></blockquote>
<p>Great, I am running Zend Server CE on a command line only linux server and must access phpMyAdmin from the localhost. Zend Server CE is also supposed to be for development environments, so where&#8217;s the harm in accessing phpMyAdmin from another computer? Despite being my first encounter with lighttpd it took me only a couple of minutes to figure out how to fix this, without <abbr title="Reading The -ing Manual">RTFM</abbr>. I added the IP-address of my home network (192.168.1) to the lighttpd configuration file.</p>
<pre>vi /usr/local/zend/gui/lighttpd/etc/lighttpd.conf</pre>
<pre>...
$HTTP["remoteip"] !~ "127.0.0.1" {
$HTTP["url"] =~ "^/phpmyadmin/" {
url.access-deny = ( "<strong>192.168.1</strong>" )
server.errorfile-prefix = "//usr/local/zend/gui/lighttpd/share/lighttpd-custom-errors/errorcode-"
}
}
...</pre>
<p>Restart all Zend Server Community Edition daemons.</p>
<pre>root@zsce:~# /usr/local/zend/bin/zendctl.sh restart
Stopping ZendServer GUI [Lighttpd] [OK]
spawn-fcgi.c.206: child spawned successfully: PID: 8359
Starting ZendServer GUI [Lighttpd] [OK]</pre>
<p>Don&#8217;t ask me to explain the change to the lighttpd config file, my first attempt to fix it worked. Hurray!</p>
<p>Now we get to the point were they included some new bugs.</p>
<p>I wanted to install the Dojo toolkit and the Zend Framework extras. But compared to the beta version the manual now contains some typos which will prevent you from installing them.</p>
<p>From the manual for version 4.0.1:</p>
<pre>aptitude install framework-zend-dojo-ce</pre>
<p>resulted in</p>
<pre>Couldn't find any package whose name or description matched "framework-zend-dojo-ce"</pre>
<p>and</p>
<pre>aptitude install framework-zend-extras-ce</pre>
<p>resulted in</p>
<pre>Couldn't find any package whose name or description matched "framework-zend-extras-ce"</pre>
<p>A quick search in the manual for the beta version revealed that the correct way to install the packages is:</p>
<pre>aptitude install zend-framework-dojo-ce</pre>
<p>and</p>
<pre>aptitude install zend-framework-extras-ce</pre>
<p>This way the packages installed without errors. Since I have never used the Dojo toolkit and the Zend framework I didn&#8217;t test them.</p>
<p>I did not install any other packages, so I do not know if there are more typos.</p>
<h3>Tests</h3>
<p>This is just a review about the installation of the community edition of the Zend Server. No tests, no benchmarks, no security audit, &#8230; Well, as it was installed separately, I did test the database connection to MySQL using the following 3 database extensions: MySQL, MySQLi and PDO.</p>
<p>I created a database (testdb), with 1 table (names) containing 2 fields (id and name), inserted some records using phpMyAdmin and tested the connection to the database and retrieval of the data using PHP-scripts.</p>
<p>The first 2, MySQL and MySQLi, worked flawlessly, but this was not the case for PDO. The following error was displayed in the browser, when testing PDO on Zend Server CE:</p>
<blockquote><p>Error: SQLSTATE[HY000] [2002] Can&#8217;t connect to local MySQL server through socket &#8216;/tmp/mysql.sock&#8217; (2)</p></blockquote>
<p>The solution for this problem (via Google) was to include socket information in the DSN (Database Source Name) as you can see in the script below. I never encountered this problem when using the default LAMP installation on Ubuntu or CentOS.</p>
<pre>&lt;?php
try {
    $dbc = new PDO(
          'mysql:host=localhost;dbname=testdb;<strong>unix_socket=/var/run/mysqld/mysqld.sock</strong>',
          'testusr', 'testpwd');
    $sql = 'SELECT * FROM names';
    foreach ($dbc-&gt;query($sql) as $row) {
        echo $row['id'] . '. ' . $row['name'] . "&lt;br /&gt;\n";
    }
} catch (PDOException $e) {
    echo "Error: " . $e-&gt;getMessage() . "&lt;br /&gt;";
}
$dbc = null;
?&gt;</pre>
<p>Test PECL installation:</p>
<pre>root@zsce:~# pecl list-all
All packages [Channel pecl.php.net]:
====================================
Package           Latest Local
pecl/APC          3.1.2        Alternative PHP Cache
pecl/memcache     2.2.5        memcached extension
pecl/hidef        0.1.1        Constants for real
pecl/memcached    0.1.5        PHP extension for interfacing with memcached via libmemcached library
pecl/spidermonkey 0.1.2        JavaScript engine for PHP
pecl/selinux      0.2.1        SELinux binding for PHP script language
pecl/bloomy       0.1.0        Extension implementing a Bloom filter</pre>
<p>OK</p>
<p>Test documentation. The following chapters on the locally installed help for the Dashboard (https://192.168.1.83:10082/ZendServer/help/zend_server.htm#dashboard.htm) returned not found errors (404).</p>
<ul>
<li> Administration Interface/Administration/Passwords</li>
<li> Tasks/Working with Zend Server</li>
</ul>
<h3>Review</h3>
<p><strong>Bugs / quirks / annoyances / missing / typos / remarks:</strong></p>
<ul>
<li>Missing: MySQL</li>
<li><span style="text-decoration: line-through;">Missing: PHP CLI</span>. My mistake, it is present.</li>
<li>Typos (?): names of the packages Dojo and extras for Zend Framework are spelled wrong in the manual</li>
<li>Documentation: when to install your DBMS, what webserver to choose when installing phpMyAdmin, how to allow access to phpMyAdmin from outside localhost, the relationship between lighttpd and Apache, &#8230;</li>
<li>Bug: PDO, doesn&#8217;t work without including socket info in the DSN</li>
<li>Installation takes more time and effort than a default Ubuntu or Centos LAMP installation.</li>
<li>The installation of phpMyAdmin reported lighttpd not installed.</li>
<li>Bug: some broken links in the locally installed help</li>
</ul>
<p>I can understand Zend not including MySQL in the installation, because not everyone uses MySQL and if they did include it, people would start complaining why PostgreSQL isn&#8217;t included. So, it&#8217;s no big deal. It would be a good idea though to include in the installation manual when you are supposed to install your DBMS. Most likely this will be before installing Zend Server, but it wouldn&#8217;t hurt mentioning this.</p>
<p>It isn&#8217;t that difficult to install Zend Server CE, but it takes more time and work than a default LAMP installation on Ubuntu.</p>
<p>Documentation is still a bit lacking: when to install your database (before seems logical to me), installation of phpMyAdmin (which webserver to choose, how to allow access from another computer), more information on the relationship between lighttpd and Apache &#8230; I am not asking for a complete manual on lighttpd and Apache here, it&#8217;s just the first time I am confronted with lighttpd (among other stuff) &#8230; or is all that supposed to be common knowledge.</p>
<p>Actually, I find it impressive. It&#8217;s quite an achievement to offer a product like this and making it free for home/development/non-critical use. No less than 5 installation methods: 1 for Microsoft Windows, 1 for Mac OS X and 3 for Linux (tarball, RPM and DEB). The list of software and packages is extensive, but I might not be the right person to appreciate all of this. I&#8217;ve never used a debugger, caching, &#8230; and I don&#8217;t know why they install 2 webservers (lighttpd and Apache) instead of just one. This is why I stick to reviewing the installation procedure. Let&#8217;s be honest; the list of bugs, remarks, &#8230; will not take a long time fixing.</p>
<h3>Why would you use Zend Server CE ?</h3>
<p>Speaking for myself, from a professional and personal perspective, I see no use for Zend Server CE in the near future. This may sound quite harsh, but let me explain.</p>
<p>At work we have a mixed server environment, Windows and Linux (CentOS, Scientific Linux) servers. I do not see us replacing the current webserver setups with Zend Server (CE). Although I do see that a mixed server environment might be the ideal place to use Zend Server; resulting in identical setups for your Windows and Linux webservers, which would make it possible to move sites easily. Especially if you start from a clean slate or want to restart with a clean slate. But this will require a lot of work and I don&#8217;t see it happen any time soon. It&#8217;s also no use to develop on Zend Server CE when you do not use Zend Server in your production environment.</p>
<p>I am also not impressed with the argument that Zend Server uses a very recent version of PHP (5.2.9) compared to Ubuntu 8.04 LTS (5.2.4) and CentOS / RHEL / SL (5.1.6). You choose an environment and you stick with it for a while and since security updates and bug fixes are <a title="backporting" href="http://en.wikipedia.org/wiki/Backporting" target="_blank">backported</a> I do not see a problem with this approach. I do admit that RHEL&#8217;s approach feels a bit like the other extreme compared to Zend Server.</p>
<p>It&#8217;s very unlikely that shared hosting sites will move en masse to Zend Server in the near future. So when I develop my personal site at home on a Zend Server CE installation and then upload my site to my webhost, there is a risk that there will be errors due to different PHP versions or different installed components, modules and packages. This is asking for trouble; you should always keep your development environment identical (or as identical as possible) to your production environment. The same goes if you work as an independent contractor. Of course, if Zend Server gains a lot of momentum this situation might change in the years to come, but I feel no need to be an early adopter.</p>
<p>I do not feel like I have wasted my time installing Zend Server CE even as I have no intention of using it in the near future. It made me realize that there are some areas where my knowledge is lacking: debuggers, caching, Zend Framework, lighttpd, &#8230; So my list of interesting things to study just got a bit longer.</p>
<table style="border: medium none; margin: 20px auto; width: auto;" border="0" align="center">
<tbody>
<tr>
<td>There is no place like 127.0.0.1</td>
</tr>
<tr>
<td align="right"><em></em></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://blog.johan-mares.be/ict/php/installing-zend-server-ce-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Installing a virtual Ubuntu LAMP-server on Mac OS X using VirtualBox</title>
		<link>http://blog.johan-mares.be/ict/linux/installing-a-virtual-ubuntu-lamp-server-on-mac-os-x-using-virtualbox/</link>
		<comments>http://blog.johan-mares.be/ict/linux/installing-a-virtual-ubuntu-lamp-server-on-mac-os-x-using-virtualbox/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 23:02:19 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[VirtualBox]]></category>

		<guid isPermaLink="false">http://blog.johan-mares.be/?p=188</guid>
		<description><![CDATA[Virtualization is a hot topic in ICT. How can you put this to use at home and more specifically on your Mac ? You can use it to run Windows on your Mac, but also to try out different flavors of Linux or to run a LAMP (Linux Apache MySQL PHP) development server. If you have a spare recent pc you can install a baremetal hypervisor like XenServer5, but that's a different story. If you want to install a hypervisor or virtual machine monitor on your MacBook, Mac mini or iMac, there are a number of solutions available. To name a few: VMWare, Parallels, Q and VirtualBox.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.johan-mares.be%2Fict%2Flinux%2Finstalling-a-virtual-ubuntu-lamp-server-on-mac-os-x-using-virtualbox%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.johan-mares.be%2Fict%2Flinux%2Finstalling-a-virtual-ubuntu-lamp-server-on-mac-os-x-using-virtualbox%2F&amp;source=maresjohan&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Virtualization is a hot topic in ICT. How can you put this to use at home and more specifically on your Mac ? You can use it to run Windows on your Mac, but also to try out different flavors of Linux or to run a LAMP (Linux Apache MySQL PHP) development server. If you have a spare recent pc you can install a baremetal <a title="hypervisor" href="http://en.wikipedia.org/wiki/Hypervisor" target="_blank">hypervisor</a> like XenServer5, but that&#8217;s a different story. If you want to install a hypervisor or virtual machine monitor on your MacBook, Mac mini or iMac, there are a number of solutions available. To name a few: VMWare, Parallels, Q and VirtualBox.<br />
First requirement: it has to be free, free as in made freely available by the software vendor, not as in a pirated or illegal copy. So skip VMWare (unless you stick with the VMWare Player) and Parallels.<br />
Second requirement: it must be a hypervisor project, preferably open source, with active development, user groups, forums and good documentation.<br />
So I chose <a title="VirtualBox" href="http://www.virtualbox.org/" target="_blank">VirtualBox</a>. For the cross-platformers among you, like myself, VirtualBox also runs on Windows, Linux and OpenSolaris and supports a large number of guest operating systems including Windows (NT 4.0, 2000, XP, Server 2003, Vista), DOS/Windows 3.x, Linux (2.4 and 2.6), Solaris, OpenSolaris, and OpenBSD.<br />
But this post will be about installing a virtual Ubuntu LAMP or web server on Mac OS X using VirtualBox.<span id="more-188"></span></p>
<h3>
<div id="attachment_370" class="wp-caption alignright" style="width: 160px"><a href="http://blog.johan-mares.be/wp-content/uploads/2009/02/vbu-sharing.png"><img class="size-thumbnail wp-image-370" title="vbu-sharing" src="http://blog.johan-mares.be/wp-content/uploads/2009/02/vbu-sharing-150x150.png" alt="Sharing" width="150" height="150" /></a><p class="wp-caption-text">Sharing</p></div>
<p>Getting started</h3>
<p>For starters, you will need a Mac. I have a MacBook 2.16 GHz Intel Core Duo, with 2 GB RAM and 120 GB hard disk and Mac OS X Leopard (10.5.6) installed. My Mac is connected to a wireless router.<br />
Next, you will need to download <a title="Download VirtualBox" href="http://www.virtualbox.org/wiki/Downloads" target="_blank">VirtualBox</a> for Intel Macs (mine is version 2.1.0) and <a title="Download Ubuntu" href="http://www.ubuntu.com/getubuntu/download" target="_self">Ubuntu</a> server (I chose for the 8.04 <abbr title="Long Term Support">LTS</abbr> 32 bit version).<br />
You will also need enough diskspace to install one or more virtual machines, but that goes without saying &#8230; right ? 8 GB and up is recommended for a virtual machine, but since we will be using the server edition, <abbr title="Command Line Interface">CLI</abbr> only (no GNOME, no KDE, no Office suite, no games, &#8230;) 4-5 GB should be more than enough for a development webserver.</p>
<div id="attachment_371" class="wp-caption alignleft" style="width: 160px"><a href="http://blog.johan-mares.be/wp-content/uploads/2009/02/vbu-tcpip.png"><img class="size-thumbnail wp-image-371" title="vbu-tcpip" src="http://blog.johan-mares.be/wp-content/uploads/2009/02/vbu-tcpip-150x150.png" alt="IPv6" width="150" height="150" /></a><p class="wp-caption-text">IPv6</p></div>
<p>The installation of VirtualBox is pretty straightforward, so I&#8217;ll skip this.<br />
However, you must change some settings of Mac OS X. First you must enable internet sharing. To do this, open &#8216;System Preferences&#8217; and in &#8216;Internet &amp; Network&#8217; click &#8216;Sharing&#8217;. Now you get the window you see in the picture &#8216;Sharing&#8217;, select &#8216;Internet Sharing&#8217;, for &#8216;Share your connection from:&#8217; select  &#8216;Airport&#8217; (when you use wireless) and select in &#8216;To computers using&#8217; the &#8216;Ethernet&#8217; option.<br />
Secondly, some sites mention that you should disable IPv6. I didn&#8217;t notice any difference between IPv6 status &#8216;Off&#8217; or &#8216;Automatically&#8217;. The information on those sites wasn&#8217;t very recent  and, if I recall correctly, referred to VirtualBox version 1.x. My IPv6 is configured to &#8216;Automatically&#8217;, but if you want to turn it off, here&#8217;s how to do it. Again open &#8216;System Preferences&#8217; and in &#8216;Internet &amp; Network&#8217; click &#8216;Network, next click the &#8216;Advanced&#8230;&#8217; button and the &#8216;TCP/IP&#8217; tab. Where it mentions &#8216;Configure IPv6&#8242; select &#8216;Off&#8217;.<br />
That should take care of the preparations. Let&#8217;s get down to business and install a virtual webserver.</p>
<h3>Create a virtual machine</h3>
<div id="attachment_372" class="wp-caption alignleft" style="width: 160px"><a href="http://blog.johan-mares.be/wp-content/uploads/2009/02/vbu-main01.png"><img class="size-thumbnail wp-image-372" title="vbu-main01" src="http://blog.johan-mares.be/wp-content/uploads/2009/02/vbu-main01-150x150.png" alt="VirtualBox" width="150" height="150" /></a><p class="wp-caption-text">VirtualBox</p></div>
<p>Start VirtualBox. Before we go into the step by step creation process, I will explain some of the choices I made. For RAM I chose 256 MB, this is the minimum for an Ubuntu server, but as it is just for a virtual development or test server on my MacBook, this should be enough. Keep in mind that the memory you allocate to your virtual machine is no longer available for your real machine; 2 GB RAM minus 256 MB still leaves plenty of RAM available for my Mac, enough to run a second and even a third virtual machine if I want to, but if you only have 1 GB of RAM to start with, you will probably notice that everything slows down if you allocate 512 MB to your virtual machine. According to VirtualBox the recommended disk space for Ubuntu is 8 GB, but that is for the desktop version with Gnome and all the bells and whistles you don&#8217;t need in a server. I chose 5 GB to be on the safe side, but after installation I noticed that Ubuntu server needs less than 1 GB of disk space, so I guess 2 or 3 GB should be more than adequate. It depends of course on what kind of sites you&#8217;ll be developing. I chose for &#8216;Fixed-size storage&#8217; instead of &#8216;Dynamically expanding storage&#8217;, but both options work, so no worries here. In the case of &#8216;Dynamically expanding storage&#8217; you select the maximum disk space and that space will only be addressed when needed, so you save some space on your hard drive &#8230; at least for a while.</p>
<p>Create your virtual server:</p>
<ul>
<li>click on the &#8216;New&#8217; icon</li>
<li>click &#8216;Next&#8217; to go to &#8216;VM Name and OS Type&#8217;</li>
<li>choose a meaningful name</li>
<li>as &#8216;Operating System&#8217; select &#8216;Linux&#8217;</li>
<li>as &#8216;Version&#8217; select &#8216;Ubuntu&#8217; or &#8216;Linux 2.6&#8242;, both options work</li>
<li>click &#8216;Next&#8217; to go to &#8216;Memory&#8217;</li>
<li>select amount of RAM, I chose 256 MB</li>
<li>click &#8216;Next&#8217; to go to &#8216;Virtual Hard Disk&#8217;</li>
<li>leave &#8216;Boot Hard Disk&#8217; checked</li>
<li>click &#8216;New&#8230;&#8217;</li>
<li>click &#8216;Next&#8217; to go to &#8216;Hard Disk Storage Type&#8217;</li>
<li>I chose for &#8216;Fixed-size storage&#8217;</li>
<li>click &#8216;Next&#8217; to go to &#8216;Virtual Disk Location and Size&#8217;</li>
<li>I kept the default name and location</li>
<li>select amount of disk space, I chose 5 GB</li>
<li>click &#8216;Next&#8217; and &#8216;Finish&#8217;</li>
<li>for  &#8216;Fixed-size storage&#8217; this can take a couple of minutes</li>
<li>click &#8216;Next&#8217; and &#8216;Finish&#8217; (again)</li>
</ul>
<h3>Virtual machine settings</h3>
<div id="attachment_373" class="wp-caption alignleft" style="width: 160px"><a href="http://blog.johan-mares.be/wp-content/uploads/2009/02/vbu-general01.png"><img class="size-thumbnail wp-image-373" title="vbu-general01" src="http://blog.johan-mares.be/wp-content/uploads/2009/02/vbu-general01-150x150.png" alt="General tab" width="150" height="150" /></a><p class="wp-caption-text">General tab</p></div>
<p>Before actually installing your virtual Ubuntu server, you must change some settings.</p>
<p>In the main VirtualBox window, select the virtual machine you&#8217;ve just created and go to &#8216;Settings&#8217; either by a right mouse click on the virtual machine or by clicking on the &#8216;General&#8217; link (in blue). Now click on the &#8216;Advanced&#8217; tab and check &#8216;Enable PAE/NX&#8217;, this is required to install an Ubuntu server, it is however not needed for an Ubuntu desktop or so I&#8217;ve read.</p>
<p>On top of this window you see a list of icons: &#8216;General&#8217;, &#8216;Storage&#8217;, &#8216;Audio&#8217;, &#8216;Network&#8217;, &#8216;Ports&#8217;, &#8230; Click on &#8216;Network&#8217;. Here several settings need to be changed.<br />
Change the &#8216;Adapter Type&#8217; to &#8216;Intel PRO/1000 T Server (&#8230;)&#8217;. This adapter is less demanding on your CPU.<br />
Change &#8216;Attached to&#8217; to &#8216;Host Interface&#8217;, &#8216;NAT&#8217; is fine when you only want an outgoing connection like for Ubuntu Desktop, but you want your Ubuntu Server to accept incoming connections (HTTP, FTP, SSH) too, otherwise your server is useless, so change it to &#8216;Host Interface&#8217;.</p>
<div id="attachment_374" class="wp-caption alignright" style="width: 160px"><a href="http://blog.johan-mares.be/wp-content/uploads/2009/02/vbu-network01.png"><img class="size-thumbnail wp-image-374 " title="vbu-network01" src="http://blog.johan-mares.be/wp-content/uploads/2009/02/vbu-network01-150x150.png" alt="Network" width="150" height="150" /></a><p class="wp-caption-text">Network</p></div>
<p>Which host interface to select in &#8216;Host Interfaces&#8217; ? I read another blog that mentions that you must select &#8216;en0: Ethernet&#8217; even if you only have a wireless connection. I believe this caused all the problems I encountered installing this virtual machine. At first it was a success, the installation went fine, the server got assigned an IP address in the 192.168.2.0 network although I have no idea where this network comes from (Mac or VirtualBox). The updating, upgrading, configuring, &#8230; everything went smooth. I could connect from my MacBook to the virtual machine via HTTP and SSH. Next day, no more connections from the virtual server to the internet or from my MacBook to the server (cannot allocate memory errors, see troubleshooting chapter at the bottom). I lost count on how many attempts I made to get it to work. I was convinced that the problem was either caused by the IPv6 setting or because I didn&#8217;t install the linux-virtual kernel and the &#8216;Guest Additions&#8217; right away. Google searches indicated these to be the most likely culprits. Once the problem occurred, the only solution was to delete the virtual machine and start all over again. It was only after I selected &#8216;en1: Airport&#8217; as &#8216;Host interfaces&#8217; that it kept working. I could see a lot benefits by using the rogue/alien/virtual/&#8230; 192.168.2.0 network: I would be able to connect to my webserver even when my Mac was offline or on a different wireless network, so I didn&#8217;t want to give it up so easily. By selecting &#8216;en1: Airport&#8217; my virtual machines now connect to my wireless router, which has a 192.168.1.0 network. And there are benefits for this solution too: your virtual machines can connect to other machines on your home network (you can use this to make backups) or let those other machines connect to the virtual servers on your Mac (e.g. a Windows pc to test a website with IE). Maybe I did something wrong, maybe the information on the other site was wrong, but 4 times in a row I installed servers with &#8216;en1: Airport&#8217; as host interface and they keep on working.</p>
<h3>Installing Ubuntu server</h3>
<p>Don&#8217;t close the &#8216;Settings&#8217; window yet. Click on &#8216;Storage&#8217; and select the tab &#8216;CD/DVD-ROM&#8217;. If you already closed the window you can click on the link &#8216;CD/DVD-ROM&#8217;. Here you can either mount your Ubuntu CD-ROM in your &#8216;Host CD/DVD Drive&#8217; or select the &#8216;ISO Image File&#8217; you downloaded on your computer. When you choose the &#8216;ISO Image File&#8217; option, click on the folder button on the right and in the new window &#8216;Virtual Media Manager&#8217;, click on the &#8216;Add&#8217; button and browse to the location of the ISO file. Don&#8217;t forget to unmount the CD- or DVD-ROM the first time you shut down after installing.<br />
From an economical and tree hugger point of view it is better to install from an ISO image <img src='http://blog.johan-mares.be/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  .<br />
Now you may hit the &#8216;Start&#8217; button after you&#8217;ve selected the virtual machine.</p>
<div id="attachment_375" class="wp-caption alignright" style="width: 160px"><a href="http://blog.johan-mares.be/wp-content/uploads/2009/02/vbu-ub.png"><img class="size-thumbnail wp-image-375" title="vbu-ub" src="http://blog.johan-mares.be/wp-content/uploads/2009/02/vbu-ub-150x150.png" alt="Ubuntu" width="150" height="150" /></a><p class="wp-caption-text">Ubuntu</p></div>
<p>I am going to walk you through the installation process, but very briefly.</p>
<ul>
<li>select language</li>
<li>select &#8216;Install Ubuntu server&#8217; or &#8216;Check CD for defects&#8217; first</li>
<li>select language, country and keyboard</li>
<li>let it configure your network with DHCP, you can change it later</li>
<li>choose a name for your webserver</li>
<li>as partitioning method I chose &#8216;Guided &#8211; use entire disk&#8217;</li>
<li>for the next step there was only 1 disk to select</li>
<li>agree to write the changes to disks</li>
<li>you can take a break now</li>
<li>set up a user and password</li>
<li>&#8216;HTTP proxy information&#8217;: leave it blank</li>
<li>you can take another short break now</li>
<li>select at least the following software to install: &#8216;LAMP server&#8217; and &#8216;OpenSSH server&#8217;</li>
<li>you will be asked to provide a password for the MySQL root user</li>
<li>after installation, let your virtual machine reboot and don&#8217;t worry about the CD-ROM or ISO image, it will be ignored, but unmount it when you shut your new server down</li>
</ul>
<div id="attachment_376" class="wp-caption alignright" style="width: 160px"><a href="http://blog.johan-mares.be/wp-content/uploads/2009/02/vbu-selsoftware.png"><img class="size-thumbnail wp-image-376" title="vbu-selsoftware" src="http://blog.johan-mares.be/wp-content/uploads/2009/02/vbu-selsoftware-150x150.png" alt="Select software" width="150" height="150" /></a><p class="wp-caption-text">Select software</p></div>
<p>There are several advantages for using ssh from a Mac OS X Terminal instead of the terminal or user interface provided by VirtualBox:</p>
<ul style="text-align: left;">
<li>more control over the layout: font, size, colors, background</li>
<li>better keyboard support (e.g. @ # ^ | `)</li>
<li>faster, more responsive &#8230; at least that is my impression</li>
</ul>
<p>Now you have installed a virtual Ubuntu LAMP or web server. It just needs some polishing and then you are ready to go. I believe it is best to continue and especially optimize your kernel for a <abbr title="Virtual Machine">VM</abbr> environment before calling it a day.</p>
<h3>Finishing off</h3>
<p>You do not have to do all of the following steps, for example the steps on how to configure the Apache webserver and vsftpd FTP-server, you can skip these or alter them to your liking, but I just want to leave you with a working webserver. Since it is supposed to be a virtual development server on your notebook or desktop I haven&#8217;t really bothered with security, creating virtual host, optimizations, &#8230;<br />
I recommend you do not skip the network configuration, the update and upgrade and the installation of the virtual kernel and guest additions.</p>
<p><strong>Network configuration</strong>: Currently your network configuration is based on <abbr title="Dynamic Host Configuration Protocol">DHCP</abbr>. This is not very useful for a server, you need a static IP address. In the user interface provided by VirtualBox, log in to your server. First check your current network configuration:</p>
<pre>johan@lamp:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:d4:b0:68
          inet addr:192.168.1.4  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fed4:b068/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1167 errors:0 dropped:0 overruns:0 frame:0
          TX packets:829 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:523485 (511.2 KB)  TX bytes:103126 (100.7 KB)
          Base address:0xc010 Memory:f0000000-f0020000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:600 (600.0 B)  TX bytes:600 (600.0 B)</pre>
<p>Obviously I am connected to the network provided by my wireless router, now edit your network configuration using the command:</p>
<pre>sudo vi /etc/network/interfaces</pre>
<p>For safety reasons it is best to make a copy of this file before editing. I will demonstrate the settings for my home network, they might be different for yours, but this example should help you to figure it out:</p>
<pre># This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.80
gateway 192.168.1.1
netmask 255.255.255.0</pre>
<p>Notice that I don&#8217;t need to specify a wireless-essid, wireless-key or wireless-channel, even though it is, indirectly, using a wireless connection, the settings are for a wired connection.<br />
Next restart the network using the command:</p>
<pre>sudo /etc/init.d/networking restart</pre>
<p>You can check the new configuration with the command <em>ifconfig</em>.</p>
<p><strong>Update/Upgrade</strong>: After an installation it is recommended to update and upgrade the installed software. On an Ubuntu server you do this via the following two commands, the second one can take a while:</p>
<pre>sudo apt-get update</pre>
<pre>sudo apt-get upgrade</pre>
<p><strong>Virtual kernel</strong>: You have to customize or optimize the kernel for a <abbr title="Virtual Machine">VM</abbr> environment:</p>
<pre>sudo apt-get install linux-virtual<strong>
</strong></pre>
<p><strong>Installing Guest Additions</strong>: To install the Guest Additions, click, with your virtual server running and in the active window, in the &#8216;Menu Bar&#8217; on &#8216;Devices&#8217; and &#8216;Installing Guest Additions&#8230;&#8217;. The ISO image containing those additions is now mounted to your virtual machine. By default a CD-ROM is not automatically mounted in Ubuntu server, so use the following commands to gain access to the additions:</p>
<pre>johan@lamp:/$ sudo mount /media/cdrom
mount: block device /dev/scd0 is write-protected, mounting read-only
johan@lamp:/$ cd /media/cdrom
johan@lamp:/media/cdrom$ ls
32Bit        VBoxLinuxAdditions-amd64.run  VBoxWindowsAdditions-amd64.exe
64Bit        VBoxLinuxAdditions-x86.run    VBoxWindowsAdditions.exe
AUTORUN.INF  VBoxSolarisAdditions.pkg      VBoxWindowsAdditions-x86.exe</pre>
<p>According to the VirtualBox manual, you must install <abbr title="Dynamic Kernel Module Support">DKMS</abbr> to be able to compile the kernel using the command (don&#8217;t do it, continue to read):</p>
<pre>sudo apt-get install dkms<strong>
</strong></pre>
<p>If you do that, and you execute &#8216;VBoxLinuxAdditions-x86.run&#8217; you will get the following output:</p>
<pre>johan@lamp:/media/cdrom$ sudo sh ./VBoxLinuxAdditions-x86.run
[sudo] password for johan:
Verifying archive integrity... All good.
Uncompressing VirtualBox 2.1.0 Guest Additions for Linux installation............
VirtualBox 2.1.0 Guest Additions installation
Please install GNU make.
Please install the build and header files for your current Linux kernel.
The current kernel version is 2.6.24-23-virtual
Please install the GNU compiler.
Problems were found which would prevent the Guest Additions from installing.
Please correct these problems and try again.</pre>
<p>As far as I can figure this out, installing DKMS doesn&#8217;t take into account that you have installed the linux kernel for virtualised hardware (linux-virtual). So instead install the headers for the right kernel and the necessary tools to be able to build.</p>
<pre>sudo apt-get install linux-headers-`uname -r` build-essential</pre>
<p>After that you can install the additions (make sure that you are in the CD-ROM directory):</p>
<pre>sudo sh ./VBoxLinuxAdditions-x86.run</pre>
<p>The VirtualBox manual recommends installing them, but I haven&#8217;t used them yet. This post is all about <em>installing</em> a virtual Ubuntu server on Mac OS X. It&#8217;s not an in-depth look at or the nuts and bolds of VirtualBox.</p>
<p><strong>Changing the configuration of the webserver</strong> to enable the per-user web directories. This means that every user can have his/her own website by creating a special directory in his/her home directory. First create a &#8216;public_html&#8217; directory in your home and change the group to &#8216;www-data&#8217; to give the Apache webserver the necessary permissions to process your webpages.</p>
<pre>cd $HOME</pre>
<pre>mkdir public_html</pre>
<pre>sudo chgrp www-data public_html/</pre>
<p>Enable the userdir module and restart or reload the Apache webserver.</p>
<pre>sudo a2enmod userdir</pre>
<pre>sudo /etc/init.d/apache2 force-reload</pre>
<p>Create a PHP test page info.php in your public_home directory with the following contents</p>
<pre>&lt;?php phpinfo(); ?&gt;</pre>
<p>and on your client computer enter the following URL in your browser (change the IP address and username)</p>
<pre>http://192.168.1.80/~johan/info.php</pre>
<p>and you should get the version information for your PHP installation.</p>
<p><strong>Installing an FTP-server</strong> to upload your websites. I am used to the &#8216;Very Secure FTPD&#8217; server, <a title="vsftpd" href="http://vsftpd.beasts.org/" target="_blank">vsftpd</a>, although I believe this is not the default one for Ubuntu. Anyway it is easy to install if you use the following commands to install and stop vsftpd and edit the config file.</p>
<pre>sudo apt-get install vsftpd</pre>
<pre>sudo /etc/init.d/vsftpd stop</pre>
<pre>sudo vi /etc/vsftpd.conf</pre>
<p>In the configuration file uncomment the following settings</p>
<pre>local_enable=YES</pre>
<pre>write_enable=YES</pre>
<pre>local_umask=022</pre>
<p>and change the &#8216;YES&#8217; to &#8216;NO&#8217; in</p>
<pre>anonymous_enable=NO</pre>
<p>and save. Restart.</p>
<pre>sudo /etc/init.d/vsftpd start</pre>
<p>Now you should be able to upload files to your virtual webserver using an FTP-client like <a title="FileZilla" href="http://filezilla-project.org/" target="_blank">FileZilla</a>. Enter the IP-address, your username and password, click &#8216;connect&#8217;. If all goes well, you will see the contents of your home directory on the webserver, including the public_html directory. Any files you upload to the public_html directory will become visible or at least accessible when you enter the following URL in your browser (change IP and username to match your settings):</p>
<pre>http://192.168.1.80/~johan/</pre>
<p><strong>Some extras</strong>: On a webserver I like to have phpMyAdmin and PHP <abbr title="Command Line Interface">CLI</abbr> available (when installing phpMyAdmin, select &#8216;apache2&#8242; when prompted):</p>
<pre>sudo apt-get install php5-cli</pre>
<pre>sudo apt-get install phpmyadmin</pre>
<p>The further configuration of your webserver, samba, &#8230; is beyond the scope of this post. Good luck.</p>
<h3>Troubleshooting</h3>
<p>I experienced a lot of problems at first. The installation went fine, the updating, upgrading and configuring too. Next day, the server could no longer connect to the internet and I could no longer access the server via HTTP, SSH or even ping to it. This happened enough times to exclude an accidental configuration error or a corrupt ISO image. The error messages I got were:</p>
<pre>ping: sendto: Cannot allocate memory</pre>
<pre>ssh: connect to host 192.168.2.22 port 22: Cannot allocate memory</pre>
<p>Once these occur just delete your virtual server and start all over again. They are either caused by IPv6 being turned on, not installing the for <abbr title="Virtual Machine">VM</abbr>&#8217;s optimized kernel or using the fictitious, virtual or whatever it is called 192.168.2.0 network. I have narrowed it down to the use of the 192.168.2.0 network. I do not know enough of virtualization to explain this, I only want a virtual webserver, in fact more than 1 server, running on my MacBook.</p>
<p>You can connect to your virtual server from other machines in your home. This works without hassle for Macs and Linux boxes, but for Windows XP you have to ping or connect via ssh to your virtual server first before you can browse to it (<abbr title="look this one up yourself, will ya">WTF</abbr>).</p>
<h3>PS</h3>
<p>I have no idea if this post is also useful for installing a virtual Ubuntu server on a Windows or Linux host.</p>
<table style="border: medium none; margin: 20px auto; width: auto;" border="0" align="center">
<tbody>
<tr>
<td>Windows users swear at their computers.<br />
Mac users swear by their computers.</td>
</tr>
<tr>
<td align="right"></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://blog.johan-mares.be/ict/linux/installing-a-virtual-ubuntu-lamp-server-on-mac-os-x-using-virtualbox/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Running PHP CLI shell scripts</title>
		<link>http://blog.johan-mares.be/ict/php/running-php-shell-scripts/</link>
		<comments>http://blog.johan-mares.be/ict/php/running-php-shell-scripts/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 19:16:27 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[shebang]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://blog.johan-mares.be/?p=71</guid>
		<description><![CDATA[I already knew how to run PHP scripts from the command line (CLI), although I never really used it. What was new to me was that there are 2 ways of doing this. The first one is by using the php command and the second, and new for me, is by adding a shebang on the first line of your script.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.johan-mares.be%2Fict%2Fphp%2Frunning-php-shell-scripts%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.johan-mares.be%2Fict%2Fphp%2Frunning-php-shell-scripts%2F&amp;source=maresjohan&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>I already knew how to run PHP scripts from the command line (CLI), although I never really used it. What was new to me was that there are 2 ways of doing this. The first one is by using the php command and the second, and new for me, is by adding a shebang on the first line of your script.</p>
<p>Why would you want to use PHP CLI ? Well you don&#8217;t have to learn another programming language like perl or bash to make shell scripts, you can run cron jobs in PHP and you can reuse code from a website for example in your shell script.<span id="more-71"></span></p>
<p>Before you read any further, the examples below will work for linux and Mac OS X, but not for Windows. I used Ubuntu 8.04 server and Mac OS X 10.5.6.</p>
<p>First you&#8217;ll have to make sure that PHP CLI is installed.</p>
<pre>johan@ubusrv:~$ php -v
PHP 5.2.4-2ubuntu5.3 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 23 2008 06:44:49)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies</pre>
<p>If you see &#8216;cli&#8217; somewhere on the first line, you are ready to go, otherwise you will have to install it first. For example on Ubuntu:</p>
<pre>johan@ubusrv:~$ sudo apt-get install php5-cli</pre>
<p>It it also useful to know the full path to the PHP binary on your computer. There are several ways of finding out. For Ubuntu and Mac OS X the path is &#8216;/usr/bin/php&#8217;.</p>
<pre>johan@ubusrv:~$ which php
/usr/bin/php
johan@ubusrv:~/cli$ whereis php
php: /usr/bin/php /usr/share/php /usr/share/man/man1/php.1.gz
johan@ubusrv:~/cli$ type -a php
php is /usr/bin/php</pre>
<p>For the <strong>first method</strong> we&#8217;ll use the following script:</p>
<pre>&lt;?php
        echo "First PHP CLI script\n";
        echo exec('ls -l\n') . "\n";
?&gt;</pre>
<p>You can either execute it by using the php command or by using the full path of the php binary. In this case it is not necessary to make the file exectuable.</p>
<pre>johan@ubusrv:~/cli$ php firstcli.php
First PHP CLI script
-rw-r--r-- 1 1000 1000 71 2009-01-01 19:39 firstcli.php
johan@ubusrv:~/cli$ /usr/bin/php firstcli.php
First PHP CLI script
-rw-r--r-- 1 1000 1000 71 2009-01-01 19:39 firstcli.php</pre>
<p>For the <strong>second method</strong> we&#8217;ll add a <a title="shebang" href="http://en.wikipedia.org/wiki/Shebang_(Unix)" target="_blank">shebang</a> to the first line of the script:</p>
<pre>#!/usr/bin/php -q
&lt;?php
        echo "First PHP CLI script\n";
        echo exec('ls -l\n') . "\n";
?&gt;</pre>
<p>I have added the &#8216;-q&#8217; in the shebang, because you will find a lot of examples like this, but you don&#8217;t need it. According to the <a title="PHP Manual" href="http://be.php.net/manual/en/features.commandline.php" target="_blank">PHP Manual</a> CLI is started up in quiet mode by default, though the <span class="option">-q</span> and <span class="option">&#8211;no-header</span> switches are kept for compatibility so      that you can use older CGI scripts.<br />
After you&#8217;ve made the file executable, you can now run it like any other shell script.</p>
<pre>johan@ubusrv:~/cli$ chmod +x firstcli.php
johan@ubusrv:~/cli$ ./firstcli.php
First PHP CLI script
-rwxr-xr-x 1 1000 1000 89 2009-01-01 19:56 firstcli.php
johan@ubusrv:~/cli$ /home/johan/cli/firstcli.php
First PHP CLI script
-rwxr-xr-x 1 1000 1000 89 2009-01-01 19:56 firstcli.php</pre>
<table style="border: medium none; margin: 20px auto; width: auto;" border="0" align="center">
<tbody>
<tr>
<td>My software never has bugs, it just develops random features</td>
</tr>
<tr>
<td align="right"></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://blog.johan-mares.be/ict/php/running-php-shell-scripts/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>A nice gesture</title>
		<link>http://blog.johan-mares.be/ict/php/a-nice-gesture/</link>
		<comments>http://blog.johan-mares.be/ict/php/a-nice-gesture/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 19:29:29 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[magazine]]></category>

		<guid isPermaLink="false">http://blog.johan-mares.be/?p=60</guid>
		<description><![CDATA[At the end of September php&#124;architect had some great news to announce concerning their magazine: a new logo, full colour printing and a new subscription price.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.johan-mares.be%2Fict%2Fphp%2Fa-nice-gesture%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.johan-mares.be%2Fict%2Fphp%2Fa-nice-gesture%2F&amp;source=maresjohan&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<div id="attachment_61" class="wp-caption alignleft" style="width: 102px"><img class="size-full wp-image-61" title="phparchlogo" src="http://blog.johan-mares.be/wp-content/uploads/2008/12/phparchlogo.png" alt="php architect" width="92" height="104" /><p class="wp-caption-text">php|architect</p></div>
<p>At the end of September php|architect had some great <a title="php|architect rebooted" href="http://c7y.phparch.com/c/entry/1/news,20080929-php_architect_rebooted" target="_blank">news</a> to announce concerning their magazine: a new logo, full colour printing and a new subscription price.</p>
<p>Ohoh, a new subscription price is usually bad news.<br />
What was the old situation: they offered 3 different types of subscription to their PHP magazine &#8216;php|architect&#8217;, namely paper only, pdf only and both.<br />
I had a subscription to the pdf only, this was also the cheapest subscription.<br />
In the new situation they will offer the paper and pdf together for less than the pdf version in the old situation. So the subscribers will receive more value for less money and that in these times.</p>
<p>So where is the catch ?<span id="more-60"></span></p>
<p>The new offer started in October and given the difference between the old subscription price and the new, they have decided to provide all their current subscribers with an extension to their subscription equal to the old cost of the remaining issues in their account divided by the new price. In my case I got 2 months extra for free.</p>
<p>Come on, where is the catch.</p>
<p>They also moved their printing facilities to be closer to their distribution center and introduced a lighter, environmentally-conscious paper to reduce their environmental impact. So their move to an all-print subscription should be largely carbon-neutral.<br />
You&#8217;ll find more on this on Marco Tabinis <a title="Marco Tabini blog" href="http://mtabini.blogspot.com/2008/10/some-thoughts-on-phparchitect-relaunch.html" target="_blank">blog</a>.</p>
<p>There is no catch. It is all good news.</p>
<p>Thanks Marco Tabini.</p>
<table style="border: medium none; margin: 20px auto; width: auto;" border="0" align="center">
<tbody>
<tr>
<td>Generosity always has admirers, but rarely imitators</td>
</tr>
<tr>
<td align="right"></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://blog.johan-mares.be/ict/php/a-nice-gesture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP namespace separator</title>
		<link>http://blog.johan-mares.be/ict/php/php-namespace-separator/</link>
		<comments>http://blog.johan-mares.be/ict/php/php-namespace-separator/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 09:37:15 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[namespace]]></category>

		<guid isPermaLink="false">http://blog.johan-mares.be/?p=41</guid>
		<description><![CDATA[I honestly thought that the namespace separator for PHP was a done deal, namely '::'.  It was originally planned to introduce namespaces in PHP6, but they moved it to the upcoming PHP 5.3 and due to problems implementing that they made a last minute change to '\'.
A lot of people are happy that PHP will finally have support for namespaces, but a lot of people also think they made a really bad choice for the separator.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.johan-mares.be%2Fict%2Fphp%2Fphp-namespace-separator%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.johan-mares.be%2Fict%2Fphp%2Fphp-namespace-separator%2F&amp;source=maresjohan&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>I honestly thought that the namespace separator for PHP was a done deal, namely &#8216;::&#8217;.  It was originally planned to introduce namespaces in PHP6, but they moved it to the upcoming PHP 5.3 and due to problems implementing that they made a last minute change to &#8216;\&#8217;.</p>
<p>A lot of people are happy that PHP will finally have support for namespaces, but a lot of people also think they made a really bad choice for the separator.<span id="more-41"></span><br />
One of the best comments I found was on <a title="PHP Gets Namespace Separators, With a Twist " href="http://developers.slashdot.org/article.pl?sid=08/10/26/1610259" target="_blank">slashdot</a> and it gives an overview of the separators for different programming languages:</p>
<pre>Java:
Attribute/Method access: foo.bar
Static method access:    Foo.bar
Package access:          foo.bar.baz

C#:
Attribute/Method access: foo.bar
Static method access:    Foo.bar
Namespace access:        foo.bar.baz

Python:
Attribute/Method access: foo.bar
Static method access:    Foo.bar
Module access:           foo.bar.baz

PHP:
Attribute/Method access: $foo-&gt;bar
Static method access:    Foo::bar
Namespace access:        foo\bar\baz</pre>
<p>My thoughts about this:</p>
<ul>
<li>it makes PHP look inconsistent</li>
<li>it makes the introduction of namespaces in PHP look like a rush job, improvisation, some quick and dirty programming</li>
<li>if they encountered serious problems introducing namespaces in PHP 5.3, they should have postponed it to PHP6, like originally planned</li>
<li>it feels weird using a backslash on the left side of an assignment operator</li>
<li>it looks ugly</li>
</ul>
<p>I don&#8217;t think I will be using namespaces anytime soon, because I will be using PHP 5.1.6 at work and PHP 5.2.5 on this shared hosting for a while longer, but when I have to I will just go with the flow like everybody else. Unless you choose for poor man&#8217;s namespacing (and be using very long classnames).</p>
<p>Just my 0.02 €</p>
<table style="border: medium none; margin: 20px auto; width: auto;" border="0" align="center">
<tbody>
<tr>
<td>Trying to please everybody,<br />
you&#8217;ll please no one.</td>
</tr>
<tr>
<td align="right"></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://blog.johan-mares.be/ict/php/php-namespace-separator/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
