Wednesday, December 4, 2013

Zend Skeleton App default ZF2 path?

I'm playing around with the Zend Skeleton Application to see how useful it will be to build an application in the future. I got it all installed correctly using a combination of git and composer and everything is working fine...until I try and update the autoloader.

As it turns out, composer seems to have installed the zend framework in a different area than it was expected in the Zend Skeleton Application default configuration.

The default autoloader file init_autoloader.php looks like this
$zf2Path = false;


if (is_dir('vendor/ZF2/library')) {
    $zf2Path = 'vendor/ZF2/library';
} elseif (getenv('ZF2_PATH')) {      // Support for ZF2_PATH environment variable or git submodule
    $zf2Path = getenv('ZF2_PATH');
} elseif (get_cfg_var('zf2_path')) { // Support for zf2_path directive value
    $zf2Path = get_cfg_var('zf2_path');
}

The composer install put everything in vendor/zendframework/zendframework/library and not in vendor/ZF2/library. A quick little update like below and I was all set.

$zf2Path = false;


if (is_dir(vendor/zendframework/zendframework/library')) {
    $zf2Path = 'vendor/zendframework/zendframework/library';
} elseif (getenv('ZF2_PATH')) {      // Support for ZF2_PATH environment variable or git submodule
    $zf2Path = getenv('ZF2_PATH');
} elseif (get_cfg_var('zf2_path')) { // Support for zf2_path directive value
    $zf2Path = get_cfg_var('zf2_path');
}

Friday, November 15, 2013

Opening up web server ports on CentOS/selinux

I was setting up a test webserver that I could run a couple different web apps. There are a few things you need to know in order to set this up. There are three modifications that you need to make to be able to do this from a default installation. These mods are through httpd, selinux, iptables.

Let's say I want to open a port on 8000. First, make your modifications to the apache config. This should be located in /etc/httpd/conf/httpd.conf

Listen 8000
<VirtualHost *:8000>
    # ServerName I.dont.need.one.of.these.for.my.purposes
    DocumentRoot /path/to/web/directory
    SetEnv APPLICATION_ENV "development"
    <Directory /path/to/web/directory>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Great, that's all set up. Let's try and restart the httpd service

service http restart

Stopping httpd:                                            [OK]
Starting httpd:                                            [FAILED]
(98)Address already in use: make_sock: could not bind to address [::]:8000

What? What's going on? Listing the services using netstats doesn't reveal that the port is taken. Doing some research reveals that CentOS is shipped with selinux setup and that I need to open a port for that

semanage port -a -t http_port_t -p tcp 8000

After this step, go ahead and restart the httpd service.

service http restart
Stopping httpd:                                            [FAILED]
Starting httpd:                                            [OK]

Yay, everything is working right? Navigate to http://192.168.0.1:8000 and nothing responds. Check the apache logs and there's not even an access attempt. Do a little more research and it looks like the default CentOS installation comes with iptables installed and tightly regulated. You'll find the config file at /etc/sysconfig/iptables. Add the following line.

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8000 -j ACCEPT

Now all we need to do is restart iptables and we're all set

service iptables restart

Installing Git on CentOS 5

I was working with an older version of CentOS today and found out that the git repositories didn't exist. So just a quick note on getting git set up on CentOS 5.

Install the dependencies
yum install gcc gettext-devel expat-devel curl-devel zlib-devel openssl-devel

Get the latest git tarball. The latest for me was git-1.8.4.3.tar.gz
wget https://www.kernel.org/pub/software/scm/git/git-1.8.4.3.tar.gz

Untar the tarball
tar -xvfz git-1.8.4.3.tar.gz

Make...profit.
cd git-1.8.4.3

make prefix=/usr/local all

make prefix=/usr/local install