267

收藏
分類專欄: Nginx 文章標(biāo)簽: Nginx 域名 IP
版權(quán)

用兩個(gè)不同的域名綁定同一個(gè)ip訪問(wèn)兩個(gè)不同的項(xiàng)目是完全可以做到的,遠(yuǎn)沒(méi)有想象的那么復(fù)雜,使用服務(wù)器環(huán)境LNMP
要實(shí)現(xiàn)這個(gè)" />

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

18143453325 在線咨詢 在線咨詢
18143453325 在線咨詢
所在位置: 首頁(yè) > 營(yíng)銷資訊 > 建站知識(shí) > linux 同一個(gè)ip 綁定兩個(gè)不同的域名 訪問(wèn)兩個(gè)不同的項(xiàng)目

linux 同一個(gè)ip 綁定兩個(gè)不同的域名 訪問(wèn)兩個(gè)不同的項(xiàng)目

時(shí)間:2023-02-01 08:20:01 | 來(lái)源:建站知識(shí)

時(shí)間:2023-02-01 08:20:01 來(lái)源:建站知識(shí)



phubing 2020-01-08 11:52:17

267

收藏
分類專欄: Nginx 文章標(biāo)簽: Nginx 域名 IP
版權(quán)

用兩個(gè)不同的域名綁定同一個(gè)ip訪問(wèn)兩個(gè)不同的項(xiàng)目是完全可以做到的,遠(yuǎn)沒(méi)有想象的那么復(fù)雜,使用服務(wù)器環(huán)境LNMP
要實(shí)現(xiàn)這個(gè)功能首先需要配置nginx
打開(kāi)nginx的配置文檔(nginx.conf)



  1. server {

  2. listen 80;          //端口

  3. server_name www.xxxxx.com;      //域名

  4. access_log xxxxx;      //日志存儲(chǔ)的位置

  5. root xxxxx;  //項(xiàng)目根路徑

  6. index index.html index.htm index.php;

  7. fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;


  8. location / {

  9. try_files $uri $uri/ /index.php?$query_string;

  10. }


  11. location /nginx_status {

  12. stub_status on;

  13. access_log off;

  14. allow xxx.xxx.xx.xx;

  15. deny all;

  16. }

  17. location ~ [^/]/.php(/|$) {

  18. #fastcgi_pass remote_php_ip:9000;

  19. fastcgi_pass unix:/dev/shm/php-cgi.sock;

  20. fastcgi_index index.php;

  21. include fastcgi.conf;

  22. }

  23. location ~ .*/.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {

  24. expires 30d;

  25. access_log off;

  26. }

  27. location ~ .*/.(js|css)?$ {

  28. expires 7d;

  29. access_log off;

  30. }

  31. }

以上只是一個(gè)項(xiàng)目的配置,同樣的我們想同一個(gè)服務(wù)器打在兩個(gè)不同的項(xiàng)目那么所需要做的就是復(fù)制相同的一份代碼,指定不同的項(xiàng)目路徑



  1. server {

  2. listen 80;    //端口

  3. server_name www.xxxx.com;    //域名

  4. access_log /data/wwwlogs/access_nginx.log combined;

  5. root xxxxxxx;    //項(xiàng)目根路徑

  6. index index.html index.htm index.php;

  7. fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;


  8. location / {

  9. try_files $uri $uri/ /index.php?$query_string;

  10. }


  11. location /nginx_status {

  12. stub_status on;

  13. access_log off;

  14. allow 127.0.0.1;

  15. deny all;

  16. }

  17. location ~ [^/]/.php(/|$) {

  18. #fastcgi_pass remote_php_ip:9000;

  19. fastcgi_pass unix:/dev/shm/php-cgi.sock;

  20. fastcgi_index index.php;

  21. include fastcgi.conf;

  22. }

  23. location ~ .*/.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {

  24. expires 30d;

  25. access_log off;

  26. }

  27. location ~ .*/.(js|css)?$ {

  28. expires 7d;

  29. access_log off;

  30. }

  31. }

要想實(shí)現(xiàn)這個(gè)功能的中心就在于域名的不同和項(xiàng)目根路徑的不同

關(guān)鍵詞:訪問(wèn),項(xiàng)目,同一

74
73
25
news

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

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