国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

阿里云linux服務器中配置安裝nginx

2024-08-27 23:55:29
字體:
來源:轉載
供稿:網友
  一朋友買了一臺linux的阿里云機器了,但是不知道怎么安裝配置WEB環境了,下面我就來給各位介紹一下在阿里云linux中配置nginx環境的方法,希望例子能給各位帶來幫助
 
  1.首先下載pcre-8.32.tar.gz和nginx-1.4.7.tar.gz最新穩定版本
 
  2.安裝 pcre 讓nginx支持rewrite
 
  pcre-8.32.tar.gz 上傳到/home 目錄下面
 
  1) 解壓 pcre
 
  執行#tar -zxvf pcre-8.32.tar.gz 解壓 pcre 后 /home 下面會有 pcre-8.32 文件夾
 
  2)配置pcre
 
  執行#cd /home/pcre-8.32
 
  執行#./configure 檢查當前的環境是否滿足要安裝軟件的依賴關系,如果出現錯誤checking for a BSD-compatible install… /usr/bin/install -c
 
  執行#yum install gcc gcc-c++
 
  3)make 自動完成編譯工作
 
  4)安裝
 
  在linux 中輸入 make install 正式安裝
 
  3.安裝 nginx
 
  nginx-1.4.7.tar.gz 上傳到/home 目錄下面
 
  
  安裝成功
 
  6)啟動nginx
 
  執行#cd /usr/local/nginx/sbin 目錄下面 執行#./nginx 啟動 nginx
 
  7 )檢查是否啟動成功
 
  ie 瀏覽器中輸入服務器ip 例如http://115.124.22.59
 
  安裝過程中出現的錯誤:1沒有安裝 zlib-devel,提示錯誤 the HTTP gzip module requires the zlib library.
 
  解決:執行#yum install -y zlib-devel
 
  2出現lib文件找不到,原因是創建的lib文件和nginx查找的文件名不統一導致
 
  錯誤./nginx: error while loading shared libraries:
 
  libpcre.so.1: cannot open shared object file: No such file or directory
 
  解決:/lib或是/lib64找到 libpcre.so.0.0.1 執行 ln -s libpcre.so.0.0.1 libpcre.so.1
 
  阿里云linux服務器配置nginx
 
  1,配置站點
 
  打開配置文件目錄找到nginx.conf:執行#cd /usr/local/nginx/conf ,編輯nginx.conf:執行#vi nginx.conf ,找到如下配置:
 
  server {  
  listen 80;  
  server_name localhost; //把 localhost改成你的域名 例如www.qiyedun.com qiyedun.com  
  #charset koi8-r;  
  #access_log logs/host.access.log main;  
  location / {  
  root /mnt/wordpress; //root跟著路徑就是你項目的放置路徑,千萬別搞錯了。  
  index index.php index.html index.htm; //index跟著默認首頁,添加多個nginx會挨個查找,直到找到對應的。  
  }
  2,配置多站點

  方法1:和第一個中配置是一樣的原理,只是為了更好的管理多個站點,很多個站點建議用第二中配置方法.
 
  nginx的默認安裝路徑為/usr/local/nginx
 
  打開nginx文件夾下的配置文件夾 執行#cd /usr/local/nginx/conf
 
  查看conf文件夾下的文件 執行#ll //ll是LL的小寫 ,不是123的1不要搞錯了
 
  編輯nginx.conf 執行#vi nginx.conf //在http{}里面最下端添加include /usr/local/nginx/conf/vhosts/*.conf;
 
  打開 /usr/local/nginx/conf 執行#cd /usr/local/nginx/conf
 
  創建vhosts文件夾 執行#mkdir vhosts
 
  例如你有第二站點域名為www.phpfensi.com
 
  進入vhost 執行#cd /usr/local/nginx/conf/vhosts
 
  創建配置文件 執行#vi qiyedun.conf
 
  拷貝如下代碼:
 
  server {  
  listen 80;  
  server_name second.qiyedun.com; //第N個站點的域名,也可以是二級域名,例如:second.qiyedun.com  
  #charset koi8-r;  
  #access_log logs/host.access.log main;  
  location / {  
  root /mnt/wordpress; // 第N個站點站點的文件存放位置  
  index index.html index.htm;  
  }  
  #error_page 404 /404.html;  
  # redirect server error pages to the static page /50x.html  
  #  
  error_page 500 502 503 504 /50x.html;  
  location = /50x.html {  
  root html;  
  }  
  }  
  保存qiyedun.conf,重啟nginx 執行#/usr/local/nginx/sbin/nginx -s reload.

  方法2:編輯vi nginx.conf
 
  找到server 拷貝一份放到http{}里面;也可以復制我如下代碼放到http{}里面.
 
  server {
  listen 80;
  server_name second.phpfensi.com; //第N個站點的域名,也可以是二級域名,例如:second.qiyedun.com
  #charset koi8-r;
  #access_log logs/host.access.log main;
  location / {
  root /mnt/wordpress; // 第N個站點站點的文件存放位置
  index index.html index.htm;
  }  --phpfensi.com
  #error_page 404 /404.html;
  # redirect server error pages to the static page /50x.html
  #
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
  root html;
  }
  }。

(編輯:武林網)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 比如县| 宜宾市| 阳春市| 广灵县| 厦门市| 开阳县| 高州市| 无锡市| 泌阳县| 西乌珠穆沁旗| 泰顺县| 庆阳市| 乐至县| 南丰县| 绥滨县| 郎溪县| 湟源县| 望谟县| 大埔县| 桐乡市| 广东省| 长治市| 长丰县| 大兴区| 周宁县| 惠州市| 靖西县| 宽城| 岳阳县| 昭苏县| 和政县| 亚东县| 车险| 大荔县| 海丰县| 景东| 义乌市| 定安县| 阳东县| 靖州| 定襄县|