當前位置:首頁 » 編程軟體 » nginxcentos編譯安裝

nginxcentos編譯安裝

發布時間: 2022-05-15 22:48:24

Ⅰ centos7怎麼安裝nginx

安裝環境為:最小化安裝的centos7,關閉seliunx。
最小化安裝centos:
關閉selinux
sed –i 『s/SELINUX=enforcing/SELINUX=disabled/g』 /etc/selinux/config

開始安裝nginx1.7.8
創建群組
groupadd www
創建一個用戶,不允許登陸和不創主目錄
useradd -s /sbin/nologin -g www -M www
#下載最新版nginx
wget -C
tar zxvf nginx-1.7.8.tar.gz
#編譯基本能運行的nginx
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
make install

如果有錯誤提示:
./configure: error: C compiler cc is not found
解決方法:
yum install gcc gcc-c++

如果有錯誤提示:
./configure: error: the HTTP rewrite mole requires the PCRE library.
You can either disable the mole by using –without-http_rewrite_mole
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.
解決方法:
yum install pcre-devel

如果有錯誤提示:
./configure: error: SSL moles require the OpenSSL library.

Ⅱ 如何在 centos 7 中編譯安裝 nginx1.7.8

1.先從nginx官網下載最新的版本 http://nginx.org/download/nginx-1.7.8.tar.gz
2.解壓nginx-1.7.8.tar.gz,然後執行下面操作即可

./configure --prefix=/usr/local/nginx
make
make install

Ⅲ 求大神指導Centos7 源碼編譯安裝Nginx+php 配置動靜分離

這個是我的服務的實際 將配置Nginx實現動靜分離,對php頁面的請求轉發給LAMP處理,而靜態頁面交給Nginx,以實現動靜分離。客戶請求靜態數據給Nginx,Nginx直接應答客戶端,當請求動態數據到Nginx時,Nginx讓客戶端去找LAMP,通過代理的方式,LAMP就和客戶端連接了。分別配置動態分離和靜態分離

(1)架設並調試後端LAMP架構,指定的域名,IP地址為xxxx,創建動態頁面test.php。

(2)配置Nginx(xxxx)處理動態頁面請求,並把域名改為 chaodiquan.com 在server{};段中加入以下代碼,檢測語法後,重啟Nginx

(3)客戶端輸入xxxx/test.php 成功後動態分離就實現了,接下來再配置靜態分離

(4)配置Nginx處理靜態頁面請求,在server{};中加入以下代碼,檢測語法後,重啟Nginx

