- List item
eg:配置一个tp5.com 的域名
1.`执行下面的命令
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/tp5.com
sudo vim /etc/nginx/sites-available/tp5.com
2.删除tp5.com 里面原来的内容,使用100dd
server {
listen 80;
server_name tp5.com;
root /var/www/html/tp5/public;
index index.html index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
}
sudo ln -s /etc/nginx/sites-available/tp5.com /etc/nginx/sites-enabled/tp5.com
3.重启nginx
sudo systemctl restart nginx.service
4.配置hosts
sudo vim /etc/hosts
- 在hosts下面加入
127.0.0.1 tp5.com