NGINX\PHP\MYSQL环境搭建

1、安装包下载

2、配置

  1. PHP
    • 安装版本:php-5.6.22-Win32-VC11-x64
    • 安装路径:D:\php-5.6.22-Win32-VC11-x64
    • 配置文件:
    • enable_dl = On
      cgi.force_redirect = 0
      cgi.fix_pathinfo=1
      fastcgi.impersonate = 1
      cgi.rfc2616_headers = 1
      #扩展包,包括mysql
      extension=php_gd2.dll
      extension=php_mbstring.dll
      extension=php_mysql.dll
      extension=php_mysqli.dll
      extension=php_pdo_mysql.dll
      #debugger 开启需要下对版本
      [Xdebug]
      zend_extension=php_xdebug-2.4.0-5.6-vc11-x86_64.dll
      xdebug.profiler_enable=on  
      xdebug.auto_trace=on  
      xdebug.collect_params=on  
      xdebug.collect_return=on  
      xdebug.show_exception_trace = On  
      xdebug.remote_autostart = On  
      xdebug.remote_enable = On  
      xdebug.remote_host = localhost
      xdebug.remote_port = 9001
      xdebug.collect_vars = On
      xdebug.remote_mode = req
      xdebug.remote_handler = dbgp
      xdebug.idekey = PHPSTORM
      xdebug.profiler_output_dir="d:/web/tmp"
  2. NGINX
    • 安装版本:nginx-1.10.0
    • 安装路径:D:\nginx-1.10.0
    • 配置文件:
      location / {
                  root   D:/web/www;#修改内容
                  index  index.html index.htm;
              }
      
      location ~ \.php$ {
                  root           D:/web/www;#修改内容
                  fastcgi_pass   127.0.0.1:9000;
                  fastcgi_index  index.php;
                  fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;#修改内容
                  include        fastcgi_params;
              }
  3. MYSQL
    • 安装版本:mysql-5.7.12-winx64
    • 安装路径:D:\mysql-5.7.12-winx64
    • 配置文件:
      # For advice on how to change settings please see
      # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
      # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
      # *** default location during install, and will be replaced if you
      # *** upgrade to a newer version of MySQL.
      
       [client]
       default-character-set=utf8
      
      [mysqld]
      character_set_server=utf8
      basedir=D:/mysql-5.7.12-winx64
      datadir=D:/mysql-5.7.12-winx64/data
      tmpdir=D:/mysql-5.7.12-winx64/data
      socket=D:/mysql-5.7.12-winx64/data/mysql.sock
      log-error=D:/mysql-5.7.12-winx64/data/mysql_error.log
      
      max_connections=100
      table_open_cache=256
      query_cache_size=1M
       
      tmp_table_size=32M
      thread_cache_size=8
      port = 3306
      
      innodb_data_home_dir=D:/mysql-5.7.12-winx64/data/
      innodb_flush_log_at_trx_commit =1
      innodb_log_buffer_size=128M
      innodb_buffer_pool_size=128M
      innodb_log_file_size=10M
      innodb_thread_concurrency=16
      innodb-autoextend-increment=1000
      join_buffer_size = 128M
      sort_buffer_size = 32M
      read_rnd_buffer_size = 32M
      max_allowed_packet = 32M
      explicit_defaults_for_timestamp=true
      sql-mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
      
    • WINDOWS服务安装启动:mysqld –defaults-file=my.ini –initialize-insecure#注意initialize
  4. 自动启停脚本
    • 启动脚本:
       @echo off
       REM Windows 下无效
       REM set PHP_FCGI_CHILDREN=5
      
       REM 每个进程处理的最大请求数,或设置为 Windows 环境变量
       set PHP_FCGI_MAX_REQUESTS=1000
      
       echo Starting PHP FastCGI...
       RunHiddenConsole D:/php-5.6.22-Win32-VC11-x64/php-cgi.exe -b 127.0.0.1:9000 -c D:/php-5.6.22-Win32-VC11-x64/php.ini
      
       echo Starting nginx...
       RunHiddenConsole D:/nginx-1.10.0/nginx.exe -p D:/nginx-1.10.0
       
        echo Starting mysqld...
        RunHiddenConsole net start mysql
    • 停止脚本:
      @echo off
       echo Stopping nginx...  
       taskkill /F /IM nginx.exe > nul
       echo Stopping PHP FastCGI...
       taskkill /F /IM php-cgi.exe > nul
       echo Stopping mysqld...
       taskkill /F /IM mysqld.exe > nul
       exit
  5. 测试页面
    • nginx和PHP测试页面:
      <?php
          phpinfo();
      ?>
    • nginx、PHP和MYSQL测试页面:
      <html>
      <head>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
          <title>Welcome to nginx!</title>
      </head>
      <body>
      <?php
      $mysqli = new mysqli("localhost", "root", "Luo008051", "mysql");
      if ($mysqli->connect_errno) {
          echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
      }
      echo $mysqli->host_info . "\n";
      
      $mysqli = new mysqli("127.0.0.1", "root", "Luo008051", "mysql", 3306);
      if ($mysqli->connect_errno) {
          echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
      }
      
      echo $mysqli->host_info . "\n";
      ?>
      </body>
      </html>

《NGINX\PHP\MYSQL环境搭建》有1条留言

留下评论

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

%d 博主赞过: