nginx源码部署
nginx 需要安裝的依賴
#centos 安裝 yum -y install gcc pcre-devel zlib-devel openssl openssl-devel #ubuntu apt-get install gcc pcre-devel zlib-devel openssl openssl-devel #未進行測試 mac : brew install gcc brew install opensslnginx 源碼安裝
#如果沒有安裝wget 請安裝后使用 mac: brew install wget centos: yum install wget ubuntu: apt-get install wget # 使用wget下載穩定版 Nginx wget https://nginx.org/download/nginx-1.22.0.tar.gz解壓縮
tar -zxvf nginx-1.22.0.tar.gz安裝
cd nginx-1.22.0 #執行 ./configure --prefix=/usr/local/nginx --with-openssl=/root/openssl-1.1.1g如果缺少依賴會出現報錯
./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.解決error: the HTTP rewrite module requires the PCRE library
#下載最新版本pcre地址:http://www.pcre.org. #解壓到 /usr/local/src tar -zxvf pcre-8.45.tar.gz sudo mkdir -p /usr/local/src sudo chmod -R 777 /usr/local/src mv ~/Downloads/pcre-8.45 /usr/local/src/pcre cd pcre ./configure --prefix=/usr/local sudo chmod -R 777 /usr/local/lib sudo chmod -R 777 /usr/local/share sudo chmod -R 777 /usr/local/bin sudo make && make install #沒有報錯即解決pcre依賴問題編譯并安裝nginx
sudo make && make install""" error: mkdir: /usr/local/nginx: Permission denied make[1]: *** [install] Error 1 make: *** [install] Error 2 """ sudo mkdir -p /usr/local/nginx sudo chmod -R 777 /usr/local/nginx sudo make && make install cd /usr/local/nginx/sbin ./nginx 輸入地址 http://localhost:80看到如圖內容,即nginx部署成功補充說明:每次啟動會麻煩可以建立全局變量 方案一:ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/ 方案二:vi /etc/profileexport NGINX_HOME=/usr/local/nginxexport PATH=$PATH:$NGINX_HOME/sbinsource /etc/profile 配置后啟動: nginx總結
- 上一篇: smtp邮件服务器配置,配置SMTP服务
- 下一篇: java实现文本编辑器