跳至主要内容

Nginx建站最佳实践

虚拟主机配置文件存储放在/etc/nginx/sites-available目录。仅当链接到/etc/nginx/sites-enabled目录时,Nginx才会使用此目录中的配置文件。

例子:
建站 example.com
1.确定建站目录
可以任意目录
常规目录为:
/home/<user_name>/<site_name> 
/var/www/<site_name> 
/var/www/html/<site_name> 
/opt/<site_name>
例:/var/www/example.com
2.添加配置文件/ect/nginx/sites-available/example.com.conf
配置文件内容:
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
server {
listen 80;
listen [::]:80;

server_name example.com; #此处修改为访问域名

root /var/www/example.com; #此处修改为步骤1站目录
index index.html;

location / {
try_files $uri $uri/ =404;
}
}
3.开启站点
ln -s /ect/nginx/sites-available/example.com.conf /ect/nginx/sites-enabled/example.com.conf
4.重新加载Nginx使配置生效
systemctl reload nginx.service
5.浏览器访问验证
example.com

Thanks:
https://www.myfreax.com/how-to-install-nginx-on-ubuntu-20-04/

评论

此博客中的热门博文

[QV2ray]源码解读

 main.cpp SIGTERM termination request, sent to the program SIGSEGV invalid memory access (segmentation fault) SIGINT external interrupt, usually initiated by the user SIGILL invalid program image, such as invalid instruction SIGABRT abnormal termination condition, as is e.g. initiated by   abort() SIGFPE erroneous arithmetic operation such as divide by zero https://en.cppreference.com/w/c/program/SIG_types 2.Application QVBASEAPPLICATION( SingleApplication ) -Qv2rayPlatformApplication -- Qv2rayWidgetApplication -- Qv2rayQMLApplication -- Qv2rayCliApplication

SSH基本使用

1.创建ssh公钥和私钥 ssh-keygen -t rsa -C [your_mail] 2.打开 公钥id_rsa.pub 复制全部内容到 VPS 3.测试是否连通 ssh -T [VPS地址] 4.保存到keychain,实现永久保存 ssh-add -K ~/.ssh/id_rsa