LNMP組合詳解與實戰

技術小牛人發表於2017-11-07

二進位制包才可以直接安裝,普通包只能編譯安裝。

採用二進位制包安裝mysql

1、直接解壓 tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz

2、 mv mysql-5.5.32-linux2.6-x86_64 /application/mysql

3、useradd mysql -s /sbin/nologin -M

4、chown -R mysql.mysql /application/mysql/data

5、/application/mysql/scripts/mysql_install_db –user=mysql –basedir=/application/mysql/ –datadir=/application/mysql/data

6、cp support-files/mysql.server /etc/init.d/mysqld

7、vi /etc/init.d/mysqldbasedirdatadir修改成本機的路徑

8、cp support-files/my-small.cnf /etc/my.cnf

9、vi /etc/profile新增/application/mysql/bin/

 

/application/mysql//bin/mysqladmin -u root -h mysql1.cn password

載入環境變數,可以加在/etc/profile//usr/local/sbin/

 

如報錯/tmp locaking之類的按如下處理:

chmod -R 4777 /tmp

 

LNMP下的php

apache——-libphp5.so

nginx php———fcgi php-fpm port 9000

 

yum install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel -y

 

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

tar xf libiconv-1.14.tar.gz

cd libiconv-1.14

./configure –prefix=/usr/local/libiconv

make&&make install

 

tar xf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8

./configure

make&&make install

sleep 2

/sbin/ldconfig

cd libltdl/

./configure –enable-ltdl-install

make&&make install

cd ../../

 

tar xf mhash-0.9.9.9.9.tar.gz

cd mhash-0.9.9.9.9

./configure

make&&make install

sleep 2

cd ../

rm -f /usr/lib64/libmcrypt.*

rm -f /usr/lib64/libmhash.*

rm -f /usr/local/lib64/libmcrypt.la /usr/lib64/libmcrypt.la

rm -f /usr/local/lib64/libmcrypt.*so /usr/lib64/libmcrypt.so

rm -f /usr/local/lib64/libmcrypt.*so.4 /usr/lib64/libmcrypt.so.4

rm -f /usr/local/lib64/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8

rm -f /usr/local/lib64/libmhash.a /usr/lib64/libmhash.a

rm -f /usr/local/lib64/libmhash.la /usr/lib64/libmhash.la

rm -f /usr/local/lib64/libmhash.so /usr/lib64/libmhash.so

rm -f /usr/local/lib64/libmhash.so.2 /usr/lib64/libmhash.so.2

rm -f /usr/local/lib64/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1

rm -f /usr/local/lib64/libmcrypt-config /usr/bin/libmcrypt-config

 

tar xf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8/

/sbin/ldconfig

./configure LD_LIBRARY_PATH=/usr/local/lib

make&&make install

cd ../

sleep 2

 

開始安裝php

yum install libxslt* -y

 

./configure

–prefix=/application/php5.3.27

–with-mysql=/application/mysql

–with-iconv-dir=/usr/local/libiconv

–with-freetype-dir

–with-jpeg-dir

–with-png-dir

–with-zlib

–with-libxml-dir=/usr

–enable-xml

–disable-rpath

–enable-safe-mode

–enable-bcmath

–enable-shmop

–enable-sysvsem

–enable-inline-optimization

–with-curl

–with-curlwrappers

–enable-mbregex

–enable-fpm

–enable-mbstring

–with-mcrypt

–with-gd

–enable-gd-native-ttf

–with-openssl

–with-mhash

–enable-pcntl

–enable-sockets

–with-xmlrpc

–enable-zip

–enable-soap

–enable-short-tags

–enable-zend-multibyte

–enable-static

–with-xsl

–with-fpm-user=nginx

–with-fpm-group=nginx

–enable-ftp

會報個錯:

ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/

 

make&&make install

useradd nginx -s /sbin/nologin -M

cp /application/php-5.4.27/php.ini-production /application/php/lib/php.ini

mkdir /app/logs -p

 

apache裡的php是通過模組apxs的方式新增進去的,所以沒有程式不需要啟動,而nginx裡的php是通過fcgi的方式需要程式,埠號為9000,所以得配置php-fpm然後將其啟動,配置如下:

/application/php/etc/下:

cp php-fpm-conf.default  php-fpm-conf

然後vi php-fpm-conf:

pid = /app/logs/php-fpm.pid

error_log = /app/logs/php-fpm.log

log_level = error

rlimit_files = 32768

events.mechanisn = epoll

listen.owner = nginx

listen.group = nginx

pm.max_children = 1024

pm.start_servers = 16

pm.min_spare_servers = 5

pm.max_spare_servers = 20

pm.process-idle_timeout = 15s;

pm.max_requests = 2048

slowlog = /app/logs/$pool.log.slow

request_slowlog_timeout = 10

 

 

/application/php/sbin/php-fpm -t 檢查語法

/application/php/sbin/php-fpm

 

將一下內容加入rc.local

/etc/init.d/mysqld start

/application/php/sbin/php-fpm

/application/nginx/sbin/nginx

 

server {

        listen       80;

        server_name  www.weipeng.com;

 

        #charset koi8-r;

 

        #access_log  logs/host.access.log  main;

 

        location / {

            root   html;

            index  index.php index.html index.htm;

        }

 

        location ~ .*.(php|php5)?$

        {

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            include        fastcgi.conf;

        }

 

/application/php/bin/php php-mysql.php 可對php檔案進行執行。

本文轉自  流顆星  51CTO部落格,原文連結:http://blog.51cto.com/liukexing/1967917


相關文章