成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

【博文推薦】搭建完全分離式LNMP平臺的簡單案例

系統 Linux
編者按:現在Nginx運用越來越廣廣泛,Nginx的優點也越來越突出,所以,在很多企業采用了LNMP架構,而且, 一些軟件也運用在LNMP平臺上比如ZABBIX。下面步入正題,看LNMP架構怎么搭建。

寫在前面:如果此文有幸被某位朋友看見并發現有錯的地方,希望批評指正。如有不明白的地方,愿可一起探討。

博文地址:http://muluhe.blog.51cto.com/9152490/1564120


案例拓撲圖

wKioL1Q9NNyDOYpoAADB-wCoxsg241.jpg

安裝配置nginx服務器


編譯安裝nginx時,需要事先安裝 開發包組"Development Tools"和"Server Platform Development",同時還需專門安裝pcre-devel包。

  1. # yum -y groupinstall "Development Tools"   
  2. # yum -y groupinstall "Server Platform Development"   
  3. # yum -y install pcre-devel 

首先添加nginx用戶組和nginx用戶

  1. # groupadd -r nginx   
  2. # useradd -g nginx -r nginx 

創建編譯安裝是所需要的目錄

  1. # mkdir -pv /var/tmp/nginx/client 

編譯安裝nginx

  1. # tar xf nginx-1.4.7.tar.gz   
  2. # cd nginx-1.4.7   
  3. # ./configure \   
  4.   --prefix=/usr/local/nginx \   
  5.   --sbin-path=/usr/local/nginx/sbin/nginx \   
  6.   --conf-path=/etc/nginx/nginx.conf \   
  7.   --error-log-path=/var/log/nginx/error.log \   
  8.   --http-log-path=/var/log/nginx/access.log \   
  9.   --pid-path=/var/run/nginx/nginx.pid  \   
  10.   --lock-path=/var/lock/nginx.lock \   
  11.   --user=nginx \   
  12.   --group=nginx \   
  13.   --with-http_ssl_module \   
  14.   --with-http_flv_module \   
  15.   --with-http_stub_status_module \   
  16.   --with-http_gzip_static_module \   
  17.   --http-client-body-temp-path=/var/tmp/nginx/client/ \   
  18.   --http-proxy-temp-path=/var/tmp/nginx/proxy/ \   
  19.   --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \   
  20.   --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \   
  21.   --http-scgi-temp-path=/var/tmp/nginx/scgi \   
  22.   --with-pcre   
  23. # make && make install 

