麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 系統 > Ubuntu > 正文

Ubuntu下如何安裝nginx

2020-02-24 16:07:47
字體:
來源:轉載
供稿:網友

nginx是高性能的HTTP和反向代理web服務器,可以為我們提供很方便的服務,那么你知道在Ubuntu下如何安裝nginx嗎?如果你還不了解的話就跟隨武林小編一起去看看吧。

1)、下載
  sudo wget http://nginx.org/download/nginx-1.2.2.tar.gz

2)、解壓
  sudo tar -xzvf nginx-1.2.2.tar.gz

3)、進入相關目錄進行以下操作
?

復制代碼
代碼如下:

./configure
make
sudo make install  


如果你運氣好的話,一切ok,不過...........哈哈。Ubuntu默認的策略是什么庫都不裝,依賴的庫都需要自已手工安裝搞定。 一般都會出錯的,那么我們來看看可能出現的問題。

4)、常見問題解決辦法
  缺少pcre library
./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-8.31解決問題,解壓后對pcre進行如下操作

?

?

復制代碼
代碼如下:

?

?


sudo wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz
sudo tar -xzvf pcre-8.31.tar.gz
cd /usr/local/src/pcre-8.31
./configure
make
sudo make install  


運氣好一次通過,運氣不好,make pcre時會出錯
缺少gcc-c++和libtool,也就是c++編譯包

?

?

復制代碼
代碼如下:

?

?


libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
libtool: compile: Try `libtool --help' for more information.
make[1]: *** [pcrecpp.lo] Error 1
make[1]: Leaving directory `/usr/local/src//pcre-8.31'
make: *** [all] Error 2root@wolfdog-virtual-machine:~/work/pcre-8.12$ libtool -help -DHAVE_CONFIG_H
The program 'libtool' is currently not installed. You can install it by typing:
sudo apt-get install libtool


解決方法:需要先安裝libtool和gcc-c++
?sudo apt-get install libtool
sudo apt-get install gcc-c++
  大爺啊~~~這時候可能又會報錯啊,坑爹啊~~~
  缺少openssl庫

?

?

復制代碼
代碼如下:

?

?


./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.


缺少zlib庫

?

?

復制代碼
代碼如下:

?

?


./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.   


解決辦法:少什么就安裝什么唄。
sudo apt-get install openssl libssl-dev libperl-dev
4)、解決了以上問題,編譯nginx就沒啥問題了。下面安裝。(附加安裝插件的方法)
  先下載插件并解壓

?

?

復制代碼
代碼如下:

?

?


sudo wget https://github.com/agentzh/echo-nginx-module/tarball/v0.40rc1 -O echo-nginx-module.tar.gz
sudo wget https://nodeload.github.com/agentzh/memc-nginx-module/tarball/v0.13rc3 -O memc-nginx-module.tar.gz
sudo tar -xzvf echo-nginx-module.tar.gz
sudo tar -xzvf memc-nginx-module.tar.gz  


進入nginx目錄cd nginx-1.2.2/,執行以下命令

?

?

復制代碼
代碼如下:

?

?


./configure --user=www-data --group=www-data --with-debug --with-http_gzip_static_module --with-http_ssl_module --with-pcre=../pcre-8.31/ --with-http_perl_module --with-perl=/usr/bin/perl --with-http_stub_status_module --with-http_realip_module /
--prefix=/usr/local/nginx /
--add-module=../agentzh-echo-nginx-module-9259898/ /
--add-module=../agentzh-memc-nginx-module-4007350/ /
注:前面一段是一些編譯參數,后面add-module是添加模塊
make -j2
make install


大爺的,又可能報錯。沒有nginx,logs目錄訪問權限

?

?

復制代碼
代碼如下:

?

?


[alert]: could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)
2011/03/21 06:09:33 [emerg] 24855#0: mkdir() "/usr/local/nginx/client_body_temp" failed (13: Permission denied)   


解決辦法:

?

?

復制代碼
代碼如下:

?

?


sudo chmod a+rwx -R logs
sudo chmod a+rwx -R /usr/local/nginx   


現在,差不多沒問題了。
可以進入/usr/local/nginx/sbin/執行以下命令看是否成功:
  nginx -v
