Linux下nginx的安裝

2021-10-10 07:33:34 字數 3012 閱讀 6452

.12.配置nginx安裝所需的環境

yum install gcc-c++

//安裝gcc

yum install -y pcre pcre-devel //安裝pcre pcre-devel

yum install -y zlib zlib-devel //安裝zlib

yum install -y openssl openssl-devel //安裝open ssl

3.解壓安裝
tar -zxvf nginx-

1.10

.1.tar.gz //解壓安裝包

./configure //使用預設配置

4.編譯安裝nginx
cd  /usr/local/nginx-

1.10

.1//進入nginx 目錄

make //執行

make install //安裝

cd .

.//回到local 目錄

cd nginx/

//進入nginx 目錄修改配置檔案即可

5.啟動nginx
cd  /usr/local/nginx/sbin   //進入sbin 目錄

./nginx //啟動nginx

./nginx -s reload //重啟nginx

6.配置nginx 服務

6.1 進入目錄

cd /etc/init.d/  

//建立nginx 指令碼

vim nginx

內容如下

#!/bin/sh

#chkconfig: 2345 85 15

# 2345 表示在2345模式下,開機自啟動

# ****** redis init.d script conceived to work on linux systems

# as it does use of the /proc filesystem.

# chkconfig: - 85 15

# description: nginx is a world wide web server. it is used to serve

nginxd=/usr/local/nginx/sbin/nginx

nginx_config=/usr/local/nginx/conf/nginx.conf

nginx_pid=/var/run/nginx.pid

retval=0

prog="nginx"

#source function library.

. /etc/rc.d/init.d/functions

# source networking configuration.

. /etc/sysconfig/network

# check that networking is up.

[ $ = "no" ] && exit 0

[ -x $nginxd ] || exit 0

# start nginx daemons functions.

start()

retval=$?

echo

[ $retval = 0 ] && touch /var/lock/subsys/nginx

return $retval

}# stop nginx daemons functions.

stop()

# reload nginx service functions.

reload() `

killproc $nginxd -hup

retval=$?

echo

}# see how we were called.

case "$1" in

start)

start

;;stop)

stop

;;reload)

reload

;;restart)

stop

start

;;status)

status $prog

retval=$?

;;*)

echo $"usage: $prog "

exit 1

esac

exit $retval

6.2給指令碼新增許可權
chmod a+x /etc/init.d/nginx
6.3將nginx加入到,開啟自啟動項
chkconfig --add nginx

chkconfig nginx on

6.4 可以試試 如果nginx.conf 配置檔案有問題 是無法啟動成功的
service nginx start     

service nginx stop

報錯解決:error: this statement may fall through [-werror=implicit-fallthrough=]
make cflags='-wno-implicit-fallthrough'
報錯解決 linux 安裝 nginx 『struct crypt_data』 has no member named 『current_salt』 解決辦法

安裝目錄下面

Linux下nginx的安裝

nginx engine x 是乙個高效能的http和反向 伺服器,是由俄羅斯人igor sysoev建立的專案,超輕量級,超快處理能力。目前使用的nginx版本是0.7.61 nginx的官言 為 http nginx.net 安裝pcre tar xzvf pcre 7.9.tar.gz cd ...

Linux下Nginx的安裝

nginx是目前比較通用的伺服器,由俄羅斯人開發,最大的特點就是負載均衡,平滑啟動。本篇部落格主要講解nginx的安裝。tar zxvf pcre 8.35.zip進行解壓縮,之後 輸入 cd pcre 8.35進入pcre安裝目錄,然後 configure make make install。這樣...

linux下nginx的安裝

1.1 編譯 每行引數後一定要跟乙個 分割開,否則會報錯 找不到檔案。出現以下資訊,表示編譯成功 編譯後,執行make make install 編譯過程中的注意事項 1.user dev group dev 此引數設定的是nginx的使用者和相應組,如果設定,必須要有相應的linux使用者和組,否...