当前位置: 代码迷 >> PHP >> lnmp源码安装以及容易配置
  详细解决方案

lnmp源码安装以及容易配置

热度:87   发布时间:2016-04-28 16:40:29.0
lnmp源码安装以及简单配置

 nginx 软件:

a: openssl-1.0.1r.tar.gz  tar zxf openssl-1.0.1r.tar.gzb: pcre-8.32.tar.gz  tar zxf openssl-1.0.1r.tar.gz  cd pcre-8.32      ./configure --prefix=/usr/local/lanmp/lib/pcre #安装目录      make && make installc: zlib-1.2.7.tar.gz       tar zxf zlib-1.2.7.tar.gz  cd  zlib-1.2.7      ./configure --prefix=/usr/local/lanmp/lib/zlib #安装目录      make && make installd: nginx-1.8.0.tar.gz  tar zxf nginx-1.8.0.tar.gz      cd nginx      #--user=www-data 指定用户      #--group=www-data 指定用户组      --prefix=/usr/local/lanmp/nginx      --with-http_ssl_module #开启HTTP SSL模块,支持HTTPS请求      --with-openssl=/usr/local/src/openssl-1.0.1r #源码的路径      --with-zlib=/usr/local/src/zlib-1.2.7 #源码的路径      --with-pcre=/usr/local/src/pcre-8.32 #源码的路径      --conf-path=/etc/lanmp/nginx.conf#配置文件路径           make && make install      /usr/local/lanmp/nginx/sbin/nginx #启动nignx,也可加入服务      cp /usr/local/lanmp/nginx/sbin/nginx /etc/init.d/ 

nginx简单配置:

全局:worker_processes  2;#进程数worker_rlimit_nofile 65535;#最多打开文件数events {    use epoll; #事件模型    worker_connections  10240;#每个进程最多连接数}http局:    keepalive_timeout  0;#超时时间    gzip  on; #支持压缩    gzip_buffers 16 8K; #申请内存大小    gzip_comp_level 6;#压缩级别    gzip_min_length 4K;#允许压缩的最小字节数    gzip_types text/html,text/css;#压缩类型    gzip_vary on;#根据http头部来判断是否压缩   server局:        location ~ .*(gif|jpg|png|bmp|swf)$ {#缓存类型           expires 1d; #缓存时间       }

 

 mysql 软件:

mysql-5.6.15.tar.gztar zxf mysql-5.6.15.tar.gzcd mysql-5.6.15#必须安装以下的包,不然cmake会出错yum -y install ncurses-devel 或者 apt-get install libncurses5-dev  cmake . \-DCMAKE_INSTALL_PREFIX=/usr/local/lanmp/mysql \ -DMYSQL_DATADIR=/usr/local/lanmp/mysql/data \ #数据库存放路径-DSYSCONFDIR=/etc/lanmp/mysql \ #conf路径-DWITH_MYISAM_STORAGE_ENGINE=1 \ #MYISAM引擎支持-DWITH_INNOBASE_STORAGE_ENGINE=1 \#INNODB引擎支持-DWITH_MEMORY_STORAGE_ENGINE=1 \#MEMORY引擎支持-DWITH_READLINE=1 \-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \-DMYSQL_TCP_PORT=3306 \-DENABLED_LOCAL_INFILE=1 \#允许从本地导入数据-DWITH_PARTITION_STORAGE_ENGINE=1 \#分区支持-DEXTRA_CHARSETS=all \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci #字符集make && make installgroupadd mysql #建一个mysql用户组useradd -r -g mysql mysql #建一个mysql用户,属于mysql用户组,并且该用户不在登录界面显示(-r参数的作用)chown -R mysql:mysql /usr/local/lanmp/mysqlcd/usr/local/lanmp/mysql/scripts./mysql_install_db --user=mysql --basedir=/usr/local/lanmp/mysql --datadir=/usr/local/lanmp/mysql #初始化安装cd /usr/local/lanmp/mysql/support-files#注册服务cp mysql.server /etc/init.d/mysqld#使用默认配置文件cp my-default.cnf /etc/lanmp/mysql/my.cnf#启动service mysqld start/usr/local/lanmp/mysql/bin/mysqladmin -u root password "123456" #设置密码

mysql简单配置:

innodb_buffer_pool_size = 128Mport = 3306server_id = 1socket = /var/lib/mysql/mysql.sockback_log = 384key_buffer_size = 128Mmax_connections = 500thread_concurrency = 2

 

 php 软件:

a: freetype-2.4.10.tarb: jpegsrc.v8b.tar.gzc: libpng-1.5.14.tar.gzd: libxml2-2.9.0.tar.gze: libiconv-1.7.tar.gz同样是解压并安装/usr/local/lanmp/lib/下f: php-7.0.3.tar.gz    tar zxf php-7.0.3.tar.gz    cd php-7.0.3    ./configure --prefix=/usr/local/lanmp/fcgphp    --with-config-file-path=/etc/lanmp/fcgphp.ini    --with-mysqli=/usr/local/lanmp/mysql/bin/mysql_config #mysqli    --enable-mbstring    --with-freetype-dir=/usr/local/lanmp/lib/freetype    --with-jpeg-dir=/usr/local/lanmp/lib/libjpeg #jpg    --with-png-dir=/usr/local/lanmp/lib/libpng  #png    --with-zlib-dir=/usr/local/lanmp/lib/zlib    --with-libxml-dir=/usr/local/lanmp/lib/libxml    --enable-xml #xml支持    --with-iconv-dir=/usr/local/lanmp/lib/libiconv#字符集转换支持    --enable-fpm #支持fcgi方式    --with-pdo-mysql=/usr/local/lanmp/mysql#pdo支持   #--with-apxs2=/usr/local/lanmp/apache2/bin/apxs#apache模块   make && make install   cp php.ini-development /etc/lanmp/fcgphp.ini

  cd /usr/local/lanmp/fcgphp/etc/php-fpm.d/
  cp www.conf.default www.conf #配置
  #启动
/usr/local/lanmp/fcgphp/sbin/php-fpm

php-fpm配置参数

pm = dynamic #进程方式,static为静态pm.max_children = 300 #最大进程数pm.start_servers = 20 #启动时创建的进程pm.min_spare_servers = 5 #最小进程数pm.max_spare_servers = 35 #空闲最大进程数