5)、nginx自啟動
編輯啟動腳本:

?

?

復制代碼
代碼如下:

?

?


sudo vim /etc/init.d/nginx

?

?

復制代碼
代碼如下:

?

?


#! /bin/bash
#
# nginx Start up the nginx server daemon
#
# chkconfig: 2345 55 25
# Description: starts and stops the nginx web server
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: starts and stops the nginx web server
### END INIT INFO
# To install:
# copy this file to /etc/init.d/nginx
# shell> chkconfig --add nginx (RedHat)
# shell> update-rc.d -f nginx defaults (debian)
# To uninstall:
# shell> chkconfig --del nginx (RedHat)
# shell> update-rc.d -f nginx remove
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/$NAME.conf
PIDFILE=/var/local/nginx/logs/$NAME.pid
ULIMIT=10240
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
echo "Starting $NAME ..."
ulimit -SHn $ULIMIT
$DAEMON -c $CONFIGFILE
}
do_stop() {
echo "Shutting down $NAME ..."
kill 'cat $PIDFILE'
}
do_reload() {
echo "Reloading $NAME ..."
kill -HUP 'cat $PIDFILE'
}
case "$1" in
start)
[ ! -f "$PIDFILE" ] && do_start || echo "nginx already running"
echo -e "./ndone"
;;
stop)
[ -f "$PIDFILE" ] && do_stop || echo "nginx not running"
echo -e "./ndone"
;;
restart)
[ -f "$PIDFILE" ] && do_stop || echo "nginx not running"
do_start
echo -e "./ndone"
;;
reload)
[ -f "$PIDFILE" ] && do_reload || echo "nginx not running"
echo -e "./ndone"
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload}" >&2
exit 1
;;
esac
exit 0


紅色部分,根據自己的路徑修改。

6)、常用命令

重啟nginx:service nginx restart
啟動:service nginx start
關閉:service nginx stop

7)、linux常用命令
tar(z-用 gzip 對存檔壓縮或解壓;x-從存檔展開文件;v-詳細顯示處理的文件;f-指定存檔或設備)
tar –zxvf nginx-0.8.54.tar.gz

ip查看
ifconfig

編譯
make

安裝編譯好的源碼包
make install

編輯文件
sudo gedit /etc/profile

修改根限:chmod說明(u:與文件屬主擁有一樣的權限[a:所有人];+:增加權限;rwx:可讀可寫可執行)
-R:遞歸所有目錄和文件
sudo chmod a+rwx -R logs

檢查是庫是否安裝成功
dpkg --list|grep openssl

下載安裝庫
sudo apt-get install libtool

檢查服務啟動是否正常
ps -ef|grep

查找openssl安裝路徑
whereis openssl

更新源
sudo apt-get update

更新已安裝的包
sudo apt-get upgrade

上文中小編詳細介紹了Ubuntu下如何安裝nginx的內容,希望能對您有所幫助,小伙伴們有空可以來武林技術頻道,我們的網站上還有許多其它的資料等著小伙伴來挖掘哦!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 成人国产视频在线观看 | 久久久久夜色精品国产老牛91 | 在线成人精品视频 | 国产一级二级在线播放 | 99精品国产成人一区二区 | 蝌蚪久久窝 | 黄色影院一级片 | 亚洲不卡 | 天天透天天狠天天爱综合97 | 久久久资源网 | 日日摸夜夜添夜夜添牛牛 | 久久精品国产一区二区电影 | 亚洲第一成人在线观看 | 狠狠干网站 | 欧美高清第一页 | 免费在线观看毛片视频 | 久久久aa | 91懂色 | 97视频| 国av在线 | www中文在线 | av成人一区二区 | 久草在线资源观看 | 成人短视频在线观看 | 涩涩操 | 久久免费视频精品 | 天堂成人国产精品一区 | 成人在线视频播放 | 99激情| 成人免费在线视频播放 | 国产一级二级视频 | 成人一区久久 | 久在线草 | japanese javhd| 99国产精品国产免费观看 | 国产精品久久久久久久久久久久久久久 | 国产精品久久久久网站 | 2021狠狠操 | 亚洲无马在线观看 | 国产成人羞羞视频在线 | 色婷婷tv |