zoukankan      html  css  js  c++  java
  • CentOS6.5 LNMP环境搭建

    本文章为个人笔记,参考自原文

    1.安装必备工具

    yum -y install make gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap lsof
    

    2.安装php依赖关系

    安装libiconv
    cd /usr/local/src
    wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
    tar -zxvf libiconv-1.14.tar.gz
    cd libiconv-1.14
    ./configure --prefix=/usr/local/libiconv
    make && make install
    cd ..
    
    #wget安装 yum -y install wget
    
    安装libmcrypt
    wget http://iweb.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
    tar -zxvf libmcrypt-2.5.8.tar.gz
    cd libmcrypt-2.5.8
    ./configure
    make && make install
    cd ..
    
    安装 Mhash 下载并安装mbash

    网址:http://mhash.sourceforge.net/

    tar -zxvf mhash-0.9.9.9.tar.gz
    ./configure
    make && make install
    cd ..
    
    安装Mcrypt
    wget http://iweb.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
    tar zxvf mcrypt-2.6.8.tar.gz
    cd mcrypt-2.6.8
    #注意一下这步运行下,不然下面可能报错
    export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
    ./configure
    make && make install
    cd ..
    编译mcrypt可能会报错:configure: error: *** libmcrypt was not found
    vi  /etc/ld.so.conf
    最后一行添加
    /usr/local/lib/
    保存并退出::wq!
    执行载入命令:
    ldconfig
    

    3.安装mysql 5.6

    下载地址

    解压mysql-5.6.44.tar.gz 进入解压目录
    
    cmake 
    -DCMAKE_INSTALL_PREFIX=/usr/local/mysql 
    -DMYSQL_DATADIR=/usr/local/mysql/data 
    -DSYSCONFDIR=/etc 
    -DWITH_MYISAM_STORAGE_ENGINE=1 
    -DWITH_INNOBASE_STORAGE_ENGINE=1 
    -DWITH_MEMORY_STORAGE_ENGINE=1 
    -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 
    -DMYSQL_USER=mysql 
    -DWITH_DEBUG=0 
    -DWITH_SSL=system
    
    make && make install
    
    到这里mysql5.6.17就安装好了,接下来就是配置一些mysql相关的东西:
    
    3.修改/usr/local/mysql权限
    chmod +w /usr/local/mysql
    chown -R mysql:mysql /usr/local/mysql
    
    
    /usr/local/mysql/support-files
    
    
    /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
    

    4.安装nginx1.7

    nginx所需的依赖关系,一般我们都需要先装pcre, zlib,前者为了重写rewrite,后者为了gzip压缩。如果系统已经yum 安装了这些库也没关系,无需卸载。直接编译安装最新的就可以了。为了一次性完成编译,先准备编译下面的依赖关系!

    安装PCRE库
    wget http://ncu.dl.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.gz
    tar -zxvf pcre-8.39.tar.gz
    cd pcre-8.39
    ./configure
    make && make install
    
    安装zlib库
    wget http://zlib.net/zlib-1.2.8.tar.gz
    tar -zxvf zlib-1.2.8.tar.gz
    cd zlib-1.2.8
    ./configure
    make && make install
    
    安装openssl
    wget http://www.openssl.org/source/openssl-1.0.1g.tar.gz
    tar -zxvf openssl-1.0.1g.tar.gz
    cd openssl-1.0.1g
    ./config
    make && make install
    
    安装nginx

    准备工作完成,现在开始安装nginx!,这里添加了前面准备的库关系,注意路径!

    wget http://nginx.org/download/nginx-1.9.9.tar.gz
    tar -zxvf nginx-1.9.9.tar.gz
    cd nginx-1.9.9
    ./configure 
    --user=www 
    --group=www 
    --prefix=/usr/local/vanlon/nginx 
    --with-http_stub_status_module 
    --with-http_ssl_module 
    --with-http_gzip_static_module 
    --with-pcre=/usr/local/src/pcre-8.39 
    --with-zlib=/usr/local/src/zlib-1.2.8 
    --with-openssl=/usr/local/src/openssl-1.0.1g 
    --add-module=../nginx_mod_h264_streaming-2.2.7
    --add-module=../nginx-rtmp-module
    
    make && make install
    
    useradd -M -s /sbin/nologin nginx
    
    #修改nginx配置文件
    vim nginx.conf
    把#user nobody 改成 user nginx;
    #测试一下nginx配置文件
    /usr/local/nginx/sbin/nginx -t
    #启动nginx
    /usr/local/nginx/sbin/nginx
    #一般来说在nginx的配置文件修改后进行如下操作,
    /usr/local/nginx/sbin/nginx -t检测一下配置文件是否正确,如果正确的话
    再使用/usr/local/nginx/sbin/nginx -s reload 使nginx平滑启动
    

    5.安装php5.6.31

    安装php
    wget http://mirrors.sohu.com/php/php-5.6.6.tar.gz
    tar -zxvf php-5.6.6.tar.gz
    cd php-5.6.6
    
    ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath  --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts
    
    make test
    make && make install
    
    配置php开机启动
    2.修改fpm配置php-fpm.conf.default文件名称
    mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
    3.复制php.ini配置文件
    cp php.ini-production /usr/local/php/etc/php.ini
    4.复制php-fpm启动脚本到init.d
    cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
    5.赋予执行权限
    chmod +x /etc/init.d/php-fpm
    6.添加为启动项
    chkconfig --add php-fpm
    7.设置开机启动
    chkconfig php-fpm on
    8.按照标准,给php-fpm创建一个指定的用户和组
    创建群组:groupadd www
    创建一个用户,不允许登陆和不创主目录 :useradd -s /sbin/nologin -g www -M www
    9.立即启动php-fpm
    service php-fpm start
    #或者
    /etc/init.d/php-fpm start
    
    配置nginx
    修改nginx配置文件使之支持php
    vim /usr/local/nginx/conf/nginx.conf
    找到下面的这段,把其
    #location ~ .php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}
    修改为
    location ~ .php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
    修改完配置之后
    测试一下是否有错:/usr/local/nginx/sbin/nginx -t
    平滑重启:/usr/local/nginx/sbin/nginx -s reload
    
  • 相关阅读:
    数据库表结构变动发邮件脚本
    .net程序打包部署
    无法登陆GitHub解决方法
    netbeans 打包生成 jar
    第一次值班
    RHEL6 纯命令行文本界面下安装桌面
    C语言中格式化输出,四舍五入类型问题
    I'm up to my ears
    How to boot ubuntu in text mode instead of graphical(X) mode
    the IP routing table under linux@school
  • 原文地址:https://www.cnblogs.com/dch0/p/11169505.html
Copyright © 2011-2022 走看看