1. 程式人生 > 實用技巧 >java中用SimpleDateFormat 怎麼把 2015-04-20T11:12:00.0+08:00 解析成 Date

java中用SimpleDateFormat 怎麼把 2015-04-20T11:12:00.0+08:00 解析成 Date

centos安裝配置nginx

1. 安裝環境

當在linux中安裝nginx的時候,執行了./configure以後,如果出現以下錯誤,則需要安裝環境

編譯安裝nginx需要pcre包,未安裝會有如下提示:

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
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.

因為nginx為c++編寫, 而且官方提供的為原始碼, 我們需要安裝gcc等編譯原始碼進行安裝

安裝環境 ,需要安裝pcre的devel包,pcre-devel。

yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel

安裝了上面的環境, 就可以了, 如果編譯的時候還是無法編譯成功,

出現該錯誤:.....checking for C compiler ... not found

再安裝此依賴

yum -y install gcc gcc-c++ autoconf automake make

2. 下載nginx

下載地址: http://nginx.org/en/download.html

這裡提供兩種下載方式

2.1 本地下載上傳伺服器

如下圖, 紅色框中的為linux或mac版本

下載之後上傳到伺服器

2.2 伺服器直接下載

直接下載需要使用wegt命令, 如果沒有此命令, 安裝即可yum install wegt

首先在nginx官網下載按鈕上滑鼠右鍵點選, 選擇複製連結地址

然後使用 wegt 連結地址 即可直接下載到伺服器的當期目錄

3. 安裝nginx

下載完畢的檔案解壓, 然後進入到nginx目錄中

執行目錄中的configure檔案用於生成可執行檔案

./configure     # 在解壓後的nginx目錄中執行

編譯

make

安裝

make install

沒報錯的話就是安裝完成了

然後使用whereis nginx指令來查詢nginx的安裝目錄, 我的結果為/usr/local/nginx/目錄下

4. 執行和關閉nginx

在nginx安裝目錄中, 有一個sbin的目錄, 進入看到有一個nginx的可執行檔案

必須sbin此目錄中執行以下命令

./nginx            # 開啟nginx
./nginx -s reload  # 重啟nginx
./nginx -s stop    # 關閉nginx

5. nginx配置檔案位置

配置檔案在nginx安裝目錄下的conf目錄中, 裡面的nginx.conf檔案就是配置檔案

配置可參考 nginx反向代理

6. 建立快捷指令

建立檔案 vim /usr/lib/systemd/system/nginx.service

寫入如下內容

[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop

[Install]
WantedBy=multi-user.target

注意路徑, 一定要是你自己安裝的nginx路徑

如果其他使用者需要此命令, 使用chmod指令新增許可權即可

使檔案生效systemctl daemon-reload或者重啟系統reboot

nginx快捷指令如下, 就不用每次都到nginx安裝目錄下執行了

systemctl start nginx   # 開啟nginx
systemctl stop nginx    # 關閉nginx
systemctl restart nginx # 重啟nginx

nginx開機自動啟動

systemctl enable nginx

關閉開機自動啟動

systemctl disable nginx.service

檢視當前狀態

systemctl status nginx.service