A virtual host is a specific website to be served off a given server. You may have
many virtual hosts to serve different domains (or subdomains) on one system.
Nginx uses the directory /etc/nginx/sites-available/ to store configuration
files for virtual hosts. At startup, it will check another directory, /etc/nginx/sitesenabled/,
and usually, these files are symbolic links to the configuration files in
sites-available.
There should be a file called default, which is the default site that nginx serves.
We will remove the symbolic link of the default site, create a new configuration file
and symbolic link, and finally restart nginx. We will use the name nginpi, but feel
free to use any name you like for the virtual host.
Edit the new nginx configuration file found at /etc/nginx/nginx.conf and add the
following to it:
browser. This can be enough for some people as you can include jQuery into these
files and send AJAX requests to other sites or network locations to get various data
without PHP running on the Pi. Let's enable the site:
2. Place some basic HTML markup into it.
3. Use a browser on another computer on your network that can access the Pi
on port 80 and browse to it.
4. You should see your basic web page now.
many virtual hosts to serve different domains (or subdomains) on one system.
Nginx uses the directory /etc/nginx/sites-available/ to store configuration
files for virtual hosts. At startup, it will check another directory, /etc/nginx/sitesenabled/,
and usually, these files are symbolic links to the configuration files in
sites-available.
There should be a file called default, which is the default site that nginx serves.
We will remove the symbolic link of the default site, create a new configuration file
and symbolic link, and finally restart nginx. We will use the name nginpi, but feel
free to use any name you like for the virtual host.
sudo service nginx stop
sudo unlink /etc/nginx/sites-enabled/default
sudo touch /etc/nginx/sites-available/nginpi
Edit the new nginx configuration file found at /etc/nginx/nginx.conf and add the
following to it:
server {This is the most basic configuration to serve up some standard HTML markup to any
listen 80;
root /var/www/local/web;
index index.html index.html;
}
browser. This can be enough for some people as you can include jQuery into these
files and send AJAX requests to other sites or network locations to get various data
without PHP running on the Pi. Let's enable the site:
cd /etc/nginx/sites-enabled1. Create a file named index.html in the /var/www directory.
sudo ln –s ../sites-available/nginpi
sudo service nginx start
2. Place some basic HTML markup into it.
3. Use a browser on another computer on your network that can access the Pi
on port 80 and browse to it.
4. You should see your basic web page now.
No comments:
Post a Comment