當前位置:首頁 » 編程軟體 » ubuntu編譯nginx

ubuntu編譯nginx

發布時間: 2022-07-19 01:29:56

編譯安裝nginx和yum安裝nginx有什麼區別

如果真的要說區別的話,源碼編譯安裝可以在各個linux系統下使用,而yum安裝只能在redhat或centos系統使用,其它系統例如ubuntu,freebsd是不可用的。另外yum安裝的nginx版本偏低,而源碼包是可以獲取官方最新的發行版本的。

② ubuntu怎麼編譯nginx

解壓nginx的tar包,進入解壓後的文件夾里,如果要安裝到其他路徑的話,修改configure文件里的prefix的值然後執行./configure,或者直接使用./configure --prefix=/xx/xx/xxx來指定,安裝路徑然後make -j2,如果你的處理器核多,可以增大數字,再然後就是make & make install了。
要注意的是./configure後面可以跟隨很多參數配置:
比如,需要的話可以加上--config-path=/xx/xx/xxx/nginx.conf指定nginx的伺服器配置文件路徑;
--add-mole增加模塊,比如luz、pagespeed、upstream等等,這些都可以在官網上查到。

③ linux ubuntu13.10安裝nginx1.8.0需要哪些編譯環境

sudo//換到rootconfigure //對安裝的軟體進行配置--prefix=/usr/local/server/nginx //安裝目錄/usr/local/server/nginx--with-http_stub_status_mole啟用 nginx 的 NginxStatus 功能

④ ubuntu 16.04下怎樣安裝nginx

2種方法:
1,apt-get install nginx
2,網上下載nginx安裝包,然後編譯

⑤ ubuntu 編譯nginx的時候報錯,如何解決

先解壓nginx的tar包,進入解壓後的文件夾里,如果要安裝到其他路徑的話,修改configure文件里的prefix的值然後執行./configure,或者直接使用./configure --prefix=/xx/xx/xxx來指定,安裝路徑然後make -j2,如果你的處理器核多,可以增大數字

⑥ ubuntu怎麼安裝nginx

Nginx程序的穩定性來自於它採用了分階段的資源分配技術,使得CPU與內存佔用率會非常低,所以使用Nginx程序部署動態網站環境不僅十分的穩定、高效,而且消耗更少的系統資源,豐富的模塊功能也幾乎與Apache程序數量相同,現在已經完全的支持了proxy、rewrite、mod_fcgi、ssl、vhosts等常用模塊。而且還支持了熱部署技術,即能夠可以7*24不間斷提供服務,即便運行數月也無須重啟,而且還可以在不暫停服務的情況下直接對Nginx服務程序進行升級。
坦白來講,雖然Nginx程序的代碼質量非常高,代碼很規范,技術成熟,模塊擴展也很容易,但Nginx依然存在不少問題,比如Nginx是由俄羅斯人創建的,所以在資料文檔方面還並不完善,中文教材的質量更是魚龍混雜,但Nginx近年來增長勢頭迅猛,預測未來應該能夠在輕量級HTTP伺服器市場有不錯的未來。

安裝PCRE(Perl兼容的正則表達式庫,解壓與編譯過程已省略):
[root@linuxprobe ~]# cd /usr/local/src
[root@linuxprobe src]# mkdir /usr/local/pcre
[root@linuxprobe src]# tar xzvf pcre-8.35.tar.gz
[root@linuxprobe src]# cd pcre-8.35
[root@linuxprobe pcre-8.35]# ./configure --prefix=/usr/local/pcre
[root@linuxprobe pcre-8.35]# make
[root@linuxprobe pcre-8.35]# make install

安裝openssl服務程序(解壓與編譯過程已省略):
[root@linuxprobe pcre-8.35]# cd /usr/local/src
[root@linuxprobe src]# mkdir /usr/local/openssl
[root@linuxprobe src]# tar xzvf openssl-1.0.1h.tar.gz
[root@linuxprobe src]# cd openssl-1.0.1h
[root@linuxprobe openssl-1.0.1h]# ./config --prefix=/usr/local/openssl
[root@linuxprobe openssl-1.0.1h]# make
[root@linuxprobe openssl-1.0.1h]# make install

