2.解壓nginx-1.18.0.tar.gz 然後進入目錄,編譯。命令如下:yum install gcc gcc-c++ kernel-devel
yum -y install pcre-devel openssl openssl-devel
3.編譯成功後tar -zxvf nginx-1.18.0.tar.gz
cd nginx-1.18.0
./configure --prefix=/usr/local/nginx --with-http_stub_status_module
4.啟動nginxmake
&&make
install
5.加入系統變數/usr/local/nginx/sbin/nginx #啟動nginx
/usr/local/nginx/sbin/nginx -s stop #斷開nginx
/usr/local/nginx/sbin/nginx -s reload #重啟nginx
ps -ef |
grep nginx 或者 ps -a |
grep -i nginx #檢視是否成功啟動nginx
開啟/etc/profile
檔案
加入或修改pathsudo
vi /etc/profile
讓修改生效export path=
$path:/usr/local/nginx/sbin
source /etc/profile
啟動nginx
sudo nginx
停止nginx
sudo nginx -s stop
重啟nginx
sudo nginx -s reload
6.配置nginx多站點
進入/usr/local/nginx/conf
,將nginx.conf
複製乙份備用,然後修改
給nginx新增乙個配置檔案sites-enabled,方便以後我們添多站點;沒有的話可以自己建乙個然後再nginx.conf:
cd /usr/local/nginx/conf/
cp nginx.conf nginx.conf.bak
/usr/local/nginx/nginx.conf
中新增如下**引入配置,有的話可以忽略
include /usr/local/nginx/sites-enabled/*;
接下來開始配置多站點
新增如下**,每個意義看備註,多站點直接複製如下**重新貼上,然後修改sudo
vi /usr/local/nginx/sites-enabled/default
root
,server_name
重啟nginx即可
配置完成我們可以重啟server
location ~ \.php$
location ~ /\.ht
}
nginx
,讓配置生效:
sudo nginx -s reload
nginx安裝 Centos7安裝nginx
在安裝nginx前首先要確認系統中安裝了gcc pcre devel zlib devel openssl devel。yum y install gcc pcre devel zlib devel openssl openssl devel 解壓 tar zxvf nginx 1.9.9.tar....
Linux學習 CentOS 7 安裝Nginx
pcre 作用是讓 nginx 支援 rewrite 功能。root bogon src cd usr local src root bogon src wget 2 解壓安裝包 root bogon src tar zxvf pcre 8.35.tar.gz3 進入安裝包目錄 root bogon...
centos7安裝Nginx 使用nginx記錄
1 安裝各種依賴 gcc安裝,nginx原始碼編譯需要 yum install gcc c pcre pcre devel 安裝,nginx 的 http 模組使用 pcre 來解析正規表示式 yum install y pcre pcre devel zlib安裝,nginx 使用zlib對htt...