當前位置:首頁 » 操作系統 » 源碼安裝nginx

源碼安裝nginx

發布時間: 2022-01-18 19:12:48

編譯安裝nginx和yum安裝nginx有什麼區別

如果真的要說區別的話,源碼編譯安裝可以在各個linux系統下使用,而yum安裝只能在redhat或centos系統使用,其它系統例如ubuntu,freebsd是不可用的。另外yum安裝的nginx版本偏低,而源碼包是可以獲取官方最新的發行版本的。

⑵ OpenSUSE linux 12 下如何安裝nginx(源碼安裝方式,不是rpm包安裝方式)

源碼包裡面有readme,自己看。

⑶ 如何在linux上安裝nginx

#forcentos
yuminstall-yepel-release&&yumcleanall&&yummakecache
yuminstall-ynginx

如果編譯安裝的話需要很多依賴包。YUM安裝是最簡單的。

⑷ 編譯安裝nginx的配置文件的路徑在哪

這個版本不同,位置還是不同的。
我的是nginx-1.9.9版本源碼安裝,配置文件在conf這個目錄裡面:
/usr/local/nginx/conf/nginx.conf
如果你找不見也可以搜索:
find / | grep 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 #顯示啟動失敗的服務

⑹ 如何在雲主機上利用源代碼安裝Nginx伺服器

1這些設置可能會有所不同,你需要根據不同情況進行修改。 2安裝Apache2 2.切換管理員身份 在Ubuntu中需要用root身份進行操作,所以用下面的命令確保以root身份登錄: sudo su 3.開始安裝Mysql5 apt-get install mysql-server mysql-client 你將被要求提供一個MySQL的root用戶的密碼,我們需要在紅色區域設置密碼。 New password for the MySQL "root" user: <-- yourrootsqlpassword Repeat password for the MySQL "root" user: <-- yourrootsqlpassword 4.安裝Apache2 Apache2的是作為一個Ubuntu的軟體包,因此我們可以直接用下面命令安裝它: apt-get install apache2 5.安裝php5 我們可以直接安裝PHP5和Apache的PHP5的模塊,如下: apt-get install php5 libapache2-mod-php5 安裝完需要重啟 /etc/init.d/apache2 restart 6.測試的PHP5並獲取PHP5安裝的詳細信息: 默認網站的文件根目錄是在/var/www下中。現在我們將在該目錄中創建一個小型PHP文件(info.php的)在瀏覽器中調用它。該文件將顯示很多關於我們的PHP安裝,如安裝的PHP版本和有用的一些細節。 7.PHP5獲得MySOL的支持 讓PHP在MySQL中獲得支持,我們可以安裝的php-mysql軟體包。安裝一些其他的PHP5模塊,以及您可能需要的應用程序,這是一個好主意: apt-cache search php5 還安裝需要安裝的 apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl 現在重新啟動Apache2的: /etc/init.d/apache2 restart 8.安裝phpMyAdmin phpMyAdmin是一個網路介面,通過它可以管理你的MySQL資料庫。 apt-get install phpmyadmin 你會看到以下問題: Web server to reconfigure automatically: <-- apache2 Configure database for phpmyadmin with dbconfig-common? <-- No

⑺ 求大神指導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提取,最後反饋給客戶端。這個是

⑻ 源碼安裝nginx需要安裝哪些東西

nginx配置裡面配置一個server段,然後把網站的目錄,域名,別名等配置好就可以了。想要好管理配置,用include加個文單花廁拘丿餃搽邪敞矛件,裡面專門配置server段

⑼ 如何重新編譯安裝一下nginx,讓它支持 sub

nginx編譯配置

最後的--add-mole就是引入的subs_filter模塊。
編譯並安裝nginx
在/etc/nginx/nginx.config中配置subs_filter

熱點內容
單片機android 發布:2024-09-20 09:07:24 瀏覽:765
如何提高三星a7安卓版本 發布:2024-09-20 08:42:35 瀏覽:664
如何更換伺服器網站 發布:2024-09-20 08:42:34 瀏覽:311
子彈演算法 發布:2024-09-20 08:41:55 瀏覽:289
手機版網易我的世界伺服器推薦 發布:2024-09-20 08:41:52 瀏覽:817
安卓x7怎麼邊打游戲邊看視頻 發布:2024-09-20 08:41:52 瀏覽:162
sql資料庫安全 發布:2024-09-20 08:31:32 瀏覽:94
蘋果連接id伺服器出錯是怎麼回事 發布:2024-09-20 08:01:07 瀏覽:507
編程鍵是什麼 發布:2024-09-20 07:52:47 瀏覽:658
學考密碼重置要求的證件是什麼 發布:2024-09-20 07:19:46 瀏覽:481