Browsing articles in "Apache"

“concrete5 cannot parse the PATH_INFO or ORIG_PATH_INFO information provided by your server.”

Thought I’d take a look into concrete5 to see what is was like, and it’s the first open source PHP project installer I’ve come across in ages that complained about anything other than filesystem permissions. PATH_INFO? Most other projects use different mechanisms/variables to do a similar job I assume…

Anyways, go to the concrete5 install directory and create a .htaccess file there with the following contents:

php_flag display_errors off
AcceptPathInfo On

If you don’t suppress PHP errors it won’t work, which I read may be related to an Ajax callback failing because the response is full of errors (the installer isn’t written properly? I’ve no idea…)

I’ve also heard that some hosting providers (like GoDaddy) don’t play well with .htaccess files, which unfortunately if that’s the case you’ll have to get in touch with them!

Zend Server lighttp not running (phpMyAdmin) but Apache is? How to start it manually

If for some reason you’ve powered on and while Apache seems to be running OK, lighttp isn’t (for example phpMyAdmin isn’t working on localhost:10081/phpmyadmin) then you will need to start it manually. This is probably caused by a dirty restart, such as a power failure. On Mac OS X run this command…

sudo /usr/local/zend/bin/lighttpdctl.sh start

For Windows, I’m afraid I will have to find that out!

Use phpMyAdmin with a remote MySQL server

Been doing relatively proprietary work recently, so not much to share other than this little tip. If you want to use phpMyAdmin but for whatever reason the MySQL server you’re using isn’t local, you can change the host by editing line 104 in config.inc.php in the root of phpMyAdmin:

$cfg['Servers'][$i]['host'] = 'localhost';

… and optionally the port if required

$cfg['Servers'][$i]['port'] = '';

Configuring Zend Server CE on Mac OS X

Unlike Windows which doesn’t come with Apache by default, or distributions of Linux which (usually) have their own package management systems, Mac OS X comes with an outdated version of Apache which isn’t handled by package management. This means it’s a pain to either update or remove it. Any Mac PHP developer will probably have tried MAMP which gives you a relatively pain-free installation, but for anything complex it can be a bit tricky due to the way it’s self-contained. As a Zend Framework developer I use Zend Server and Zend Server CE at work now and figured now that I’ve got to do some work at home I should look to get it installed and configured…

Just to check that everything is working OK to start with, go to http://localhost/ and you should see the default Mac OS X homepage which will be located in your Sites directory.

Installation

Download Zend Server CE from Zend and install as usual.

Configuration

Disable the default Apache installation

apachectl stop

Replace the default apachectl with Zend Server’s apachectl

Easiest way to do this (without uninstalling anything) is to replace the default apachectl with Zend Server’s apachectl, that way it will just appear to be launching Apache as per usual when OS X starts up.

Firstly move apachectl to a safe place, such as your home directory:

cd /usr/sbin/
sudo mv apachectl /Users/yourusername/

Then create a symbolic link to Zend Server’s apachectl:

sudo ln -s /usr/local/zend/apache2/bin/apachectl ./ 

Start Zend Server’s Apache:

sudo apachectl start

You should then see:

/usr/sbin/apachectl start [OK]

This will indicate that you are running Zend Server’s Apache as opposed to Mac OS X’s Apache (as the latter doesn’t output to the terminal when you start/stop it) although if you go to http://localhost/ you will notice that you will get a 404.

Configure Apache to use port 80

I’m assuming to avoid any conflict with the default Apache installation that Zend Studio’s Apache comes preconfigured to use port 10088. To change this simply edit the configuration:

sudo vi /usr/local/zend/apache2/conf/httpd.conf

… or if you dont use Vi, use another text editor such as Nano:

sudo nano /usr/local/zend/apache2/conf/httpd.conf

Look for the line Listen 10088, then either comment it out and add a new line or edit the port to be port 80.

#Listen 10088
Listen 80

You may also need to change the DocumentRoot and first Directory parameters to your webroot (/Users/username/Sites for example)

Save httpd.conf (Ctrl + x in Nano to exit then y to save) and restart Apache:

sudo apachectl restart

If you go to http://localhost/ in your browser you should now see the default Mac OS X homepage, as httpd.conf should already be setup to point to your Sites directory by default.

