LNMMP平台搭建

來源:互聯網
上載者:User

標籤:mysql   資料庫   設定檔   local   identified   

拓撲650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/4A/43/wKiom1QkA2rD8fEsAAe8ZNeNTe0466.bmp" title="a.bmp" alt="wKiom1QkA2rD8fEsAAe8ZNeNTe0466.bmp" />1) Nginx及的編譯及安裝

參考Nginx基本使用一文,同時在編譯時間一定要加入

2) 編譯安裝MariaDB
#添加使用者useradd -r mysql#安裝並提供設定檔和啟動指令碼tar xvf mariadb-10.0.10-linux-x86_64.tar.gz -C /usr/local/cd /usr/local/ln -s mariadb-10.0.10-linux-x86_64/ mysqlmkdir /etc/mysqlscp support-files/my-large.cnf /etc/mysql/my.cnfscp support-files/mysql.server /etc/init.d/mysqld #更改目錄許可權chown -R nginx.mysql ./*chown -R mysql.mysql data#初始化資料庫scripts/mysql_install_db #啟動服務並提供具有許可權的使用者MariaDB [(none)]> grant all on *.* to ‘test‘@‘172.16.21.%‘ identified by ‘123456‘;Query OK, 0 rows affected (0.05 sec)MariaDB [(none)]> flush privileges;Query OK, 0 rows affected (0.00 sec)


3) 編譯安裝php
#解決依賴關係yum install bzip2-devel libmcrypt-devel  libcurl-devel#解壓並安裝phptar xf php-5.4.26.tar.bz2 -C /usr/local/src/cd /usr/local/src/php-5.4.26/./configure --prefix=/usr/local/php --with-mysql=mysqlnd --with-openssl  --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd  --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr/local/libxml --enable-xml  --enable-sockets --enable-fpm --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2make && make install#提供指令碼開機檔案和設定檔cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confcp /usr/local/src/php-5.4.26/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm#啟動服務service php-fpm startStarting php-fpm  doness -tnl |grep 9000LISTEN     0      128               127.0.0.1:9000                     *:*


4) 為php提供xcache加速
[[email protected] ~]# tar xf xcache-3.1.0.tar.bz2 -C /usr/local/src[[email protected] ~]# cd /usr/local/src/xcache-3.1.0[[email protected] xcache-3.1.0]#  /usr/local/php/bin/phpize[[email protected] xcache-3.1.0]# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config[[email protected] xcache-3.1.0]# make && make install[[email protected] xcache-3.1.0]# mkdir /etc/php.d[[email protected] xcache-3.1.0]# cp xcache.ini /etc/php.d/[[email protected] xcache-3.1.0]# service php-fpm restaret


5) 配置nginx為php的反向 Proxy

編輯nginx設定檔,開啟如下選項

    index  index.php index.html index.htm; #在index選項後加入index.phplocation ~ \.php$ {            root           html;            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;            include        fastcgi_params;        }

編輯/etc/nginx/fastcgi_params檔案

[[email protected] xcache-3.1.0]# cat /etc/nginx/fastcgi_paramsfastcgi_param  GATEWAY_INTERFACE  CGI/1.1;fastcgi_param  SERVER_SOFTWARE    nginx;fastcgi_param  QUERY_STRING       $query_string;fastcgi_param  REQUEST_METHOD     $request_method;fastcgi_param  CONTENT_TYPE       $content_type;fastcgi_param  CONTENT_LENGTH     $content_length;fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;fastcgi_param  REQUEST_URI        $request_uri;fastcgi_param  DOCUMENT_URI       $document_uri;fastcgi_param  DOCUMENT_ROOT      $document_root;fastcgi_param  SERVER_PROTOCOL    $server_protocol;fastcgi_param  REMOTE_ADDR        $remote_addr;fastcgi_param  REMOTE_PORT        $remote_port;fastcgi_param  SERVER_ADDR        $server_addr;fastcgi_param  SERVER_PORT        $server_port;fastcgi_param  SERVER_NAME        $server_name; #提供php測試頁面[[email protected] html]# cat index.php<?phpphpinfo();?>#訪問測試

