nginx-1.11.10 在Linux伺服器下的安裝完整步驟
基於Linux伺服器下nginx原始碼的安裝配置流程
1、下載原始碼
下載完以後上傳到伺服器
或者伺服器可以上外網的話直接用下面的命令下載
wget http://nginx.org/download/nginx-1.11.10.tar.gz
2、解壓
tar -zxvf nginx-1.11.10.tar.gz
3、進入解壓縮後的目錄執行配置檔案檔案
[[email protected] ~]# cd nginx-1.11.10
[[email protected] nginx-1.11.10]# ./configure
注意此時一些編譯包未安裝的話可能出現以下報錯
./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.
4、安裝必要的依賴包
一般編譯nginx的 話需要安裝以下的包,也可根據報錯資訊來安裝
gcc,openssl,openssl-devel,zlib,pcre-devel,pcre,使用yum安裝這些包,這裡以pcre-devel 為例
[[email protected] nginx-1.11.10]# yum install pcre-devel 已載入外掛:refresh-packagekit, security, ulninfo 設定安裝程序 解決依賴關係 --> 執行事務檢查 ---> Package pcre-devel.x86_64 0:7.8-7.el6 will be 安裝 --> 完成依賴關係計算 依賴關係解決 ================================================================================ 軟體包 架構 版本 倉庫 大小 ================================================================================ 正在安裝: pcre-devel x86_64 7.8-7.el6 base 320 k 事務概要 ================================================================================ Install 1 Package(s) 總下載量:320 k Installed size: 957 k 確定嗎?[y/N]:y 下載軟體包: pcre-devel-7.8-7.el6.x86_64.rpm | 320 kB 00:00 warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Retrieving key from http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 Importing GPG key 0xC105B9DE: Userid: "CentOS-6 Key (CentOS 6 Official Signing Key) <
[email protected]>" From : http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 確定嗎?[y/N]:y 執行 rpm_check_debug 執行事務測試 事務測試成功 執行事務 正在安裝 : pcre-devel-7.8-7.el6.x86_64 1/1 Verifying : pcre-devel-7.8-7.el6.x86_64 1/1 已安裝: pcre-devel.x86_64 0:7.8-7.el6 完畢!
5、重新執行配置檔案
[[email protected] nginx-1.11.10]# ./configure
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
6、編譯原始檔
[[email protected] nginx-1.11.10]# make
7、安裝
[[email protected] nginx-1.11.10]# make install
8、檢查是否正常安裝
[[email protected] nginx-1.11.10]# whereis nginx
nginx: /usr/local/nginx
9、啟動nginx
[[email protected] nginx-1.11.10]# /usr/local/nginx/sbin/nginx
[[email protected] nginx-1.11.10]# ps -ef|grep -i nginx
root 4503 1 0 16:22 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 4504 4503 0 16:22 ? 00:00:00 nginx: worker process
root 4509 5266 0 16:23 pts/1 00:00:00 grep -i nginx
10、如果作為伺服器一般是開機啟動,需要作如下操作將nginx註冊為系統任務
[[email protected] nginx-1.11.10]# vim /etc/init.d/nginx
指令碼如下
#!/bin/sh
#
# 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: /usr/local/nginx/conf/nginx.conf
# pidfile: /var/run/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 3
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
11、配置自動啟動
[[email protected] nginx-1.11.10]# chkconfig --add nginx
[[email protected] nginx-1.11.10]# chkconfig --list nginx
nginx 0:關閉 1:關閉 2:關閉 3:關閉 4:關閉 5:關閉 6:關閉
[[email protected] nginx-1.11.10]# chkconfig --level 2345 nginx on
[[email protected] nginx-1.11.10]# chkconfig --list nginx
nginx 0:關閉 1:關閉 2:啟用 3:啟用 4:啟用 5:啟用 6:關閉
至此在linux下的nginx 完全安裝完畢,如果不想註冊為系統服務,10-11可忽略。
在ubantu下比較方便 apt-get nginx即可
相關推薦
nginx-1.11.10 在Linux伺服器下的安裝完整步驟
基於Linux伺服器下nginx原始碼的安裝配置流程 1、下載原始碼 下載完以後上傳到伺服器 或者伺服器可以上外網的話直接用下面的命令下載 wget http://nginx.org/download/nginx-1.11.10.tar.gz 2、解壓 tar -zxv
Centos6.7安裝nginx-1.11.10
centos nginx yum grouplist #查看已經安裝的組Installed Groups: #已經安裝的組Available Groups: #可以安裝的組同步系統時間編譯安裝nginx安裝#yum -y groupinstall "Development Tools" "Se
centos 7 安裝 nginx-1.11.10(騰訊雲)
解決 AC .gz direct 輸入密碼 blank elf not run 騰訊雲 在centos 7 下安裝 nginx-1.11 前需要先切換到root環境,通過命令 su root 切換,然後再輸入密碼, 如果不能切換需要把下載的nginx文件夾給予777的權限
Linux伺服器下安裝配置SVN並設定開機啟動
下面以CentOS7.5為例介紹SVN的安裝步驟。 一、安裝svn伺服器 在Linux中安裝服務端 yum install subversion 二、配置SVN伺服器 1、新建一個版本倉庫(名字可以任意取) mkdir /svn svnadmin create /svn/pr
阿里雲linux伺服器下安裝Apache的簡單方法
隨著阿里雲主機的火熱推出,很多的站長朋友,也開始使用阿里雲伺服器了。 php程式,大多還是要跑在linux系統的主機上的。 今天,介紹下在阿里雲的linux主機上安裝apache的方法。 雲伺服器作業系統:CentOS 6.2 64位 客戶端操作環境:Mac OSX T
一篇不大靠譜的nginx 1.11.10配置檔案
前言 網站是前後端分離,前端打包站點部署需要自力更生,為了避免跨域問題. 選擇了nginx這個知名的反向代理伺服器. 這裡不探究安裝這種問題。。。 版本 : nginx-1.11.10 配置檔案(nginx.conf) #use
Linux伺服器下安裝TensorFlow
簡單介紹在Linux伺服器的個人目錄下安裝TensorFlow。TensorFlow的安裝方式有多種,基於Pip的安裝、基於Docker的安裝、基於VirtualEnv的安裝、基於Anaconda的安裝,以及從原始碼編譯安裝,這些在官網均有介紹,這裡簡單
Linux相關:linux伺服器下安裝MySQL 及 首次登陸密碼錯誤重置root密碼
本教程指標MySQL5.7.17版本安裝,其他版本存在差異,未必使用一、 下載mysql5.7我個人下載安裝的是5.7.17版本64位。可以到上面網站下載,或線上下載,輸入命令:wget http://mirrors.sohu.com/mysql/MySQL-5.7
linux環境下安裝ngnix步驟(很詳細)
安裝準備開始前,請確認gcc g++開發類庫是否裝好,預設已經安裝。ububtu平臺編譯環境可以使用以下指令apt-get install build-essentialapt-get install libtoolcentos平臺編譯環境使用如下指令 安裝make:yum
Linux 系統下安裝python3步驟
CentOS安裝Python3k步驟: 1. 安裝GCC及依賴庫:yum -y install gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel
linux伺服器下非root許可權安裝anaconda(以Anaconda3-5.0.1-Linux-x86_64.sh為例)
1.找到自己需要的anaconda版本並下載下來(可以用迅雷下載~速度還快點~),上傳到伺服器自己目錄下; 下載地址:https://repo.anaconda.com/archive/ 2.cd到anaconda安裝包目錄下,安裝anaconda: # bash Anaconda3-5
linux環境下安裝nginx步驟
borde test nginx重啟 images roo g++ .tar.gz org syn 開始前,請確認gcc g++開發類庫是否裝好,默認已經安裝。 ububtu平臺編譯環境可以使用以下指令 apt-get install build-essential
【linux】linux 環境下 安裝禪道(轉載) -- 跟web服務器無關,無視apache、nginx!!!
sdn php 修改 鏈接 net 壓縮 操作 tps 數據庫 參考文章 鏈接 :https://blog.csdn.net/xinxin19881112/article/details/46813991 講的非常完美、透徹,不像其他的文章,都是抄襲的,沒一點註意事項和自己
Redis(1)-----初識Redis-----windows,linux系統下安裝Redis及其視覺化工具RedisDesktopManager配置
一,windows系統 1.1,安裝 要安裝Redis,首先要獲取安裝包。 Windows的Redis安裝包需要到以下GitHub連結找到。 連結:https://github.com/MSOpenTech/redis 開啟網站後,找到Release,點選前往下載頁面。  
Linux CentOS7下安裝Zookeeper-3.4.10服務(最新)
pre exp 路徑 datadir detail count 3.4 repr 數據文件 Linux CentOS7下安裝Zookeeper-3.4.10服務(最新) 2017年10月27日 01:25:26 極速-蝸牛 閱讀數:1933 版權聲明:
【技術向】Linux伺服器下Matlab無許可權安裝指南
文章目錄 1.安裝前的準備 1.1原料下載: 1.2解壓 1.3配置Java 2.安裝 我在網路上看了一些部落格,覺得有的介紹有點多餘且版本過老不適用,現根據我的經驗分享一下安裝流
Linux系統下安裝solr搜尋伺服器和訪問不了solr首頁問題
第一步:安裝linux、jdk、tomcat。 jdk安裝步驟詳細見 安裝jdk [[email protected] ~]# ll total 8044 -rw-r--r--. 1 root root 8234674 Oct 27 2013 apac
Django uwsgi nginx tar.gz 方法 Linux 伺服器安裝
第一步:Django 安裝 Django官方下載連結 ①pip安裝可用,則直接 pip install django==Version(對應版本號) ②下載對應版本tar包,copy到伺服器,解壓後進入解壓目錄執行如下命令: python setup.py install 第
Linux CentOs 下 安裝 mysql nginx redis
SCP 的使用 來源於: https://blog.csdn.net/qq_30968657/article/details/72912070 scp [引數] <源地址(使用者名稱@IP地址或主機名)>:<檔案路徑> <目的地址(使用者名稱 @IP 地址或主機名)>:
linux環境下安裝Nginx
準備: 本文使用的安裝包: nginx是C語言開發,建議在linux上執行,本教程使用Centos6.5作為安裝環境。 yum方法安裝的,可以用 yum list installed 查詢,如果是查詢指定包,用 yum list installe