日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux pcre静态编译,Linux下,Nginx部署静态网站

發布時間:2025/3/11 linux 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux pcre静态编译,Linux下,Nginx部署静态网站 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、準備工作

選首先安裝這幾個軟件:GCC,PCRE(Perl Compatible Regular Expression),zlib,OpenSSL。

Nginx是C寫的,需要用GCC編譯;Nginx的Rewrite和HTTP模塊會用到PCRE;Nginx中的Gzip用到zlib;

用命令“# gcc”,查看gcc是否安裝;如果出現“gcc: no input files”信息,說明已經安裝好了。

否則,就需要用命令“# yum install gcc”,進行安裝了!一路可能需要多次輸入y,進行確認。

安裝好后,可以再用命令“#gcc”測試,或者用命令“# gcc -v”查看其版本號。

同樣方法,用如下命令安裝PCRE,zlib,OpenSSL(其中devel,是develop開發包的意思)。

# yum install -y pcre pcre-devel

# yum install -y zlib zlib-devel

# yum install -y openssl openssl-devel

2、下載并安裝

創建目錄(nginx-src)并進去;然后,從官方地址(http://nginx.org/) 下載,解壓,配置,編譯,安裝:

# mkdir nginx-src && cd nginx-src

# wget http://nginx.org/download/nginx-1.10.3.tar.gz

# tar xzf nginx-1.10.3.tar.gz

# cd nginx-1.10.3

# ./configure

# make

# make install

# whereis nginx

nginx: /usr/local/nginx

默認的安裝路徑為:/usr/local/nginx;跳轉到其目錄下sbin路徑下,便可以啟動或停止它了。

# ./nginx -h

nginx version: nginx/1.10.3

Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:

-?,-h : this help

-v : show version and exit

-V : show version and configure options then exit

-t : test configuration and exit

-q : suppress non-error messages during configuration testing

-s signal : send signal to a master process: stop, quit, reopen, reload

-p prefix : set prefix path (default: /usr/local/nginx/)

-c filename : set configuration file (default: conf/nginx.conf)

-g directives : set global directives out of configuration file

啟動:nginx

停止:nginx -s stop

3、添加到系統服務

使用命令“# vi /etc/init.d/nginx”,打開編輯器,輸入如下內容:

#!/bin/sh

# chkconfig: 2345 85 15

# Startup script for the nginx Web Server

# description: nginx is a World Wide Web server.

# It is used to serve HTML files and CGI.

# processname: nginx

# pidfile: /usr/local/nginx/logs/nginx.pid

# config: /usr/local/nginx/conf/nginx.conf

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

DESC="nginx deamon"

NAME=nginx

DAEMON=/usr/local/nginx/sbin/$NAME

SCRIPTNAME=/etc/init.d/$NAME

test -x $DAEMON || exit 0

d_start(){

$DAEMON || echo -n "already running"

}

d_stop(){

$DAEMON -s quit || echo -n "not running"

}

d_reload(){

$DAEMON -s reload || echo -n "can not reload"

}

case "$1" in

start)

echo -n "Starting $DESC: $NAME"

d_start

echo "."

;;

stop)

echo -n "Stopping $DESC: $NAME"

d_stop

echo "."

;;

reload)

echo -n "Reloading $DESC conf..."

d_reload

echo "reload ."

;;

restart)

echo -n "Restarting $DESC: $NAME"

d_stop

sleep 2

d_start

echo "."

;;

*)

echo "Usage: $ScRIPTNAME {start|stop|reload|restart}" >&2

exit 3

;;

esac

exit 0

保存退出后,再使用下面的命令,使其可執行;然后,添加配置并查看。

可用chkconfig修改其值,也可用ntsysv工具改變是否自啟動。

# chmod +x /etc/init.d/nginx

# chkconfig --add nginx

# chkconfig nginx on/off

# chkconfig --list nginx

nginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off

4、部署靜態網站

將靜態網站文件上傳至/usr/local/nginx/html 目錄下,通過域名訪問即可。

總結

以上是生活随笔為你收集整理的linux pcre静态编译,Linux下,Nginx部署静态网站的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。