LNMP组合详解与实战

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LNMP组合详解与实战相关的知识,希望对你有一定的参考价值。

二进制包才可以直接安装,普通包只能编译安装。

采用二进制包安装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文件进行执行。


以上是关于LNMP组合详解与实战的主要内容,如果未能解决你的问题,请参考以下文章

LNMP架构详解

lnmp 一键安装详解

OpenCV实战——图像运算详解

OpenCV实战——图像运算详解

服务器硬件及RAID配置实战

LNMP架构搭建Discuz论坛(实战!)