登陸騰訊雲centos安裝nginx環境

本地電腦安裝putty,下載網址https://www.ssh.com/ssh/putty/download
在這裏插入圖片描述
然後輸入用戶名,默認root
輸入密碼,輸入密碼時候並不會出現星號,輸入完直接會車。

開始就告訴你,如果wget一個安裝包很慢或者下載不下來,可以把網址複製到迅雷裏下載,即使被牆了,迅雷也能p2p幫你下載下來的。然後自己使用winscp複製到 /usr/local/src目錄下即可。

1.安裝make
yum -y install gcc automake autoconf libtool make
yum install gcc gcc-c++

2.安裝pcre
PCRE(Perl Compatible Regular Expressions)是一個Perl庫,包括 perl 兼容的正則表達式庫。這些在執行正規表達式模式匹配時用與Perl 5同樣的語法和語義是很有用的。Boost太龐大了,使用boost regex後,程序的編譯速度明顯變慢。測試了一下,同樣一個程序,使用boost::regex編譯時需要3秒,而使用pcre不到1秒。因此改用pcre來解決C語言中使用正則表達式的問題.網址:ftp://ftp.pcre.org/pub/pcre/。自己查找最新版本的。
在這裏插入圖片描述
cd /usr/local/src
wget ftp://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
tar -zxvf pcre-8.44.tar.gz
cd pcre-8.44
./configure
make && make install

3.安裝zlib
zlib 是通用的壓縮庫,提供了一套 in-memory 壓縮和解壓函數,並能檢測解壓出來的數據的完整性(integrity)。zlib 也支持讀寫 gzip (.gz) 格式的文件。網址:http://www.zlib.net/。可以找到最新版本。
cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install

4.安裝openssl
ssl,可以讓網站變成https。需要ssl證書,阿里雲騰訊雲可以申請免費的。下載網址:https://www.openssl.org/source/

cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.1.1e.tar.gz
tar -zxvf openssl-1.1.1e.tar.gz
cd openssl-1.1.1e/
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib
make && make install

5.安裝nginx
這個就不用說了,網址 http://nginx.org/download/,查找最新版。
cd /usr/local/src
wget http://nginx.org/download/nginx-1.17.9.tar.gz
tar -zxvf nginx-1.17.9.tar.gz
cd nginx-1.17.9
./configure
make && make install

./configure時候報錯了。
./configure: error: the HTTP rewrite module requires the PCRE library.
解決:
yum -y install pcre-devel
yum -y install openssl openssl-devel
然後再次執行./configure

啓動nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
在這裏插入圖片描述
開機自啓動
即在rc.local增加啓動代碼就可以了。
vi /etc/rc.local
增加一行 /usr/local/nginx/sbin/nginx
設置執行權限:
chmod 755 rc.local

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章