centos6.7下编译安装lnmp

很多步骤不说明了,请参照本人的centos6.7下编译安装lamp,这次的架构是nginx+php-fpm一台服务器,mysql一台服务器

(1)首先编译安装nginx:

操作命令: yum -y groupinstall "Development Tools" "Server Platform Development"

      yum -y install pcre-devel

      useradd -r nginx  

      mkdir /var/tmp/nginx   事先得创建此目录,不然启动nginx时会报错

      tar xf nginx-1.8.1.tar.gz

      cd nginx-1.8.1

 

./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx

--error-log-path=/var/log/nginx/error.log  --conf-path=/etc/nginx/nginx.conf

--http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --

user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --http-

client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-

path=/var/tmp/nginx/fcgi/ --with-pcre       

 

make && make install

 

echo "export PATH=/usr/local/nginx/sbin:$PATH" > /etc/profile.d/nginx.sh

exec bash

 

(2) 编译安装php:

操作命令: yum -y install libxml2-devel   bzip2-devel   libjpeg-devel    libpng-devel    freetype-devel     libcurl-devel

libmcrypt-devel(此包在epel源中) 

tar xf php-5.4.40.tar.bz2  cd php-5.4.40

 

./configure --prefix=/usr/local/php --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --

with-openssl --enable-fpm --enable-sockets --enable-sysvshm --enable-mbstring --with-freetype-dir --with-jpeg-dir -

-with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml --with-mhash --with-mcrypt --with-config-file-

path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-curl

 

make && make install       make test

 

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

cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm

chmod +x /etc/rc.d/init.d/php-fpm

chkconfig --add php-fpm

chkconfig php-fpm on

 

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf   为php-fpm提供配置文件

vim /usr/local/php/etc/php-fpm.conf

pm.max_children = 150      最大进程数(根据压测进行调试)

pm.start_servers = 8

pm.min_spare_servers = 5

pm.max_spare_servers = 10

user=nginx

group=nginx

 

(3)整合nginx和php5

vim /etc/nginx/nginx.conf

centos6.7下编译安装lnmp_第1张图片

 

$fastcgi_script_name   代表请求的uri      映射关系为  www.$$$.com/index.php --> /use/local/nginx/html/index.php

fastcgi_params  映射到此文件/etc/nginx/fastcgi_params

 

MySQL的编译安装在编译lamp博文中已经介绍了,此处不叙述

 

使用fastcgi_cache 模块添加缓存功能

  在http上下文中添加下面选项:

centos6.7下编译安装lnmp_第2张图片

 

 

为php添加加速器:

  tar xf xcache-3.2.0.tar.bz2    cd xcache-3.2.0

    /usr/local/php/bin/phpize  ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config

  make && make install   mkdir /etc/php.d    cp xcache.ini /etc/php.d/

   service php-fpm restart

 

查看各软件编译时的参数:

php:php -r "phpinfo();" | grep configure

nginx: nginx -V

apache: cat /usr/local/httpd/build/config.nice

mysql: cat /usr/local/mysql/bin/mysqlbug | grep CONFIGURE_LINE

 

转载于:https://www.cnblogs.com/linuxboke/p/5457204.html

你可能感兴趣的:(运维,php,数据库)