User Tools

Site Tools


web

This is an old revision of the document!


Web Servers

One-line HTTP servers

Apache2 httpd

Debian instructions:

apt install apache2 php libapache2-mod-php php-pdo-sqlite
 
# Enable/disable modules (/etc/apache2/mods-avaialable/)
a2enmod userdir
a2dismod userdir
 
# Enable/disable sites (/etc/apache2/sites-available/)
a2ensite mysite
a2dissite mysite

The user is www-data and the default webroot is /var/www/html/ (Debian).

Nginx

See https://www.devdungeon.com/content/nginx-tutorial.

apt install nginx

To add PHP, use PHP FPM

apt install php-fpm

Then in your vhost file, include the following snippet:

  # In your nginx vhost server entry:
  index index.php;
  # Have all .php files pass through php-fpm
  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    # Find the right socket in /run/php/
    fastcgi_pass unix:/run/php/php7.3-fpm.sock;
  }

Here is an example nginx site config:

example.nginx.conf
server {
  listen 80;
  listen [::]:80;
  #listen 443 ssl;
  #listen [::]:443 ssl;
 
  server_name www.devdungeon.com;
 
  #ssl_certificate /etc/ssl/private/self-signed.cert;
  #ssl_certificate_key /etc/ssl/private/self-signed.key;
  #ssl_ciphers  HIGH:!aNULL:!MD5;
 
  # Map a static dir
  location /camserver/static/ {
    alias /path/to/static/;
  }
 
  # Reverse proxy  
  location /camserver/ {
    proxy_pass http://localhost:8002/;
    proxy_set_header X-Real-IP $remote_addr;
  }
 
  # List directory contents
  location /images {
    autoindex on;
    alias /path/to/images/;
  }
 
  root /var/www/html/;
  index index.php index.html;
 
  location / {
    try_files $uri $uri/ =404;
  }
 
  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    # Find right socket in /run/php/
    fastcgi_pass unix:/run/php/php7.3-fpm.sock;
    include fastcgi_params;
  }
 
  location ~ /\.ht {
    deny all;
  }
}
web.1618452845.txt.gz · Last modified: 2021/04/15 02:14 by nanodano