• [Linux]CentOS7搭建Nginx + MySQL + PHP


    -------------------------------------------------------------------------------------

    Nginx安装参考地址:http://www.cnblogs.com/farwish/p/3807289.html

    RPM安装MySQL:
    wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
    rpm -ivh mysql-community-release-el7-5.noarch.rpm
    yum install -y mysql-community-server

    成功安装之后重启mysql服务:

      service mysqld restart 或 systemctl restart mysqld.service

    初次安装mysql是root账户是没有密码的:

      mysql -u root -p   遇到密码提示,回车即可进入

    设置root密码的方法:

       mysqladmin -u root password "root"
     
    进入mysql:
      mysql -u root -p
      Enter Password: root
     
    设置mysql最大连接数:
      执行sql:set global max_connections = 3000; (重启mysql后失效) 
     
    ----------------------------------------------------------------------------------------
     

    PHP源码安装:

      1. 下载源码包并解压:

    wget http://cn2.php.net/distributions/php-5.6.3.tar.gz
     
    tar zxvf php-5.6.3.tar.gz
     
    cd php-5.6.3

      2. 安装依赖:

      这些依赖有libxml, libpng, libjpeg, libmcrypt...等

      根据提示进行操作,如:yum install libxml2 按Tab键查看所有libxml包,我这里安装 yum install libxml2-devel,然后进行配置。

      

      注:libmcrypt不在centos的网络yum仓库中,需要自行下载。

      (  一. 源码安装方法:

        cd /usr/local/src

        wget http://softlayer.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gz

        tar -zxvf libmcrypt-2.5.8.tar.gz

        cd /usr/local/src/libmcrypt-2.5.8

        ./configure --prefix=/usr/local

        make && make install

        

          二. 使用第三方yum源
        下载:

    wget http://www.atomicorp.com/installers/atomic
    sh ./atomic

        yum命令安装:

    yum  install  php-mcrypt  libmcrypt  libmcrypt-devel

       )

      gd中的一些函数依赖freetype, 需要安装:

        wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.gz

        ./configure --prefix=/usr/local/freetype/

        make && make install

      或:yum install -y freetype-devel   

      其他:

      yum install -y curl curl-devel libjpeg libjpeg-devel libpng libpng-devel

      3. 配置: 

    ./configure --with-libdir=lib64 --prefix=/usr/local/php --with-mysql --with-mysqli --with-pdo-mysql --enable-inline-optimization --enable-fpm --with-freetype-dir --with-gd --with-zlib --with-png-dir --with-jpeg-dir --enable-mbstring --with-iconv --enable-sockets --with-curl --with-mcrypt --with-openssl --enable-pcntl --enable-soap

      4. 编译安装:

      make && make install

      复制一份php的配置文件,新建一个: 

    cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
    cd /home/weichen/php-5.6.3
    cp php.ini-production /usr/local/php/lib/php.ini
      5. 启动php:
    /usr/local/php/sbin/php-fpm  (注意:需要root权限进行操作)
      查看进程:
      ps aux | grep php
     
      修改网站根目录:  
    vim /usr/local/nginx/conf/nginx.conf
      将
      location / {
                root   html;
                index  index.php index.html index.htm;
            }
      改为 
    location / {
          root   /home/www;
          index  index.php index.html index.htm;
    }
      此处的目录地址也需要修改对:  
    location ~ .php$ {
          root           /home/www;
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;
          fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
          include        fastcgi_params;
    }

    CentOS平台自动安装脚本:https://github.com/farwish/delicateShell

    Docker构建LNMP运行环境:https://github.com/phvia/dkc

  • 相关阅读:
    NYOJ458
    NYOJ67
    NYOJ105
    NYOJ1071
    NYOJ463
    C语言练字用小软件 — Practise_Calligraphy_1.0(ANSI)
    NYOJ276
    NYOJ455
    NYOJ74
    Jzoj4458 密钥破解——Pollard-rho
  • 原文地址:https://www.cnblogs.com/farwish/p/4161417.html
Copyright © 2020-2023  润新知