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

首頁 > 系統 > Linux > 正文

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

2024-08-27 23:55:37
字體:
來源:轉載
供稿:網友
  一朋友買了一臺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 目錄下面
 
  1) 解壓 nginx
 
  執行#tar -zxvf nginx-1.4.7.tar.gz 解壓 nginx 后 /home 下面會有nginx-1.4.7 文件夾
 
  2 配置nginx
 
  執行#cd nginx-1.4.7
 
  執行#./configure –prefix=/usr/local/nginx –with-http_stub_status_module
 
  ///–prefix=/usr/local/nginx是指定nginx的安裝路徑
 
  其中參數 –with-http_stub_status_module 是為了啟用 nginx 的 NginxStatus 功能,用來監控 Nginx 的當前狀態.
 
  3)make
 
  在linux 中執行#make
 
  4)安裝
 
  在linux 中執行#make install
 
  5) 檢查是否安裝成功
 
  執行#cd /usr/local/nginx/sbin
 
  執行#./nginx -t
 
  結果顯示:
 
  nginx:the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
 
  nginx:configuration file /usr/local/nginx/conf/nginx.conf test is successful
 
  安裝成功
 
  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:編輯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;
  }
  }
  方法二:和第一個中配置是一樣的原理,只是為了更好的管理多個站點,很多個站點建議用第二中配置方法.
 
  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.

(編輯:武林網)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 永顺县| 桂平市| 芦溪县| 台山市| 宁津县| 房产| 青阳县| 仁化县| 三门峡市| 宿松县| 察隅县| 柳江县| 蛟河市| 五寨县| 边坝县| 迁西县| 治多县| 彭山县| 鞍山市| 新乡县| 甘德县| 惠安县| 岳池县| 苏尼特右旗| 斗六市| 通州市| 西乌珠穆沁旗| 平顶山市| 葫芦岛市| 福州市| 临武县| 若羌县| 靖州| 延川县| 连云港市| 波密县| 翁源县| 宁德市| 厦门市| 尼玛县| 丰城市|