How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu

sudo apt-get update
sudo apt-get install nginxsudo mkdir -p /var/www/example.com/html
sudo chown -R $USER:$USER /var/www/example.com/html
sudo chmod -R 755 /var/www
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/example.com
sudo nano /etc/nginx/sites-available/example.com
server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

    server_name localhost;

    location / {
        try_files $uri $uri/ =404;
    }
}
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/sudo rm /etc/nginx/sites-enabled/default
sudo service nginx restart
https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-14-04-lts
 
时间: 2024-11-10 07:05:56

How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu的相关文章

配置 nginx server 出现nginx: [emerg] "root" directive is duplicate in /etc/nginx/server/blogs.conf:7

在配置nginx 虚拟机时,执行 sudo /usr/sbin/nginx -t 报下面的错误: nginx: [emerg] "root" directive is duplicate in /etc/nginx/server/blogs.conf:7 nginx: configuration file /etc/nginx/nginx.conf test failed 错误原因是:在配置文件时,访问路径设置了两个,重复配置webroot路径导致,去掉一个就可以了. server {

Apache Virtual Hosting IP Based and Name Based Virtual Hosts

As we all are aware that Apache is a very powerful, highly flexible and configurable Web server for Nix OS. Here in this tutorial, we are going to discuss one more feature of Apachewhich allows us to host more than one website on a single Linux machi

How To Set Up Apache Virtual Hosts on CentOS 6

About Virtual Hosts 虚拟主机,用于在一个单一IP地址上,运行多个域.这对那些想在一个VPS上,运行多个网站的人,尤其有用.基于用户访问的不同网站,给访问者显示不同的信息.没有限制能VPS中,添加的虚拟主机的个数. Set Up 教程中的这些步骤,需要你有root权限.你可以查看Initial Server Setup ,来学习如何设置初始化服务器.这里使用www.作为root的名字,你可以使用你想用的. 另外,你需要在你的VPS上安装并运行apache. 如果没有安装,你可以

Configure Apache Virtual Hosts - CentOS 7

Difficulty: 2Time: 15 minutes Want to host websites on your server? Using Apache? Great. This article will show you how to do exactly that using Apache’s “virtual hosts.” In Apache, you can use virtual hosts to direct http traffic for a given domain

Install LEMP (Linux, Nginx, MySQL and PHP) Stack on Ubuntu Linux 14.04 LTS(转)

Install LEMP (Linux, Nginx, MySQL and PHP) Stack on Ubuntu Linux 14.04 LTS Nginx Installation Nginx is one of the robust web server in Linux world. Nginx is a free, open source, high performance HTTP server and reverse proxy, as weell as an IMAP/POP3

Nginx Server 的配置解析

Config file Nginx.conf 配置文件主要分为三部分: 全局块 Events 块 HTTPS 块 Global Block 指主要配置影响全局的参数,配置对Server的运行,包括运行的用户组,进程PID存放路径.日志存放路径以及配置文件的引入. 如下配置: user nobody;worker_processes  4;error_log  /data/nginx/logs/error.log  notice; Events 块 Event块涉及的指令主要控制 Nginx 服务

nginx Server names

通配符名称 正則表達式名称 混合名称 优化 兼容性 server名称定义使用的server_name指令和决定哪个server块用于一个给定的请求. 參见"怎样Nginx处理一个请求".能够使用确切名称.通配符或正則表達式定义它们: server { listen 80; server_name example.org www.example.org; ... } server { listen 80; server_name *.example.org; ... } server {

nginx server配置及路由重写相关

文件名   example.conf server { #监听的端口号 listen 80; #域名 server_name  www.example.com   *.example.com; #指定目录某个目录的父目录,          root  D:/www; #指定404页面 error_page 404 /404.php; #location模块当其他都匹配不到的时候才匹配'/' #根目录下, location  /  { #配置默认页 index  index.php #nginx

Nginx Server 上80,443端口。http,https共存

server{ listen 80; listen 443 ssl; server_name www.iamle.com; index index.html index.htm index.php; root /home/wwwroot/www.iamle.com/; #ssl on; 这里要注释掉 ssl_certificate /usr/local/nginx/conf/ssl/www_iamle_com.crt; ssl_certificate_key /usr/local/nginx/c