location ~ .*.(gif|jpg|jpeg|bmp|swf)$ { #這段代碼意思是任意網址以這5種格式為結尾就到Nginx根目錄下的html文件夾尋找資源

root html;
expires 1d; #緩存一天}

(5)在nginx的html目錄中,放入圖片aa.jpg,然後在apache的動態測試頁test.php中添加

<html>
<body>
<img src="aaaa/aa.jpg">
</body>
</html>

(6)客戶端輸入xxxx/test.php測試,由於test.php是動態頁面,因此客戶端會找到LAMP架構中的Apache,然後調取圖片aa.jpg是靜態數據,所以從Nginx提取,最後反饋給客戶端。這個是

Ⅳ centos上怎麼安裝ngix

第1步,解壓文件:
源碼包通常會使用tar工具歸檔然後用gzip或bzip2進行壓縮,後綴格式會分別為.tar.gz與tar.bz2 ,解壓方法:
[root@linuxprobe ~]# tar xzvf FileName.tar.gz
[root@linuxprobe ~]# tar jxvf FileName.tar.bz2
第2步,切換到解壓後的目錄:
[root@linuxprobe ~]# cd FileDirectory
第3步:准備編譯工作:
在開始安裝服務程序之前,需要執行configure腳本,他會自動的對當前系統進行一系列的評估,如源文件、軟體依賴性庫、編譯器、匯編器、連接器檢查等等,如果有需求,還可以使用--prefix參數來指定程序的安裝路徑(很實用),而當腳本檢查系統環境符合要求後,則會在當前目錄下生成一個Makefile文件。
[root@linuxprobe ~]# ./configure --prefix=/usr/local/program
第4步:生成安裝程序:
剛剛生成的Makefile文件會保存有系統環境依賴關系和安裝規則,接下來需要使用make命令來根據MakeFile文件提供的規則使用合適的SHELL來編譯所有依賴的源碼,然後make命令會生成一個最終可執行的安裝程序。
[root@linuxprobe ~]# make
第5步:安裝服務程序:
如果在configure腳本階段中沒有使用--prefix參數,那麼程序一般會被默認安裝到/usr/local/bin目錄中。
[root@linuxprobe ~]# make install
第6步:清理臨時文件(可選):
[root@linuxprobe ~]# make clean
卸載服務程序的命令(請不要隨便執行!!!):
[root@linuxprobe ~]# make uninstall
詳情可以參考這個文檔http://www.linuxprobe.com/chapter-20.html

Ⅳ centos 使用yum安裝nginx後如何添加模塊

1.確認你已經安裝在用的nginx信息

nginx-V

#停掉nginx服務
servicenginxstop
#進入解壓的nginx-1.10.3目錄
cdnginx-1.10.3
#編譯./configure後面加上第1步nginx-V查看到的所有配置參數,後面加上你要加的模塊配置
./configure--prefix=/etc/nginx--sbin-path=/usr/sbin/nginx...(太長我省略了)--add-mole=/root/nginx-rtmp-mole-1.1.10
make
千萬別makeinstall
驗證新nginx是否可用驗證編譯後的nginx是否可以使用已有的配置
./objs/nginx-t
使用新nginx
備份cp/usr/sbin/nginx/usr/sbin/nginx-bak
替換cp./objs/nginx/usr/sbin/nginx

ok了,重啟nginx
servicenginxstart
祝你成功!

Ⅵ 如何在CentOS 6使用yum安裝nginx

開始安裝Nginx和PHP-FPM之前,你必須卸載系統中以前安裝的Apache和PHP。用root登錄輸入下面的命令:
[plain] view plain
# yum remove httpd* php*

增加額外資源庫

默認情況下,CentOS的官方資源是沒有php-fpm的, 但我們可以從Remi的RPM資源中獲得,它依賴於EPEL資源。我們可以這樣增加兩個資源庫:

[plain] view plain
# yum install yum-priorities -y
# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

輸出樣例

[plain] view plain
Retrieving http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
warning: /var/tmp/rpm-tmp.00kiDx: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...########################################### [100%]
1:epel-release ########################################### [100%]

安裝Nginx

輸入下列命令

[plain] view plain
# yum install nginx

Ⅶ centos安裝nginx錯誤

出現這個錯誤是因為nginx的安裝目錄和解壓縮目錄選擇了同一個,並且參數沒有配置好。

舉例說明:在centos 7.2 環境下,我把nginx-1.12.2.tar.gz壓縮文件放在/opt/目錄下,tar -zxvf nginx-1.12.2.tar.gz 解壓以後出現nginx-1.12.2文件夾,mv nginx-1.12.2 nginx更改文件夾名為nginx,cd nginx進入nginx目錄,./configure --prefix=/opt/nginx 設置參數,make進行編譯,make install進行安裝,安裝的時候就會報這個錯誤。

解決方法有兩個(這里的參數只是針對解決問題,還需配合其他參數使用才不會使目錄那麼亂):

  1. 安裝目錄和解壓縮目錄不要選擇同一個,即:./configure --prefix=/usr/local/nginx

  2. 設置conf-patn參數,即: ./configure --prefix=/opt/nginx --conf-path=/opt/nginx/conf/nginx.conf

Ⅷ centos7怎麼編譯安裝nginx

安裝環境為:最小化安裝的centos7,關閉seliunx。
最小化安裝centos:
關閉selinux
sed –i 『s/SELINUX=enforcing/SELINUX=disabled/g』 /etc/selinux/config

開始安裝nginx1.7.8
創建群組
groupadd www
創建一個用戶,不允許登陸和不創主目錄
useradd -s /sbin/nologin -g www -M www
#下載最新版nginx
wget -C http://nginx.org/download/nginx-1.7.8.tar.gz
tar zxvf nginx-1.7.8.tar.gz
#編譯基本能運行的nginx
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
make install

如果有錯誤提示:
./configure: error: C compiler cc is not found
解決方法:
yum install gcc gcc-c++

如果有錯誤提示:
./configure: error: the HTTP rewrite mole requires the PCRE library.
You can either disable the mole by using –without-http_rewrite_mole
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.
解決方法:
yum install pcre-devel

如果有錯誤提示:
./configure: error: SSL moles require the OpenSSL library.
You can either do not enable the moles, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using –with-openssl=<path> option.
解決方法:
yum install openssl-devel

以上錯誤提示依次解決後:再一次的運行
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
meke install

編譯參數解釋:
#指定運行許可權的用戶
--user=www
#指定運行的許可權用戶組
--group=www
#指定安裝路徑
--prefix=/usr/local/nginx
#支持nginx狀態查詢
--with-http_stub_status_mole
#開啟ssl支持
--with-http_ssl_mole
#開啟GZIP功能
--with-http_gzip_static_mole

因此要順利的通過nginx編譯安裝必須安裝的依賴關系有:
yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel

2、在 centos7 中為nginx的啟動、重啟、重載配置添加腳本
nginx直接啟動的方法:
/usr/local/nginx/sbin/nginx

但是不是很方便,因此使用下面的腳本來控制nginx的啟動關閉重載更加合理一些。
編輯文件:vim /usr/lib/systemd/system/nginx.service 添加下面的腳本,注意路徑 !
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

systemctl的一些使用方法:
systemctl is-enabled servicename.service #查詢服務是否開機啟動
systemctl enable xxx.service #開機運行服務
systemctl disable xxx.service #取消開機運行
systemctl start xxx.service #啟動服務
systemctl stop xxx.service #停止服務
systemctl restart xxx.service #重啟服務
systemctl reload xxx.service #重新載入服務配置文件
systemctl status xxx.service #查詢服務運行狀態
systemctl --failed #顯示啟動失敗的服務

因此,添加上面腳本後,centos7 中操作nginx的方法有
systemctl is-enabled nginx.service #查詢nginx是否開機啟動
systemctl enable nginx.service #開機運行nginx
systemctl disable nginx.service #取消開機運行nginx
systemctl start nginx.service #啟動nginx
systemctl stop nginx.service #停止nginx
systemctl restart nginx.service #重啟nginx
systemctl reload nginx.service #重新載入nginx配置文件
systemctl status nginx.service #查詢nginx運行狀態
systemctl --failed #顯示啟動失敗的服務

Ⅸ CentOS系統上,怎麼安裝 nginx

返值,失敗返 false 值,sybase_connect連資料庫語,別連接使用帳號及密碼使用本函數需注意早點關閉資料庫, 整數函數種類, 資料庫功能 本函數用打與 Sybase 資料庫連接參數 servername 欲連資料庫伺服器名稱參數 username 及 password 省略, string [password]), string [username], int sybase_connect(string [servername],?br />連接功則返資料庫連接代號,減少系統負?第一步:為yum增加epel的源,命令:yum install epel-release 回車第二部:命令:yum install nginx回車第三部:yum install php-fpm

Ⅹ 如何在CentOS 6上通過YUM安裝Nginx和PHP-FPM

在CentOS 6上通過YUM安裝Nginx和PHP-FPM:
第一步,在/etc/yum.repos.d/目錄下創建一個源配置文件nginx.repo:
cd /etc/yum.repos.d/
vim nginx.repo

填寫如下內容:
[nginx]
name=nginx repo
baseurl=nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
保存,則會產生一個/etc/yum.repos.d/nginx.repo文件。

下面直接執行如下指令即可自動安裝好Nginx:
yum install nginx -y
安裝完成,下面直接就可以啟動Nginx了:
/etc/init.d/nginx start
現在Nginx已經啟動了,直接訪問伺服器就能看到Nginx歡迎頁面了的。

熱點內容
python保存mp3文件 發布:2024-03-29 12:47:10 瀏覽:150
win10怎麼配置jdk8 發布:2024-03-29 12:47:09 瀏覽:535
解壓軟體java 發布:2024-03-29 12:40:32 瀏覽:282
長安cs35壓縮比 發布:2024-03-29 12:39:58 瀏覽:176
java中編譯器默認導入jdk包 發布:2024-03-29 12:23:26 瀏覽:365
中山大學資料庫 發布:2024-03-29 12:20:44 瀏覽:695
創造與魔法哪個腳本不要錢 發布:2024-03-29 12:20:38 瀏覽:441
medly安卓版在哪裡進行作曲 發布:2024-03-29 12:20:37 瀏覽:427
php所有空格 發布:2024-03-29 12:19:28 瀏覽:656
asp建立資料庫 發布:2024-03-29 12:07:18 瀏覽:533