六、nginx入门-Nginx虚拟主机配置文件
1.介绍配置文件
vim /etc/nginx/conf.d/default.conf
——————————————————————
server {
listen 80; 监听端口
server_name localhost; 域名
#charset koi8-r; 默认字符集
#access_log /var/log/nginx/host.access.log main; 网站日志位置
location / { 位置 访问主页是根/
root /usr/share/nginx/html; root放的是默认网站
index index.html index.htm;
}
}
———————————————————
2.启动一个新的虚拟主机
vim /etc/nginx/conf.d/ghz.conf
————————
server {
listen 80;
server_name ghz.com;
location / {
root /ghz;
index index.html;
}
}
————————
mkdir /ghz
echo "欢迎来到ghz" > /ghz/lindex.html
systemctl restart nginx
vim /etc/hosts
——————————
192.168.56.132 ghz.com
——————————
ping ghz.com
elinks http://ghz.com