<< All Posts
Installing Symfony2 on OpenBSD 5.6


Hi there!

Let’s install the Symfony2 on OpenBSD 5.6. If you still don’t know how to install and configure nginx + php on OpenBSD click here to see my last blog post.

  1. First, let’s install CURL:
$ export PKG_PATH=ftp://mirrors.nycbug.org/pub/OpenBSD/5.6/packages/`machine -a`/
$ sudo pkg_add curl
 quirks-2.9 signed on 2014-07-31T22:37:55Z
 curl-7.37.0:libidn-1.28p0: ok
 curl-7.37.0: ok
  1. Configuring PHP CLI:
$ cd /usr/local.bin
$ sudo ln -s php-5.5 php
  1. Installing Composer:
$ curl -sS https://getcomposer.org/installer | php
 #!/usr/bin/env php
 Some settings on your machine make Composer unable to work properly.
 Make sure that you fix the issues listed below and run this script again:
The allow_url_fopen setting is incorrect.
 Add the following to the end of your `php.ini`:
 allow_url_fopen = On

The php.ini used by your command-line PHP is: /etc/php-5.5.ini
If you can not modify the ini file, you can also run `php -d option=value` to modify ini values on the fly. You can use -d multiple times.

Okay, We got this error. PHP are not allowing to use URL_FOPEN. Let’s change /etc/php-5.5.ini

  1. vi /etc/php-5.5.ini
allow_url_fopen = On
  1. Downloading composer again and trying to install symfony2:
sudo su
 # sudo curl -sS https://getcomposer.org/installer | php
 exit
 $ sudo php composer.phar create-project symfony/framework-standard-edition project/
 Installing symfony/framework-standard-edition (v2.6.3)
 - Installing symfony/framework-standard-edition (v2.6.3)
 Downloading: 100%
 Failed to download symfony/framework-standard-edition from dist: Could not decompress the archive, enable the PHP zip extension.
 The php.ini used by your command-line PHP is: /etc/php-5.5.ini
 Now trying to download from source
 - Installing symfony/framework-standard-edition (v2.6.3)
 Cloning 4e2519619fddc6e403f70d5c5d50a71128f01c62
 [RuntimeException]
 Failed to clone [email protected]:symfony/symfony-standard.git, git was not found, check that it is installed and in your PATH env.
 sh: git: not found
  1. Errors, Errors, Errors. So, We need to install php zip extension and git. Let’s do it:
$ sudo pkg_add php-zip
 quirks-2.9 signed on 2014-07-31T22:37:55Z
 Ambiguous: choose package for php-zip
 a       0: <None>
 1: php-zip-5.3.28p9
 2: php-zip-5.4.30
 3: php-zip-5.5.14
 Your choice: 3
 php-zip-5.5.14: ok
 --- +php-zip-5.5.14 -------------------
 You can enable this module by creating a symbolic link from
 /etc/php-5.5.sample/zip.ini to
 /etc/php-5.5/zip.ini. As root:
ln -sf /etc/php-5.5.sample/zip.ini /etc/php-5.5/zip.ini
 $ sudo ln -sf /etc/php-5.5.sample/zip.ini /etc/php-5.5/zip.ini
  1. Now, let’s install git
$ sudo pkg_add git
 quirks-2.9 signed on 2014-07-31T22:37:55Z
 |No change in quirks-2.9Ambiguous: choose dependency for git-1.9.3:
 a       0: rsync-3.1.1
 1: rsync-3.1.1-iconv
 Your choice: 
 git-1.9.3:cvsps-2.1p0: ok
 git-1.9.3:rsync-3.1.1: ok
 git-1.9.3:p5-Error-0.17019: ok
 git-1.9.3: ok
 The following new rcscripts were installed: /etc/rc.d/rsyncd
 See rc.d(8) for details.
 Look in /usr/local/share/doc/pkg-readmes for extra documentation.
  1. Installing php-curl extension:
$ sudo pkg_add php-curl
 quirks-2.9 signed on 2014-07-31T22:37:55Z
 Ambiguous: choose package for php-curl
 a       0: <None>
 1: php-curl-5.3.28p9
 2: php-curl-5.4.30
 3: php-curl-5.5.14
 Your choice: 3
 php-curl-5.5.14: ok
 --- +php-curl-5.5.14 -------------------
 You can enable this module by creating a symbolic link from
 /etc/php-5.5.sample/curl.ini to
 /etc/php-5.5/curl.ini. As root:
ln -sf /etc/php-5.5.sample/curl.ini /etc/php-5.5/curl.ini
$ sudo ln -sf /etc/php-5.5.sample/curl.ini /etc/php-5.5/curl.ini
9. Finally we're able to install symfony2!
sudo php composer.phar create-project symfony/framework-standard-edition path/
 Installing symfony/framework-standard-edition (v2.6.3)
 - Installing symfony/framework-standard-edition (v2.6.3)
 Loading from cache

Created project in path/
 Loading composer repositories with package information
 Installing dependencies (including require-dev)
 - Installing psr/log (1.0.0)
 Downloading: 100%
- Installing twig/twig (v1.18.0)
 Downloading: 100%
- Installing doctrine/lexer (v1.0.1)
 Downloading: 100%
- Installing doctrine/annotations (v1.2.3)
 Downloading: 100%