把openssl服務程序命令目錄添加到環境變數中(永久生效):
[root@linuxprobe pcre-8.35]# vim /etc/profile
//將配置文件最下面的參數追加參數為:
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/openssl/bin
[root@linuxprobe pcre-8.35]# source /etc/profile

安裝zlib數據壓縮函數庫(解壓與編譯過程已省略):
[root@linuxprobe pcre-8.35]# cd /usr/local/src
[root@linuxprobe src]# mkdir /usr/local/zlib
[root@linuxprobe src]# tar xzvf zlib-1.2.8.tar.gz
[root@linuxprobe src]# cd zlib-1.2.8
[root@linuxprobe zlib-1.2.8]# ./configure --prefix=/usr/local/zlib
[root@linuxprobe zlib-1.2.8]# make
[root@linuxprobe zlib-1.2.8]# make install

創建用於執行nginx服務的用戶:
[root@linuxprobe zlib-1.2.8]# cd ..
[root@linuxprobe src]# useradd www -s /sbin/nologin

安裝nginx服務程序(openssl,zlib,pcre要寫成源碼解壓路徑!!!):
[root@linuxprobe src]# tar xzvf nginx-1.6.0.tar.gz
[root@linuxprobe src]# cd nginx-1.6.0/
[root@linuxprobe nginx-1.6.0]# ./configure --prefix=/usr/local/nginx --without-http_memcached_mole --user=www --group=www --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35
[root@linuxprobe nginx-1.6.0]# make
[root@linuxprobe nginx-1.6.0]# make install

創建nginx程序腳本(將下面的參數直接復制進去即可):
[root@linuxprobe nginx-1.6.0]# vim /etc/rc.d/init.d/nginx
#!/bin/bash
# nginx - this script starts and stops the nginx daemon
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
if [ -z "`grep $user /etc/passwd`" ]; then
useradd -M -s /bin/nologin $user
fi
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
#configtest || return $?
stop
sleep 1
start
}
reload() {
#configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
[root@linuxprobe nginx-1.6.0]# chmod 755 /etc/rc.d/init.d/nginx

重啟nginx服務程序並添加到開機啟動項:
[root@linuxprobe nginx-1.6.0]# /etc/rc.d/init.d/nginx restart
Restarting nginx (via systemctl): [ OK ]
[root@linuxprobe nginx-1.6.0]# chkconfig nginx on

此時可以通過訪問IP來判斷nginx服務是否順利運行
我們一般通過部署Linux+Nginx+MYSQL+PHP這四種開源軟體,搭建一個免費、高效、擴展性強、資源消耗低的LNMP動態網站架構。關於這塊的安裝使用你可以看下http://www.linuxprobe.com/chapter-20.html#2022_Nginx

⑦ 在Ubuntu 里有沒有什麼命令確定 Nginx 配置文件位置

當你執行 nginx -t
得時候,nginx會去測試你得配置文件得語法,並告訴你配置文件是否寫得正確,同時也告訴了你配置文件得路徑:
# nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful

熱點內容
qq上傳視頻很慢怎麼辦 發布:2025-02-07 09:16:04 瀏覽:696
pythonredis緩存 發布:2025-02-07 09:10:24 瀏覽:927
封邊機主要看哪些配置 發布:2025-02-07 09:10:17 瀏覽:905
流控腳本破解 發布:2025-02-07 08:39:09 瀏覽:413
什麼是資源為什麼要研究資源配置 發布:2025-02-07 08:25:19 瀏覽:87
釣魚網站源碼製作 發布:2025-02-07 08:23:54 瀏覽:139
mac運行fl需要什麼配置 發布:2025-02-07 08:15:45 瀏覽:573
安卓怎麼做都比不了蘋果 發布:2025-02-07 08:12:47 瀏覽:238
怎麼給物理機配置ip地址 發布:2025-02-07 08:01:37 瀏覽:139
三國志13未加密 發布:2025-02-07 07:54:37 瀏覽:926