為nginx提供SysV init腳本

  1. # vim /etc/rc.d/init.d/nginx 
  1. #!/bin/sh   
  2. #   
  3. # nginx - this script starts and stops the nginx daemon   
  4. #   
  5. # chkconfig:   - 85 15    
  6. # description:  Nginx is an HTTP(S) server, HTTP(S) reverse \   
  7. #               proxy and IMAP/POP3 proxy server   
  8. # processname: nginx   
  9. # config:      /etc/nginx/nginx.conf   
  10. # config:      /etc/sysconfig/nginx   
  11. # pidfile:     /var/run/nginx.pid   
  12.      
  13. # Source function library.   
  14. . /etc/rc.d/init.d/functions  
  15.      
  16. # Source networking configuration.   
  17. . /etc/sysconfig/network  
  18.      
  19. # Check that networking is up.   
  20. [ "$NETWORKING" = "no" ] && exit 0   
  21.      
  22. nginx="/usr/local/nginx/sbin/nginx" 
  23. prog=$(basename $nginx)   
  24.      
  25. NGINX_CONF_FILE="/etc/nginx/nginx.conf" 
  26.      
  27. [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx  
  28.      
  29. lockfile=/var/lock/subsys/nginx  
  30.      
  31. make_dirs() {   
  32.    # make required directories   
  33.    user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`   
  34.    options=`$nginx -V 2>&1 | grep 'configure arguments:'`   
  35.    for opt in $options; do  
  36.        if [ `echo $opt | grep '.*-temp-path'` ]; then  
  37.            value=`echo $opt | cut -d "=" -f 2`   
  38.            if [ ! -d "$value" ]; then  
  39.                # echo "creating" $value   
  40.                mkdir -p $value && chown -R $user $value   
  41.            fi  
  42.        fi  
  43.    done  
  44. }   
  45.      
  46. start() {   
  47.     [ -x $nginx ] || exit 5   
  48.     [ -f $NGINX_CONF_FILE ] || exit 6   
  49.     make_dirs   
  50.     echo -n $"Starting $prog: "  
  51.     daemon $nginx -c $NGINX_CONF_FILE   
  52.     retval=$?   
  53.     echo  
  54.     [ $retval -eq 0 ] && touch $lockfile   
  55.     return $retval   
  56. }   
  57.      
  58. stop() {   
  59.     echo -n $"Stopping $prog: "  
  60.     killproc $prog -QUIT   
  61.     retval=$?   
  62.     echo  
  63.     [ $retval -eq 0 ] && rm -f $lockfile   
  64.     return $retval   
  65. }   
  66.      
  67. restart() {   
  68.     configtest || return $?   
  69.     stop   
  70.     sleep 1   
  71.     start   
  72. }   
  73.      
  74. reload() {   
  75.     configtest || return $?   
  76.     echo -n $"Reloading $prog: "  
  77.     killproc $nginx -HUP   
  78.     RETVAL=$?   
  79.     echo  
  80. }   
  81.      
  82. force_reload() {   
  83.     restart   
  84. }   
  85.      
  86. configtest() {   
  87.   $nginx -t -c $NGINX_CONF_FILE   
  88. }   
  89.      
  90. rh_status() {   
  91.     status $prog   
  92. }   
  93.      
  94. rh_status_q() {   
  95.     rh_status >/dev/null 2>&1   
  96. }   
  97.      
  98. case "$1" in  
  99.     start)   
  100.         rh_status_q && exit 0   
  101.         $1   
  102.         ;;   
  103.     stop)   
  104.         rh_status_q || exit 0   
  105.         $1   
  106.         ;;   
  107.     restart|configtest)   
  108.         $1   
  109.         ;;   
  110.     reload)   
  111.         rh_status_q || exit 7   
  112.         $1   
  113.         ;;   
  114.     force-reload)   
  115.         force_reload   
  116.         ;;   
  117.     status)   
  118.         rh_status   
  119.         ;;   
  120.     condrestart|try-restart)   
  121.         rh_status_q || exit 0   
  122.             ;;   
  123.     *)   
  124.         echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"  
  125.         exit 2   
  126. esac 

為此腳本賦予執行權限

  1. # chmod +x /etc/rc.d/init.d/nginx 

將nginx服務添加至服務管理列表,并讓其開機自動啟動

  1. # chkconfig --add nginx   
  2. # chkconfig nginx on 

編輯配置文件/etc/nginx/nginx.conf,在server段內添加如下內容

  1. location ~ \.php$ {   
  2.     fastcgi_pass   10.170.2.90:9000;   
  3.     fastcgi_index  index.php;   
  4.     fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name;   
  5.     include        fastcgi_params;   

啟動nginx服務

  1. # vim /etc/init.d/nginx start 

測試nginx是否工作起來,在瀏覽器中鍵入10.170.2.80,可以得到如下頁面

wKioL1Q9LSiw-gBgAAG9vqavcsc123.jpg

安裝PHP服務器


編譯安裝php

  1. # tar xf php-5.4.26.tar.bz2   
  2. # cd php-5.4.26   
  3. # ./configure --prefix=/usr/local/php5 --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --enable-fpm --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2   
  4. # make && make install 

為php提供配置文件

  1. # cp php.ini-production /etc/php.ini 

配置php-fpm

  1. # cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm   
  2. # chmod +x /etc/rc.d/init.d/php-fpm   
  3. # chkconfig --add php-fpm   
  4. # chkconfig php-fpm on   
  5. # cp /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf 

編輯配置文件/usr/local/php5/etc/php-fpm.conf,將以下選項修改為相對應的值

  1. pm.max_children = 50   
  2. pm.start_servers = 5   
  3. pm.min_spare_servers = 2   
  4. pm.max_spare_servers = 8   
  5. pid = /usr/local/php5/var/run/php-fpm.pid 

在/var/www/html目錄下提供測試頁面index.php,其內容為

  1. <h1>hello,nginx</h1>   
  2. <?php   
  3.         $link = mysql_connect('10.170.2.36','testuser','******');   
  4.         if ($link)   
  5.                 echo "Success...";   
  6.         else  
  7.                 echo "Failure...";   
  8.     
  9.         mysql_close();   
  10.         phpinfo();   
  11. ?> 

啟動php-fpm服務

  1. # /etc/init.d/php-fpm start 

測試nginx服務器與php服務器是否能夠建立通信,在瀏覽器中鍵入10.170.2.80/index.php,可以得到如下頁面

wKioL1Q9M63ijdb-AAI2nNDl8qs444.jpg

頁面中顯示Failure...,是因為后端的數據庫還沒有進行相應的配置

安裝MariaDB服務器


編譯安裝mariadb-5.5.36

  1. # tar xf mariadb-5.5.36-linux-x86_64.tar.gz -C /usr/local   
  2. # cd /usr/local/   
  3. # ln -sv mariadb-5.5.36-linux-x86_64/ mysql   
  4. # mkdir -pv /mysql/data   
  5. # groupadd -r mysql   
  6. # useradd -g mysql -s /sbin/nologin -M -d /mysql/data -r mysql   
  7. # chown -R mysql:mysql /mysql   
  8. # chown -R mysql:mysql /mysql/data 

為數據庫提供配置文件:

  1. # cd mysql   
  2. # mkdir /etc/mysql   
  3. # chown -R root.mysql ./*   
  4. # cp support-files/my-large.cnf /etc/mysql/my.cnf   
  5. 修改文件/etc/mysql/my.cnf文件內容,在thread_concurrency = 8行下添加一行:   
  6. datadir = /mysql/data 

為數據庫提供SysV啟動腳本,并設置為開機啟動:

  1. # cp support-files/mysql.server /etc/init.d/mysqld   
  2. # chkconfig --add mysqld   
  3. # chkconfig mysqld on 

初始化數據庫并啟動數據庫:

  1. # echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh   
  2. # source /etc/profile.d/mysql.sh    
  3. # echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf   
  4. # ldconfig   
  5. # ln -sv /usr/local/mysql/include/ /usr/include/mysql   
  6. # scripts/mysql_install_db --user=mysql --datadir=/mysql/data/   
  7. # /etc/init.d/mysqld start 

創建數據庫并授權:

  1. MariaDB [(none)]> CREATE DATABASE testdb;   
  2. MariaDB [(none)]> GRANT ALL ON testdb.* TO dscuser@'10.170.2.%' IDENTIFIED BY '******';   
  3. MariaDB [(none)]> FLUSH PRIVILEGES; 

整體測試LNMP平臺


在瀏覽器中鍵入10.170.2.80/index.php,可以得到如下頁面

wKioL1Q9ND6RPJbOAAI3E1x54NM883.jpg

這次可以看到頁面中顯示Success...信息。

責任編輯:林師授 來源: 51CTO
相關推薦

2024-07-08 12:18:13

2015-03-09 14:53:04

OracleOracle DGDataGuard F

2014-12-24 11:13:06

可用性集availabilitset

2015-05-15 10:04:28

localhost

2014-11-25 11:33:35

2018-11-08 11:12:09

存儲分離式超融合

2015-02-27 10:14:33

2015-06-15 13:06:23

項目項目經驗

2015-06-17 09:34:09

軟件定義存儲 云存儲

2015-07-01 10:25:07

Docker開源項目容器

2018-08-02 09:13:34

分離式超融合存儲

2014-12-12 10:46:55

Azure地緣組affinitygro

2015-09-29 10:26:51

pythonlogging模塊

2018-05-07 09:34:39

分離式超融合存儲

2015-12-10 10:13:22

2015-04-07 09:32:57

phpSocket通信php出現錯誤

2015-03-19 09:35:36

OpenStack平臺性能測試Rally功能測試Tempest

2014-12-01 10:33:51

Python

2015-04-21 09:28:58

ockerdocker監控平臺監控

2015-07-29 13:46:27

OpenStackIcehouse私有云實戰部署
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 欧美精品一区在线发布 | 国产精品视频导航 | 色婷婷激情 | 成人免费看黄 | 免费视频一区二区 | 国产探花在线精品一区二区 | 偷拍亚洲色图 | 国产第1页 | 天堂一区二区三区 | 岛国av在线免费观看 | 国产精品久久国产精品 | 中文字幕成人免费视频 | 亚洲国产aⅴ精品一区二区 免费观看av | 精品动漫一区 | 99精品欧美一区二区三区综合在线 | 亚洲综合热 | 亚洲网站在线观看 | 久久成人精品一区二区三区 | 欧美日韩综合一区 | 亚洲欧洲日韩精品 中文字幕 | 久久久精品一区二区三区 | 久久久久久国产精品久久 | 懂色中文一区二区三区在线视频 | 365夜爽爽欧美性午夜免费视频 | 成人一区二区在线 | 精品一区二区久久久久久久网站 | 亚洲精品日韩一区二区电影 | 色狠狠一区 | 亚洲精品电影 | 欧美一区二区三区久久精品 | 久久综合爱 | 99精品国产一区二区三区 | 日韩有码在线播放 | 日韩av三区 | 激情a | 日韩av一区二区在线观看 | 精品一区二区三区日本 | 91精品国产91久久久久久三级 | 日本中文字幕一区 | 美国a级毛片免费视频 | 亚洲精品v日韩精品 |