- Installing doctrine/collections (v1.2)
 Downloading: 100%
- Installing doctrine/cache (v1.4.0)
 Downloading: 100%
- Installing doctrine/inflector (v1.0.1)
 Downloading: 100%
- Installing doctrine/common (v2.4.2)
 Downloading: 100%
- Installing symfony/symfony (v2.6.3)
 Downloading: 100%
- Installing doctrine/dbal (v2.5.1)
 Downloading: 100%
- Installing doctrine/orm (v2.4.7)
 Downloading: 100%
- Installing doctrine/doctrine-cache-bundle (v1.0.1)
 Downloading: 100%
- Installing jdorn/sql-formatter (v1.2.17)
 Downloading: 100%
- Installing doctrine/doctrine-bundle (v1.3.0)
 Downloading: 100%
- Installing twig/extensions (v1.2.0)
 Downloading: 100%
- Installing kriswallsmith/assetic (v1.2.1)
 Downloading: 100%
- Installing symfony/assetic-bundle (v2.6.1)
 Downloading: 100%
- Installing swiftmailer/swiftmailer (v5.3.1)
 Downloading: 100%
- Installing symfony/swiftmailer-bundle (v2.3.8)
 Downloading: 100%
- Installing monolog/monolog (1.12.0)
 Downloading: 100%
- Installing symfony/monolog-bundle (v2.7.1)
 Downloading: 100%
- Installing sensiolabs/security-checker (v2.0.1)
 Downloading: 100%
- Installing sensio/distribution-bundle (v3.0.16)
 Downloading: 100%
- Installing sensio/framework-extra-bundle (v3.0.4)
 Downloading: 100%
- Installing incenteev/composer-parameter-handler (v2.1.0)
 Downloading: 100%
- Installing sensio/generator-bundle (v2.5.1)
 Downloading: 100%

kriswallsmith/assetic suggests installing leafo/lessphp (Assetic provides the integration with the lessphp LESS compiler)
 kriswallsmith/assetic suggests installing leafo/scssphp (Assetic provides the integration with the scssphp SCSS compiler)
 kriswallsmith/assetic suggests installing ptachoire/cssembed (Assetic provides the integration with phpcssembed to embed data uris)
 kriswallsmith/assetic suggests installing leafo/scssphp-compass (Assetic provides the integration with the SCSS compass plugin)
 kriswallsmith/assetic suggests installing patchwork/jsqueeze (Assetic provides the integration with the JSqueeze JavaScript compressor)
 symfony/assetic-bundle suggests installing kriswallsmith/spork (to be able to dump assets in parallel)
 monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
 monolog/monolog suggests installing raven/raven (Allow sending log messages to a Sentry server)
 monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
 monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
 monolog/monolog suggests installing videlalvaro/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
 monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
 monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
 monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
 monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
 Writing lock file
 Generating autoload files
 Would you like to install Acme demo bundle? [y/N] y
 Installing the Acme demo bundle.
 Creating the "app/config/parameters.yml" file
 Some parameters are missing. Please provide them.
 database_driver (pdo_sqlite):
 database_host (127.0.0.1):
 database_port (null):
 database_name (symfony):
 database_user (root):
 database_password (null):
 mailer_transport (smtp):
 mailer_host (127.0.0.1):
 mailer_user (null):
 mailer_password (null):
 locale (en):
 secret (ThisTokenIsNotSoSecretChangeIt):
 Clearing the cache for the dev environment with debug true
 Trying to install assets as symbolic links.
 Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework
 The assets were installed using symbolic links.
 Installing assets for Acme\DemoBundle into web/bundles/acmedemo
 The assets were installed using symbolic links.
 Installing assets for Sensio\Bundle\DistributionBundle into web/bundles/sensiodistribution
 The assets were installed using symbolic links.
  1. That’s really cool eh? Okay, now that we downloaded our symfony2 framework, let’s fix the document root on /etc/nginx/nginx.conf. Just change the document root to be /var/www/htdocs/path/web

  2. Here I decided to add my user on www group. And changed my whole htdocs directory to www group. I decided to uncomment umask(0000); in web/app.php, web/app_dev.php and app/console. This is necessary because OpenBSD doesn’t have setfacl.

  3. This is my nginx.conf

worker_processes  1;
worker_rlimit_nofile 1024;
events {
    worker_connections  800;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    index         index.php index.html index.htm app.php;
    keepalive_timeout  65;
    server_tokens off;

    server {
        listen       80;
        listen       [::]:80;
        server_name  ule.php-br.org; 
        root         /var/www/htdocs/path/web;

        location = /50x.html {
            root  /var/www/htdocs/path/web;
        }

        location / {
            try_files $uri /app.php$is_args$args;
        }

    location ~ ^/(app_dev|config)\.php(/|$) {
        fastcgi_pass   unix:run/php-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS off;
    }


        location ~ ^/app\.php(/|$) {
            fastcgi_pass   unix:run/php-fpm.sock;
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param HTTPS off;
            internal;
        }

        location ~ \.php$ {
            try_files      $uri $uri/ =404;
            fastcgi_pass   unix:run/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}
  1. That’s it! Just restart your php_fpm and your nginx and test it!
sudo /etc/rc.d/php_fpm restart
sudo /etc/rc.d/nginx -f restart



<< All Posts