nginx服務搭建

1、nginx簡介:php

  國內經常使用的的是nginx,nginx是一個開源的,支持高性能、高併發的www服務和代理服務軟件,nginx因具備高併發(特別是靜態資源,)佔用系統資源少等特性,且功能豐富而逐漸流行起來,從軟件大的功能應用方面,nginx不可是一個優秀的web服務軟件,還能夠具備反向代理負載均衡功能和緩存服務功能,在方向代理負載均衡方面,他相似於大名鼎鼎的LVS負載均衡及haproxy專業代理軟件,可是nginx部署起來更爲簡單,方便,在緩存服務功能方面,它有相似於squid等專業的緩存服務軟件,當前流行的nginx web組合被稱爲LNMP或LEMP(LNMP 即 linux nginx mysql php)其中 LEMP (E取自Nginx (engine x))html

2、nignx的搭建mysql

//下載rewrite支持及一些源
[root@localhost data]# yum install pcre pcre-devel -y
[root@localhost data]# yum -y install gcc
[root@localhost data]# yum install openssl openssl-devel -y
//下載nginx
http://nginx.org/en/download.html      -->  download   -->   nginx-1.6.3
//將下載好的tar包放到本身規劃的路徑下並解壓
[root@localhost pandj]# ll /home/pandj/
total 788
-rw-r--r--. 1 root root 805253 Jul 31  2018 nginx-1.6.3.tar.gz
[root@localhost pandj]# ll
total 788
drwxr-xr-x. 8 pandj pandj    158 Apr  7  2015 nginx-1.6.3
-rw-r--r--. 1 root  root  805253 Jul 31  2018 nginx-1.6.3.tar.gz
//配置並編輯nginx
[root@localhost pandj]# cd nginx-1.6.3
[root@localhost nginx-1.6.3]# ./configure --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --prefix=/application/nginx-1.6.3/
[root@localhost nginx-1.6.3]# echo $?
0
[root@localhost nginx-1.6.3]# make
[root@localhost nginx-1.6.3]# make install
//建立用戶
[root@localhost nginx-1.6.3] useradd www
//建立一個軟鏈接,方便後續管理
[root@localhost application]# ln -s /application/nginx-1.6.3/ /application/nginx
//至此nginx已經安裝成功,檢查語法並重啓。
[root@localhost application]# /application/nginx/sbin/nginx -t
nginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful
[root@localhost sbin]# cd /application/nginx/sbin/nginx 
//瀏覽器訪問服務器地址,能夠看到welcome nginx

  

  一些參考文檔:搭建nginx + mysql + php 的環境配置及原理 :https://www.jianshu.com/p/495a02eb2672linux

  若是是在阿里雲上部署的nginx,在配置文件中修改了端口仍是不能訪問是由於須要在阿里雲上修改策略,默認只開放22和3306端口,在阿里雲——雲服務器——安全組規則——配置規則——添加安全組規則——添加所須要訪問的端口。nginx

  上訴參考案例:https://blog.csdn.net/liyuxing6639801/article/details/72588074web

相關文章
相關標籤/搜索