650) this.width=650;" title="wpsD3AE.tmp" border="0" alt="wpsD3AE.tmp" src="http://img1.51cto.com/attachment/201409/25/6837943_1411645708jIiu.png" height="396" style="border:0px;padding-left:0px;padding-right:0px;padding-top:0px;background-image:none;" /> 

#而且xcache已經成功安裝

650) this.width=650;" title="wpsD3BF.tmp" border="0" alt="wpsD3BF.tmp" src="http://img1.51cto.com/attachment/201409/25/6837943_1411645710E93n.png" height="257" style="border:0px;padding-left:0px;padding-right:0px;padding-top:0px;background-image:none;" /> 

 

6) 安裝memcached
[[email protected] ~]# tar xvf memcached-1.4.15.tar.gz -C /usr/local/src/[[email protected] ~]# cd /usr/local/src/memcached-1.4.15[[email protected] memcached-1.4.15]# lsaclocal.m4    COPYING      memcached_dtrace.d  solaris_priv.cassoc.c       daemon.c     memcached.h         stats.cassoc.h       depcomp      memcached.spec      stats.hAUTHORS       doc          missing             tcache.c       hash.c       NEWS                testapp.ccache.h       hash.h       protocol_binary.h   thread.cChangeLog     install-sh   README.md           timedrun.ccompile       items.c      sasl_defs.c         trace.hconfig.guess  items.h      sasl_defs.h         util.cconfig.h.in   m4           scripts             util.hconfig.sub    Makefile.am  sizes.c             version.m4configure     Makefile.in  slabs.cconfigure.ac  memcached.c  slabs.h[[email protected] memcached-1.4.15]# ./configure --prefix=/usr/local/memcached[[email protected] memcached-1.4.15]#make && make install #安裝後配置[[email protected] memcached-1.4.15]#  echo "export PATH=/usr/local/memcached/bin:$PATH" > /etc/profile.d/memcache.sh[[email protected] memcached-1.4.15]# . /etc/profile.d/memcache.sh[[email protected] memcached-1.4.15]# echo "MANPATH /usr/local/memcached/share/man" >> /etc/man.config[[email protected] memcached-1.4.15]# ln -s include/memcached /usr/include/memcache[[email protected] memcached-1.4.15]# useradd -r memcached[[email protected] memcached-1.4.15]# memcached -u memcached


6)為php安裝memached模組
[[email protected] php]# tar xf memcache-2.2.7.tgz -C /usr/local/src/[[email protected] php]# cd /usr/local/src/memcache-2.2.7/[[email protected] memcache-2.2.7]# /usr/local/php/bin/phpize Configuring for:PHP Api Version:         20100412Zend Module Api No:      20100525Zend Extension Api No:   220100525[[email protected] memcache-2.2.7]# ./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcache#在php的設定檔php.ini中加入如下內容extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/memcache.so #添加測試頁面memtest.php[[email protected] memcache-2.2.7]# cat /usr/local/nginx/html/memtest.php<?php$mem = new memcache;$mem->connect("172.16.21.103", 11211)  or die("Could not connect");$version = $mem->getVersion();echo "Server‘s version: ".$version."<br/>\n";$mem->set(‘hellokey‘, ‘Hello World‘, 0, 600) or die("Failed to save data at the memcached server");echo "Store data in the cache (data will expire in 600 seconds)<br/>\n";$get_result = $mem->get(‘hellokey‘);echo "$get_result is from memcached server.";?>


#訪問結果如下:

650) this.width=650;" title="wpsD3C0.tmp" border="0" alt="wpsD3C0.tmp" src="http://img1.51cto.com/attachment/201409/25/6837943_1411645712gOoM.png" height="152" style="border:0px;padding-left:0px;padding-right:0px;padding-top:0px;background-image:none;" /> 

#在memcached查看如下

[[email protected] ~]# telnet 127.0.0.1 11211Trying 127.0.0.1...Connected to 127.0.0.1.Escape character is ‘^]‘.get hellokeyVALUE hellokey 0 11Hello WorldEND

此時,我們的LNMMP已經搭建完成

LNMMP平台搭建

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.