ChinaDBA.com×××

 應朋友要求,將LNMP的×××步驟寫在這裏

chinadba.com基於LNMP結構,即Linux、Nginx、MySQL、PHP

首先要有臺linux的機器,上面需要首先安裝GCC、automake、autoconf,另外由於mysql5.5使用了cmake,cmake也需要安裝。

準備好源碼包

首先安裝MySQL吧

下載並安裝cmake

#tar zxf cmake-2.8.5.tar.gz

#cd cmake-2.8.5

#./bootstrap

#make

#make install

 

下載並安裝mysql5.5

#useradd mysql

#tar zxvf mysql-5.5.15.tar.gz

#cd mysql-5.5.15

#CFLAGS=”-O3″ CXX=gcc

#CXXFLAGS=”-O3 -felide-constructors -fno-exceptions -fno-rtti”

#cmake . -LH|more //CMake下查看MySQL的編譯配置

#cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

#make -j 8

#make install

#cp support-files/my-medium.cnf /etc/my.cnf

#cd /usr/local/mysql

#scripts/mysql_install_db –user=mysql

#chown -R root .

#chgrp -R mysql .

#chown -R mysql:mysql data/

#bin/mysqld_safe –user=mysql &

# cp -rf support-files/mysql.server /etc/init.d/mysqld

# chmod 755 /etc/init.d/mysqld

 

接下來安裝php

#./configure

--prefix=/usr/local/php

--enable-fpm

--with-fpm-user=daemon

--with-fpm-group=daemon

--with-config-file-path=/usr/local/php/etc

--with-mysql=/usr/local/mysql

--with-mysqli=/usr/local/mysql/bin/mysql_config

--with-pdo-mysql=/usr/local/mysql

--with-iconv

--with-iconv-dir

--with-freetype-dir

--with-jpeg-dir

--with-png-dir

--with-gd

--with-zlib

--with-libxml-dir

--with-curl

--with-curlwrappers

--with-mhash

--with-xmlrpc

--with-mcrypt

--enable-xml

--disable-rpath

--enable-safe-mode

--enable-bcmath

--enable-shmop

--enable-sysvsem

--enable-inline-optimization

--enable-mbregex

--enable-mbstring

--enable-gd-native-ttf

--enable-ftp

--enable-pcntl

--enable-sockets

--enable-zip

--enable-soap

--disable-debug

--disable-ipv6

選項前面是兩個-

#make

#make install

配置fpm

#cp -rf sapi/fpm/php-fpm.conf /usr/local/php/etc/

#cp -rf sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

# cp -rf php.ini-production /usr/local/php/etc/php.ini

# chmod 755 /etc/init.d/php-fpm

php的配置與優化

修改配置文件,主要修改的參數有以下一些:

error_log = /usr/local/php/var/log/php-fpm.log

log_level = notice

emergency_restart_threshold = 10

emergency_restart_interval = 1m

process_control_timeout = 5

daemonize = yes

listen = 127.0.0.1:9000

listen.owner = daemon

listen.group = daemon

listen.mode = 0666

pm = dynamic

pm.max_children = 256

pm.min_spare_servers = 128

pm.max_spare_servers = 256

pm.max_requests = 1024(*)

request_terminate_timeout = 600s(*)

request_slowlog_timeout = 300s

rlimit_files = 65536

rlimit_core = 65536

最後安裝nginx,爲了提供perl正則表達式支持先安裝pcre

(1)編譯安裝pcre

#tar jxvf pcre-8.02.tar.bz2

#cd pcre-8.02

#./configure

#make

#make install

(2)安裝nginx

#tar zxvf nginx-0.8.53.tar.gz

#cd nginx-0.8.53

#./configure \

--user=daemon \

--group=daemon \

--prefix=/usr/local/nginx \

--with-http_stub_status_module \

--with-http_ssl_module \

#make

#make install

#vim /etc/rc.local加入

/usr/local/nginx/sbin/nginx         配置開機啓動

修改nginx的配置文件

        # for chinadba.com
        server
        {
         listen       80;
         server_name  www.chinadba.com chinadba.com;

         root  /usr/local/chinadba.com;
         index index.php;

         if (!-e $request_filename) {
              rewrite . /index.php break;
             }

         location ~ "\.(php)$" {

         fastcgi_pass    127.0.0.1:9000;
         fastcgi_index   index.php;
         include         /usr/local/nginx/conf/fastcgi.conf;
         index           index.php;
         if (!-e $request_filename) {
              rewrite . /index.php last;
              break;
             }

          }

         log_format  chinadba.com  '$http_x_real_ip - $remote_user [$time_local] $request_time "$request" '
                                '$status $body_bytes_sent "$http_referer" '
                                '"$http_user_agent" $http_x_forwarded_for';
         access_log  /usr/local/nginx/logs/access_chinadba.com.log  chinadba.com;
        }

 
最後優化一下linux的內核參數

 

優化linux內核參數

#vim /etc/sysctl.conf

添加如下內容:

net.ipv4.tcp_max_syn_backlog = 65536

net.core.netdev_max_backlog = 32768

net.core.somaxconn = 32768

net.core.wmem_default = 8388608

net.core.rmem_default = 8388608

net.core.rmem_max = 16777216

net.core.wmem_max = 16777216

net.ipv4.tcp_timestamps = 0

net.ipv4.tcp_synack_retrices = 2

net.ipv4.tcp_syn_retrices = 2

#sysctl -p使其生效

 

wordpress的裝配,自帶的readme.html就有,照着做就行了。

ok,至此完成。

另外做個廣告,歡迎光臨chinadba.com。
 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章