If you get any complaints about the FQDN when you start Apache, such as:

httpd: Could not reliably determine the server's fully qualified domain name, using iMac.local for ServerName

Then you need to explicitely set the name of the domain to be used (in this case, localhost)

#ServerName www.example.com:10088
ServerName localhost:80

Configure Zend Framework

sudo ln -s /usr/local/zend/share/ZendFramework/bin/zf.sh ./zf

Configure Pear

sudo ln -s /usr/local/zend/bin/pear ./
sudo pear upgrade pear

Configure MySQL

You can create symbolic links for the typical MySQL commands if you wish (although you can change the include paths for the shell if you so desire)

sudo ln -s /usr/local/zend/mysql/bin/mysql ./
sudo ln -s /usr/local/zend/mysql/bin/mysqladmin ./
sudo vi /usr/local/zend/mysql/data/my.cnf
#socket = /usr/local/zend/mysql/tmp/mysql.sock
socket = /tmp/mysql.sock

Configure phpMyAdmin

If you change the web root for Apache, you will have to create a Directory entry and Alias for phpMyAdmin, since it exists somewhere else:

sudo vi /usr/local/zend/apache2/conf/httpd.conf

Alias /phpMyAdmin /usr/local/zend/share/phpmyadmin

<Directory "/usr/local/zend/share/phpmyadmin">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Install PHPUnit

sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony-project.com
sudo pear update-channels
sudo pear install --alldeps phpunit/PHPUnit
sudo ln -s /usr/local/zend/bin/phpunit ./
sudo pear install --alldeps phpunit/PHPUnit

Installing PHPUnit with Zend Server (CE) on Windows using PEAR

After a few hours of trying to figure out what was failing each time, I think I’ve finally found the solution (which is a combination of various other tidbits of information I’ve picked up from other blogs)

Firstly, assuming you’ve got a stock installation of Zend Server or Zend Server CE, it will be installed at:

C:\Program Files\Zend\ZendServer\

Therefore the PEAR setup batch file will be located at:

C:\Program Files\Zend\ZendServer\bin\go-pear.bat

If you run this from the command line (go to the bin directory then type “go-pear”) it will prompt you with the setup configuration for PEAR. The prompt will look something like this:

Are you installing a system-wide PEAR or a local copy?(system|local) [system] : system

Below is a suggested file layout for your new PEAR installation.  Tochange individual locations, type the number in front of thedirectory.  Type 'all' to change all of them or simply press Enter toaccept these locations.

The issue that was causing my installation in particular to fail (which is not an issue with say XAMPP or other bundles) is that Zend Server installs by default to your Program Files directory, which has a space in it. PEAR doesn’t play well with spaces, so you will need to change your Temporary directory for processing and Temporary directory for downloads to something without a space such as C:\Temp or C:\tmp

Type “all” to change them all and simply enter replacement paths for the temporary directories, then hit enter when re-prompted. This should install PEAR and create a Registry file for you to merge (it will say where it created it, which should be in the same directory you just ran go-pear.bat in)

Type “pear” at the command line to see if it installed properly. Once it’s working OK type the following:

pear channel-discover pear.phpunit.depear channel-discover components.ez.nopear channel-discover pear.symfony-project.compear update-channels

This will add the channels that contain the packages required by PHPUnit (you’ll need all 3) then updates all available channels

pear upgrade pear

This will upgrade PEAR in case it is not up to date.

pear install --alldeps phpunit/PHPUnit

This will install PHPUnit from the correct channel with all the dependencies it requires (which is what the Symfony and eZ Component channels are needed for)

The problems I encountered which aren’t covered elsewhere is the fact that PEAR will fail trying to download and install packages if you don’t change the temporary directories, and that without the additional channels (not just the PHPUnit channel) it doesn’t seem to be able to work out where the dependencies are even though it knows they are required.

Mac OS X Apache not starting properly

Whilst trying to figure out why Zend Server CE wasn’t working properly on my Mac (again…) I realised that something was wrong with the version of Apache shipped with OS X. Luckily Chris Oliver found the problem in the Apache control script.

http://excid3.com/blog/2010/12/usrsbinapachectl-line-82-ulimit-open-files-cannot-modify-limit-invalid-argument/

It’d be nice if web stacks were as simple as on Linux (or even Windows) but you can but dream…