時(shí)間:2023-07-16 00:48:01 | 來源:網(wǎng)站運(yùn)營
時(shí)間:2023-07-16 00:48:01 來源:網(wǎng)站運(yùn)營
Centos8 Yum安裝nginx并設(shè)置虛擬主機(jī):nginx是最近非?;鸬膚eb服務(wù)器,這次CentOS8也在yum官方源中新增了nginx 1.14dnf install nginx -y
如果出錯(cuò)檢查檢查一下網(wǎng)絡(luò)和yum源,如何更換yum源到阿里源vim /etc/nginx/nginx.conf
可以看到里面有個(gè)默認(rèn)網(wǎng)站,不用管它,在紅色箭頭處插入兩個(gè)網(wǎng)站的配置server { listen 80; listen [::]:80; access_log /usr/share/nginx/log/game.shaochenfeng.com; error_log /usr/share/nginx/log/game.shaochenfeng.com.err error; server_name game.shaochenfeng.com; root /usr/share/nginx/game.shaochenfeng.com; location / { } }server { listen 80; listen [::]:80; access_log /usr/share/nginx/log/map.shaochenfeng.com; error_log /usr/share/nginx/log/map.shaochenfeng.com.err error; server_name map.shaochenfeng.com; root /usr/share/nginx/map.shaochenfeng.com; location / { } }
保存并退出 下面創(chuàng)建虛擬主機(jī)的主目錄和日志目錄mkdir /usr/share/nginx/game.shaochenfeng.com # 創(chuàng)建虛擬主機(jī)的主目錄和日志目錄mkdir /usr/share/nginx/map.shaochenfeng.com#將你的網(wǎng)站文件復(fù)制到上面對(duì)應(yīng)的目錄mkdir /usr/share/nginx/logchown nginx:nginx -R /usr/share/nginx/game.shaochenfeng.com # nginx運(yùn)行在nginx用戶下,所以要給網(wǎng)站文件授予權(quán)限chown nginx:nginx -R /usr/share/nginx/map.shaochenfeng.com
啟動(dòng)并開機(jī)啟動(dòng)nginxsystemctl enable nginx # 設(shè)置nginx開機(jī)啟動(dòng)systemctl start nginx # 啟動(dòng)nginxsystemctl status nginx # 查看nginx狀態(tài)
這樣, 當(dāng)訪問http://game.shaochenfeng.com時(shí)就會(huì)得到/usr/share/nginx/http://game.shaochenfeng.com/index.html 當(dāng)訪問http://map.shaochenfeng.com時(shí)就會(huì)得到/usr/share/nginx/http://map.shaochenfeng.com/index.html關(guān)鍵詞:設(shè)置,虛擬,主機(jī),安裝
客戶&案例
營銷資訊
關(guān)于我們
微信公眾號(hào)
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。