viernes, enero 17, 2014

Instalación de Zend Framework 2

Requerimientos:

  • Tener instalado Servidor WEB (en mi caso ZendServer2 + Apache) + PHP
  • SO: en mi caso Linux

Procedimiento:

    1. Crear un directorio virtual donde se instalara nuestro proyecto y ademas poseer un dominio, en mi caso registrare mi dominio aws.3a2.com en http://www.midominiogratis.es/
    2. Generare mi sitio virtual en /etc/http/vhost/3a2.conf
      # vim /etc/httpd/conf/httpd.conf
      ------------------------------
      #añado esta linea
      Include vhost/*.conf 
      #Verificar esta linea
      NameVirtualHost *:80
      ------------------------------
      # mkdir /etc/httpd/vhost
      # vim /etc/httpd/vhost/3a2.conf
      ------------------------------
      <virtualhost *:80> 
      ServerAdmin webmaster@3a2.com
      DocumentRoot /apps/3a2
      ServerName aws.3a2.com
      ErrorLog logs/3a2.com-error_log
      CustomLog logs/3a2.com-access_log common
          <Directory /apps/3a2 *:80>
          DirectoryIndex index.php
          Order allow,deny
          Allow from all
          Options FollowSymLinks -Indexes
          Order allow,deny
          Allow from all
          AllowOverride None
          RewriteEngine On
          RewriteCond %{REQUEST_FILENAME} -s [OR]
          RewriteCond %{REQUEST_FILENAME} -l [OR]
          RewriteCond %{REQUEST_FILENAME} -d
          RewriteRule ^.*$ - [NC,L]
          RewriteRule ^.*$ index.php [NC,L] 
          </Directory *:80> 
      </virtualhost> 
      -------------------------------
      # mkdir /apps && mkdir /apps/3a2
      # vim /apps/3a2/index.php
      --------------------------------
      phpinfo();
      ?>
      --------------------------------
      # /etc/init.d/httpd reload
    3. Antes de proceder a instalar proceder a verificar que el site levante
      3a2
    4. Ahora procederemos a instalar el framework, para esto clonaremos el site de modelo (Skeleton) que se posee en el github
      # yum -y install git
      # cd /apps/3a2/
      # git clone git://github.com/zendframework/ZendSkeletonApplication.git
      Initialized empty Git repository in /apps/3a2/ZendSkeletonApplication/.git/
      remote: Reusing existing pack: 2426, done.
      remote: Total 2426 (delta 0), reused 0 (delta 0)
      Receiving objects: 100% (2426/2426), 1.24 MiB | 1.08 MiB/s, done.
      Resolving deltas: 100% (1060/1060), done.
      # mv ZendSkeletonApplication/* .
      # rm -rf ZendSkeletonApplication
      # ls -l
      total 912
      -rw-r--r-- 1 root root    338 Jan 17 14:32 composer.json
      -rwxr-xr-x 1 root root 891620 Jan 17 14:32 composer.phar
      drwxr-xr-x 3 root root   4096 Jan 17 14:32 config
      drwxr-xr-x 3 root root   4096 Jan 17 14:32 data
      -rw-r--r-- 1 root root     40 Jan 17 12:52 index.php
      -rw-r--r-- 1 root root   1807 Jan 17 14:32 init_autoloader.php
      -rw-r--r-- 1 root root   1548 Jan 17 14:32 LICENSE.txt
      drwxr-xr-x 3 root root   4096 Jan 17 14:32 module
      drwxr-xr-x 6 root root   4096 Jan 17 14:32 public
      -rw-r--r-- 1 root root   2551 Jan 17 14:32 README.md
      drwxr-xr-x 3 root root   4096 Jan 17 14:32 vendor
      # /usr/local/zend/bin/php composer.phar self-update
      Updating to version b20021cc6aa113069e4223b78d0074a1fc7dd4e8.
          Downloading: 100%
      # /usr/local/zend/bin/php composer.phar install
      Loading composer repositories with package information
      Installing dependencies (including require-dev)
        - Installing zendframework/zendframework (2.2.5)
          Downloading: 100%
      
      zendframework/zendframework suggests installing doctrine/annotations (Doctrine Annotations >=1.0 for annotation features)
      zendframework/zendframework suggests installing ircmaxell/random-lib (Fallback random byte generator for Zend\Math\Rand if OpenSSL/Mcrypt extensions are unavailable)
      zendframework/zendframework suggests installing ocramius/proxy-manager (ProxyManager to handle lazy initialization of services)
      zendframework/zendframework suggests installing zendframework/zendpdf (ZendPdf for creating PDF representations of barcodes)
      zendframework/zendframework suggests installing zendframework/zendservice-recaptcha (ZendService\ReCaptcha for rendering ReCaptchas in Zend\Captcha and/or Zend\Form)
      Writing lock file
      Generating autoload files
    5. Ahora modificaremos las siguientes lineas del 3a2.conf para que apunte al public y añadiremos el SetEnv
      # vim /etc/httpd/vhost/3a2.conf
      ------------------------------
      <virtualhost *:80>
      ServerAdmin webmaster@3a2.com
      DocumentRoot /apps/3a2/public
      ServerName aws.3a2.com
      ErrorLog logs/3a2.com-error_log
      CustomLog logs/3a2.com-access_log common
      SetEnv APPLICATION_ENV "development" 
         <Directory /apps/3a2/public *:80>
         DirectoryIndex index.php
         Order allow,deny
         Allow from all
         Options FollowSymLinks -Indexes
         Order allow,deny
         Allow from all
         AllowOverride None
         RewriteEngine On
         RewriteCond %{REQUEST_FILENAME} -s [OR]
         RewriteCond %{REQUEST_FILENAME} -l [OR]
         RewriteCond %{REQUEST_FILENAME} -d
         RewriteRule ^.*$ - [NC,L]
         RewriteRule ^.*$ index.php [NC,L] 
         </Directory >
      </virtualhost> 
                     -------------------------------




  • Ahora a probar en el navegador debe salir
  • No hay comentarios: