Skip to content

Webserver

Benoît edited this page Apr 11, 2018 · 9 revisions

Webserver

See this official ressource for webserver configuration.

Large video files are served throught mod_xsendfile for Apache and X-Accel for Nginx.

Those directives will be used to delegate to webserver large video file serving. See this controller, for example.

PHP

sudo apt-get install -y php7.0 php7.0-fpm php-xml php-pgsql

php.ini configuration

upload_max_filesize = 2048M
post_max_size = 2048M

sudo service php7.0-fpm restart

Nginx

nginx conf

in /etc/nginx/nginx.conf:

    client_max_body_size 2048M;

Download speed are controlled using these directives:

  • limit_rate_after 1m;

  • limit_rate 150k;

Vhost:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    listen 443 ssl; 
    server_name e-media.local;
    ssl_certificate /etc/nginx/ssl/nginx.crt;
    ssl_certificate_key /etc/nginx/ssl/nginx.key;

    root /vagrant/shared/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 {
        #limit connection rate
    limit_rate_after 1m;
    limit_rate 150k;
    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/emedia.conf file:

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

        <Directory /vagrant/shared/e-media>
                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

Enable site:

   sudo a2ensite emedia

Restart apache2:

    sudo service apache2 restart 
Clone this wiki locally