Skip to content

Webserver

Benoît edited this page Jan 15, 2018 · 9 revisions

Webserver

Nginx

server {
    root /vagrant/sites/e-media/web;

    location / {
        try_files $uri /app.php$is_args$args;
    }
    location ~ ^/(app_dev|config)\.php(/|$) {
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
    }
    location ~ ^/app\.php(/|$) {
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        internal;
    }

    #used: to stream file directly by the server using 'X-Accel': 
    #see: https://github.com/benIT/e-media/wiki/Webserver
    location /stream-files {
        alias /vagrant/shared/e-media/web/e-media-data/;
        internal;
    }

    location ~ \.php$ {
        return 404;
    }

    error_log /var/log/nginx/emedia_error.log;
    access_log /var/log/nginx/emedia_access.log;
}

sudo rm -f /etc/nginx/sites-enabled/default 
sudo ln -s /etc/nginx/sites-available/emedia /etc/nginx/sites-enabled/emedia

Apache 2

Modules

Install rewrite module:

   sudo a2enmod rewrite

Install xsendfile module. This module will be used to delegate apache large video file serving. See this controller, for example.:

  sudo a2enmod xsendfile

Take a look to the configuration in the vhost below.

Virtual host

Here a basic vhost for running the app in /etc/apache2/sites-available/video-app.conf file:

Listen 10000
<VirtualHost *:10000>
        #ServerName www.example.com
        ServerAdmin webmaster@localhost
        DocumentRoot /vagrant/shared/videoapp/web

        <Directory /vagrant/shared/videoapp>
                XSendFilePath   /vagrant/shared/e-media/web/e-media-data/
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Restart apache2:

    sudo service apache2 restart 
Clone this wiki locally