1、配置域名并映射IP

sudo gedit /etc/hosts#在最后添加一行
172.0.0.1 localhost

--------------------------------------------------------------------" />

国产成人精品无码青草_亚洲国产美女精品久久久久∴_欧美人与鲁交大毛片免费_国产果冻豆传媒麻婆精东

15158846557 在線咨詢 在線咨詢
15158846557 在線咨詢
所在位置: 首頁 > 營銷資訊 > 網(wǎng)站運(yùn)營 > Ubuntu nginx 配置虛擬主機(jī)

Ubuntu nginx 配置虛擬主機(jī)

時(shí)間:2023-05-19 00:03:01 | 來源:網(wǎng)站運(yùn)營

時(shí)間:2023-05-19 00:03:01 來源:網(wǎng)站運(yùn)營

Ubuntu nginx 配置虛擬主機(jī):Ubuntu 20.10 Nginx1.18

1、配置域名并映射IP

sudo gedit /etc/hosts#在最后添加一行
172.0.0.1 localhost

---------------------------------------------------------------------------------------------------------------------

2、配置虛擬主機(jī)

在/etc/nginx/sites-available/ 目錄下,創(chuàng)建 server 虛擬主機(jī)配置文件localhost【文件名】

sudo gedit /etc/nginx/sites-available/localhost直接復(fù)制下面代碼到配置文件中

# server 配置server { listen 80; listen [::]:80; #域名(虛擬主機(jī)的訪問地址) server_name localhost; #項(xiàng)目主入口文件路徑 root /home/[your name]/localhost/public; #查找默認(rèn)入口的先后順序 index index.php index.html index.htm; location / { try_files $uri $uri/ =404; }}創(chuàng)建一個(gè)軟鏈接到 /etc/nginx/sites-enabled/ 目錄下,使配置文件生效

sudo ln -s /etc/nginx/sites-available/localhost /etc/nginx/sites-enabled/注意:
這里 localhost 【文件名】為項(xiàng)目根目錄,主頁文件好像不能直接放在根目錄下,所以需要在根目錄下新建一個(gè)子目錄把主頁文件放進(jìn)去

---------------------------------------------------------------------------------------------------------------------

3、重啟nginx

sudo service nginx restart

關(guān)鍵詞:主機(jī),虛擬,配置

74
73
25
news

版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。

為了最佳展示效果,本站不支持IE9及以下版本的瀏覽器,建議您使用谷歌Chrome瀏覽器。 點(diǎn)擊下載Chrome瀏覽器
關(guān)閉