nginx安裝

nginx安裝

我是在ubuntu上安裝的
首先解壓
tar -vxf nginx-1.3.1.tar.gz
然後進入解壓後的文件夾
cd nginx-1.3.1/

然後執行./configure 命令生成makefile文件
此時可能會報如下的錯誤
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
這是由於沒有安裝pcre庫造成的,然後執行以下命令安裝pcre庫

先更新一下源
sudo apt-get update              
然後安裝pcre庫
apt-get install libpcre3 libpcre3-dev

然後再執行./configure命令時可能會報錯說沒有安裝zlib庫,此時我們執行以下命令進行安裝
apt-get install zlib1g-dev

然後執行./configure命令就能成功生成makefile文件了
然後編譯
make
再安裝
make install

安裝完成後進入安裝的文件夾,默認的安裝文件夾是/usr/local/nginx/sbin
cd /usr/local/nginx/sbin
然後以管理員權限運行,然後就可以在瀏覽器中輸入你的機器的ip,就會訪問nginx的歡迎界面
sudo ./nginx
我是在虛擬機中安裝的,然後用ifconfig命令查看一下虛擬機的IP,然後直接在主機的瀏覽器中輸入虛擬機的IP就可以訪問nginx的歡迎界面,當然在虛擬機中也能訪問
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章