Nginx WIN7下安装PHP的MySQL

 

步骤:

  1.      1、安装NGINX for win
  2.      2、安装PHP for win
  3.      3、安装MYSQL for win
    1.      4、安装PHPADMIN

 

下载最新的稳定的nginx的版本 。

nginx的配置和运行

将Nginx配置成WINDOWS服务:

下载WINSW,建立winsw.xml,并输入内容如下:

 

02  nginx 

03  nginx 

04  nginx 

05  c:/nginx/nginx.exe 

06  c:/nginx/ 

07  roll 

08   

09  -p c:/nginx 

10  -p c:/nginx -s stop 

11

运行后将会在WINDOWS服务列表中找到NGINX服务项,将服务设置成自动启动。

修改Nginx配置文件,路径名称C:/nginx/conf:

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset gbk;

        #access_log  logs/host.access.log  main;

        location / {
            root   E:/www;
            index  index.html index.htm;
            autoindex on;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ /.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}                
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  
        #  这里是重点啦,要小心一下要把文件解注释掉     
        #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;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ //.ht {
        #    deny  all;
        #}
    }

    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

尝试加载输入测试网页在浏览器中:

http://localhost

 

如果你看到它,你的安装成功。如需将Nginx配置负载均衡和反向代理,请参考其它资料,本文不作详述。

Nginx的配置PHP

下载PHP最新版本,放置c:/php

一、

首先打开php.ini(修php.ini-development) 找到:
;extension=php_mysql.dll
将前面的 ; 号去掉, 改成:
extension=php_mysql.dll
找到:
extension_dir = “./”
将其改为你的 php 安装目录下 ext 子目录的绝对路径。例如我的:
extension_dir = “D:/php/ext/”
这步很重要 。否则接下来 php 会找不到 php_mysql.dll 模块,无法装载。

指定docroot——php文件的存放目录,即你的documentroot。doc_root = “e:/www”

扩展存放目录 extension_dir——更改为真实的扩展存放地址。extension_dir = “./ext”

默认时区更改——在[Date]里面增加:date.timezone = Asia/ChongQing

因为nginx需要的是cgi方式的php,所以如下几个地方是重点,否则nginx无法打开php文件

enable_dl = On
cgi.force_redirect = 0
cgi.fix_pathinfo=1
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1

如果你使用MySQL,那么和我一样拷贝php5ts.dll和libmysql.dll(开启MYSQL)至C:/WINDOWS/system32下面。并且拷贝php.ini至C:/WINDOWS目录下。

启动PHP:

php的启动因为要使用cgi方式,所以有些特殊。我参照网上的方法下载了RunHiddenConsole.exe,使用该工具用其执行的cmd窗口会自动关闭,否则你看一个CMD窗口一直在那晃来晃去,头会晕的。

创建start_php.bat,来启动php,文件内容如下:

@echo off
echo Starting PHP FastCGI...
RunHiddenConsole.exe d:/php/php-cgi.exe -b 127.0.0.1:9000 -c d:/php/php.ini

创建stop_nginx.bat,来关闭php和nginx进程,文件内容如下:

@echo off
echo Stopping nginx...
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
exit

安装了mysql后,phpinfo查看没有mysql的话,需要将libmysql.dll拷贝一份至C:/WINDOWS/system32下面即可!

下载MYSQL最新版本

 

1、修改MySQL下面自带的ini文件。

修改D:/mysql-5.0.37-win32/my-small.ini文件内容,添加红色内容

[client]
#password = your_password
port  = 3306
socket  = /tmp/mysql.sock
default-character-set=gbk

[mysqld]
port  = 3306
socket  = /tmp/mysql.sock
default-character-set=gbk
skip-locking
key_buffer = 16K
max_allowed_packet = 1M
table_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K

修改完成后保存即可。

2、安装mysql服务
从MS-DOS窗口进入目录E:/myserver/mysql-5.0.37-win32/bin,运行如下命令:
mysqld --install mysql5 --defaults-file=E:/myserver/mysql-5.0.37-win32/my-small.ini

3、启动mysql数据库
还在上面的命令窗口里面,输入命令:net start mysql5
这样就启动了mysql服务。

4、(本地)登录mysql数据库
还在上面的命令窗口里面,输入命令:mysql -u root -p
回车后提示输入密码。
mysql解压缩版初次安装管理员root的密码为空,因此直接再回车一次就登入mysql数据库了。

5、(远程)登录mysql数据库

如果你不是初次登录mysql,你还拥有网络地址的用户,那么你可以用如下命令登录到mysql服务器,这个mysql服务器也许在远方,也许在本地。这种登录方式叫“远程登录”,命令如下:

mysql -h 192.168.3.143 -u root -p
mysql -h 192.168.3.143 -u root -pleizhimin

-h是指定登录ip,-u指定用户,-p指定密码,-p后如果什么都不写,那么接下来会提示输入密码,-p后也可以直接写上密码,这样就不再需要输入密码了。

6、操作数据库和表
登录mysql数据库后,就可以执行指定操作数据库,用命令:use 数据库名
指定了操作的数据库对象后,就可以操作数据库中的表了,操作方法当然是SQL命令了,呵呵。

7、更改mysql数据库管理员root的密码
mysql数据库中默认有个mysql数据库,这个是mysql系统的数据库,用来保存数据库用户、权限等等很多信息。要更改密码,就要操作mysql数据库的user表。

现在mysql的root用户密码还为空,很不安全的,假设要更改密码为“leizhimin”。

还在上面的命令窗口里面,执行如下命令:
use mysql;
grant all on *.* to root@'%' identified by 'ttbug' with grant option;
commit;

这段命令的含义是,添加一个root用户,拥有所有的权限,密码为“ttbug”,并且这个用户不但可以本地访问,也可以通过网络访问。强调这个原因是mysql系统自带的的那个root用户只能从本地访问,它@字符后面的标识是localhost。具体可以查看mysql数据的uer表看看,这样以来,就有两个root用户了,一个是系统原来的,一个新建的,为了管理的方便,就将mysql自带root删除,保留刚创建的这个root用户,原因是这个用户可以通过网络访问mysql。

然后,删除用户的命令:
use mysql
delete from user where user='root' and host='localhost';
commit;

其实上面的方法是授权命令,在授权的同时创建了数据库用户。mysql也有单独的修改用户密码的方法,下面看看如何操作。

首先,先建立一个用户ttbug,密码为:123456

grant all on *.* to ttbug@'localhost' identified by '123456' with grant  option;

接下来就修改这个用户的密码为:012345

update user set password = password('012345') where user = 'ttbug' and host='localhost';
flush privileges;

说明一点,最好用grant的方式创建mysql用户,尤其对mysql DBA来说,创建用户的同时要指定用户权限,养成好习惯很重要的。

这个修改方法实际上用的是mysql函数来进行的,还有更多的方法,我就不一一介绍了。

还要注意一点就是在修改密码等操作的时候,mysql不允许为表指定别名,但是初次在外却没有这个限制。

8、创建数据库
实际上mysql数据库中除了mysql数据库外,还有一个空的数据库test,供用户测试使用。

现在继续创建一个数据库testdb,并执行一系列sql语句看看mysql数据库的基本操作。

创建数据库testdb:

create database testdb;

预防性创建数据库:

create database if not testdb

创建表:

use testdb;
create table table1(
username varchar(12),
password varchar(20));

预防性创建表aaa:

create table if not exists aaa(ss varchar(20));

查看表结构:

describe table1;

插入数据到表table1:
insert into table1(username,password) values
('leizhimin','lavasoft'),
('hellokitty','hahhahah');

commit;

查询表table1:
select * from table1;

更改数据:

update table1 set password='hehe' where username='hellokitty';
commit;

删除数据:

delete from  table1 where username='hellokitty';
commit;

给表添加一列:

alter table table1 add column(
  sex varchar(2) comment '性别',
  age date not null comment '年龄'
);
commit;

从查询创建一个表table1:

create table tmp as

select * from table1;

删除表table1:

drop table if exists table1;

drop table if exists tmp;

9、备份数据库testdb

mysqldump -h 192.168.3.143 -u root -pleizhimin -x --default-character-set=gbk >C:/testdb.sql

10、删除数据库testdb

drop database testdb;

11、恢复testdb数据库

首先先建立testdb数据库,然后用下面命令进行本地恢复:

mysql -u root -pleizhimin testdb

12、删除mysql服务
假如你厌倦mysql了,你需要卸载,那么你只需要这么做

停止mysql服务
net stop mysql5

删除mysql服务
sc delete mysql5

然后删除msyql的安装文件夹,不留任何痕迹。

呵呵,现在看来还是oninstall(非安装解压缩)版的mysql好,绿色环保。
好了,不说了,相信你已经掌握mysql的基本操作了。

 

PHP将在FastCGI的运行模式,nginx的不支持CGI只支持FastCGI这一种模式。

没有什么损失,但由于这种体制更灵活。为了做到这一点,你需要编辑配置文件在C:/ nginx的/机密/ nginx.conf。

  1. Open the file in WordPad.在写字板中打开文件。 The configuration file is in UNIX text file format, so you will have a problem with it in Notepad.配置文件是UNIX文本文件格式,所以你将与它在记事本的问题。 Once you save it in WordPad, you may open the file in Notepad because the process converts the file format to native Windows.一旦你保存在写字板中,你可以用记事本打开文件,因为该进程的文件格式转换到本机Windows。 Just make sure you open and save the file as text instead of Rich Text Format (RTF).只需确保您打开并保存为文本,而不是RTF格式(RTF)文件。
  2. Scroll down to the location that says pass the PHP scripts to FastCGI server listening on … .向下的位置,指出通过PHP脚本的FastCGI服务器侦听...。 Remove the hash signs ('#') for that block and modify it to read as follow before saving.删除该块('#')哈希标志和修改阅读如下保存前。
 location ~ /.php$ {位置〜/。PHP的$( 
root html ;根的HTML;
fastcgi_pass 127.0.0.1: 10000 ; fastcgi_pass 127.0.0.1:10000;
fastcgi_index index.php ; fastcgi_index编辑;
fastcgi_param SCRIPT_FILENAME /nginx/html$fastcgi_script_name ; fastcgi_param设为SCRIPT_FILENAME / nginx的/的HTML $ fastcgi_script_name;
include fastcgi_params ;包括fastcgi_params;
} )

You also have to tell nginx to look for index.php in a directory as default file.您还必须告诉nginx的以维基看待作为默认的文件目录。 Look for the root location block and add index.php so it looks like the following.查询根位置块和编辑 ,所以添加类似以下。

 location / {位置/( 
root /nginx/html ;根/ nginx的/的HTML;
index index.php index.html index.htm ;指数编辑index.html index.htm;
} )

This is important to avoid having to enter full path to a PHP file or getting the 403 permission denied message ( http://localhost/wp-admin/ works instead of only http://localhost/wp-admin/index.php . You also need to modify root to full path, but omitting the drive letter.这一点很重要,以避免不必输入完整路径的PHP文件,或取得403权限被拒绝的消息(http://localhost/wp-admin/工厂,而不是只http://localhost/wp-admin/index.php。您还需要修改根目录的完整路径,但省略了驱动器号。

Running and Stopping nginx, MySQL and PHP FastCGI with Batch File运行和停止同批次nginx的,MySQL和PHP FastCGI的文件

In previous section, you have tested Engine X, and if that works you are now ready for this step.在上一节中,你可以先测试发动机十,并且该工程你现在这一步做好准备。 The WEMP system consists of three main server components.该WEMP系统由三个主要的服务器组件。 To start and stop them can be a problem if you are constantly testing for different configuration.要启动和停止他们可能是一个问题,如果你不断地为不同的配置测试。

By editing the batch file used to start nginx so it starts and stops all the servers as well, you save some time.通过编辑批处理文件用于启动nginx的,所以启动和停止所有服务器内,都节省时间。 It is also flexible enough that you may stop it immediately as you finish with your work and need to free more memory for other things.它还足够灵活,你可以立即停止你完成你的工作,需要释放更多的内存,其他的事情。

While it is possible to run MySQL as Windows server, I prefer the batch script executable approach for the above reason.虽然有可能作为Windows服务器上运行MySQL的,我更喜欢批处理脚本,因上述原因可执行文件的方法。

Here is the content of start-nginx.bat after editing:这里是开始内容编辑后nginx.bat:

 1 1 
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
 @ECHO OFF @艾关 
ECHO Starting PHP FastCGI...艾启动PHP的FastCGI的...
RunHiddenConsole.exe C:/Program Files/PHP/php-cgi.exe -b 127.0.0.1:10000 RunHiddenConsole.exe荤:/ Program Files文件/ PHP中/ PHP的cgi.exe - b 127.0.0.1:10000
ECHO Starting nginx...艾启动nginx的...
c:/nginx/nginx.exe ç:/ nginx的/ nginx.exe
ECHO Starting MySQL...艾启动MySQL ...
RunHiddenConsole.exe "C:/Program Files/MySQL/MySQL Server 5.0/bin/mysqld-nt" --defaults-file="C:/Program Files/MySQL/MySQL Server 5.0/my.ini" RunHiddenConsole.exe的“C:/ Program Files文件/ MySQL / MySQL服务器5.0 /容器/ mysqld -新台币” -默认文件=的“C:/ Program Files文件/ MySQL / MySQL服务器5.0 / my.ini文件”
SLEEP 1睡眠1
EXIT退出

Copy and paste the text above and overwrite the start-nginx.bat in C:/nginx/conf .复制并粘贴上面的文本并覆盖开始nginx.bat在C:/ nginx的/机密 。 Alternatively download start-nginx.bat here.或者下载启动nginx.bat这里。

The script to stop nginx, mysqld and php-cgi is stop-nginx.bat .该脚本停止nginx的时,mysqld和PHP,CGI已经站nginx.bat。 You also need to overwrite this one or edit existing one from nginx.您还需要覆盖此一个或编辑现有的Nginx的之一。

 1 1 
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
 @ECHO OFF @艾关 
ECHO Stopping MySQL...艾停止MySQL ...
process -k mysqld-nt.exe >nul过程亩mysqld - nt.exe“nul
ECHO Stopping nginx...艾停止nginx的...
process -k nginx.exe >nul过程亩nginx.exe“nul
process -k nginx.exe >nul过程亩nginx.exe“nul
process -k nginx.exe >nul过程亩nginx.exe“nul
process -k nginx.exe >nul过程亩nginx.exe“nul
ECHO Stopping PHP FastCGI...艾停止PHP的FastCGI的...
process -k php-cgi.exe >nul过程亩的PHP cgi.exe“nul
SLEEP 1睡眠1
EXIT退出

Again copy, paste and overwrite the file with the text above or download stop-nginx.bat here.再次复制,粘贴并覆盖上述或下载停止文本,nginx.bat这里的文件。

With those scripts, you will be able to run and stop nginx, myslqd and php-cgi from one place.有了这些脚本,您将能够运行和停止nginx的,myslqd和PHP,从一个地方的CGI。

Don't run the batch file yet.不要运行该批处理文件还。 You need to install PHP and MYSQL first… which the following steps are exactly about.您需要安装PHP和MySQL第一...,以下步骤是完全对。

Installing PHP on Windows在Windows上安装PHP

PHP installation is pretty simple. PHP的安装非常简单。 Just go to PHP download page and download PHP xxx installer.只要到PHP下载页面和下载安装PHP的三十。 The PHP version used for this demonstration is 5.2.6. PHP的版本此演示使用的是5.2.6。

Run the installer executable program, and choose Other CGI when asked for the type of server you will be running.运行安装可执行程序,并选择其他CGI时,您的服务器将运行类型的要求。 As we are going to run PHP independently in FastCGI mode, that is the option you should choose.由于我们要运行PHP的FastCGI的模式下独立工作,这是你应该选择的选项。

You should seriously consider adding PHP path to your system PATH variable so you can enter php or php-cgi command from any directory in the command prompt to run PHP.你应该认真考虑加入PHP的路径系统路径变量,以便您可以输入PHPPHP的任何命令的目录中的CGI命令提示符下运行PHP。

While you can choose the whole extensions, I recommend against it.虽然您可以选择整个扩展,我建议反对。 You can always run the installation package again to add extensions later as you need them.您可以随时运行安装程序包再次添加扩展后,你需要他们。

For now, here are the list of PHP extensions you should seriously consider:现在,这里是PHP扩展你应该认真考虑名单:

  • Curl柯尔
  • GD2 GD2的
  • MySQL MySQL的

Then proceed with the installation.然后继续安装。 By default PHP will be installed in C:/Program Files/PHP .默认情况下,PHP将被安装在C:/ Program Files文件/ PHP中

Running PHP in FastCGI Mode Under Windows运行中的FastCGI模式下Windows的PHP

Some people use third party program, such as Spawn-CGI.exe from lighttpd package, but I can't seem to get it running.有些人使用,如菌种,CGI.exe第三方程序,从lighttpd软件包,但我似乎无法得到它运行。 However, it is not necessary either.然而,这不是必要。

php-cgi.exe now runs well in FastCGI mode without any third party software. PHP的cgi.exe现在的FastCGI模式运行良好,没有任何第三方软件。 Open a command prompt window and run php-cgi -h to see full options.打开一个命令提示符窗口并运行 php - cgi的- h来查看选项。

Making php-cgi to listen to a : pair is easy. 使 PHP - cgi的收听到主机>:<端口对很容易。 The following command will do it.下面的命令将这样做。

php-cgi -b 127.0.0.1:10000

The line instructs php-cgi to bind to localhost, which has an IP of 127.0.0.1 — it is inaccessible outside of your machine — and on port 10,000.该生产线指示的PHP的CGI绑定到本地主机,它是127.0.0.1的IP -它是无法对您的计算机外部-在端口10000。 This has to match the nginx configuration above.这匹配Nginx的配置上面。

Now it is much more convenient if you are able to run this without opening a command prompt, isn't it?现在是方便多了,如果你能运行没有打开命令提示符这一点,是不是? Here is a solution.这里是一个解决办法。

If you want to get rid of the command prompt window when php-cgi is running, you should download RunHiddenConsole.zip and unzip the executable file in C:/nginx/conf.如果你想清除的命令提示符窗口当PHP,CGI已经运行,你应该下载RunHiddenConsole.zip并解压缩的可执行文件在C:/ nginx的/机密。 This program will execute php-cgi, run it in the background but hide the command prompt window so it doesn't clutter your desktop.该计划将执行的PHP的CGI,在后台运行,但它隐藏命令提示符窗口,所以不会干扰您的桌面。 (You will use it twice to run php-cgi and mysqld — the latter if you choose not to run it as a Windows service). (您将使用它两次,运行php - cgi和mysqld -后者如果您选择不运行作为Windows服务)。

Installing MySQL on Windows在Windows上安装MySQL

MySQL is the database engine used by WordPress and countless other database-powered applications. MySQL的数据库引擎是由WordPress和不计其数的其他数据库用于供电的应用。 That sounds more complex than the above two programs, but really it is the most simple to install of all.这听起来比上述两个程序复杂,但实际上是最简单的安装所有。

All you have to do is answer questions and choose the right options.你所要做的就是回答问题,并选择正确的选项。 This is unlike nginx and PHP installations above.这不像nginx的和PHP安装以上。

Now you can relax… all the hard work has been done so far.现在您可以放松...所有的辛勤工作已经完成至今。

First off, you need to download a version of MySQL for Windows .首先,你需要下载一个MySQL的的Windows版本。 If you've never installed this before, the easiest way is to download a package with executable setup file.如果您以前从未安装此之前,最简单的方法就是下载的可执行安装文件包。

For demonstration purpose, it would be Windows Essential (x86) .为了演示的目的,这将是基本的Windows(x86)的

Save to your desktop and run it once download is finished.保存到您的桌面,运行一次下载完成。 Let's go through the entire installation process step by step.让我们完成整个安装循序渐进的过程。

First, pick Typical installation option.首先,选择典型安装选项。

This will install the MySQL server and client programs but not the C include files.这将安装MySQL服务器和客户程序而不是在C包含文件。 You don't need them unless you are developing an application that uses MySQL as the database backend.你不需要它们,除非你正在开发应用程序使用MySQL作为后台数据库。

Once the files are installed, you will be prompted to Configure the MySQL Server now .一旦安装了这些文件,你将被提示配置MySQL服务器了 。 Let the checkbox checked before proceeding to the next step.让我们在着手下一步检查复选框。

The next screen allows you to choose between Detailed Configuration or Standard Configuration .接下来的画面让您可以选择详细配置标准配置 。 Pick the former, just for the sake of curiosity about what options are available to us.选择前者,只是约还能有什么选择我们为了好奇。 Don't worry, if you don't know what an option is, you can always leave it as is.不要担心,如果你不知道什么是选项,您可以随时离开它是。

When asked to choose the server type, the choice in this example is obvious.当被要求选择服务器类型,在这个例子中,选择是显而易见的。 This setup is for experimenting with various WordPress themes and plugins, so low memory consumption is preferable.这种安装了各种主题和插件WordPress的试验是,如此之低内存消耗是可取的。 Choose Developer Machine .选择开发机 。 The other option will allow more concurrent connections running at the same time, which wastes more memory.其他选项将允许更多的并发连接运行在同一时间,耗费更多的内存。

It doesn't matter which one do you choose in the next step, but in this case, the choice is Multifunctional Database .不要紧,哪一个选择下一步选择,但在这种情况下,选择是多功能数据库

Following the option above, you will see a screen that prompts you for InnoDB Tablespace Settings .根据上述选项,您将看到一个屏幕,提示InnoDB表设置你。 Choose the directory where you want the file to be placed.选择您希望的目录文件放置。

The next step shows a screen where you can customize the number of concurrent connections allowed by MySQL.下一步显示屏幕,在这里你可以自定义由MySQL允许的同时连接数。 Although it is safe to choose Manual Setting and set it to 15 or even lower, I leave this to 20.虽然它是安全的选择手动设定 ,并设置为15或更低,我把这个问题留给20。

MySQL is capable of accepting connections through named pipes or TCP/IP networking. MySQL是能够接受通过命名管道或TCP / IP网络连接。 The latter is a more common setup, and more flexible too as you may migrate the MySQL server to another machine and still connect over the network, so leave all the settings as is. Enable TCP/IP Networking and Enable Strict Mode and leave Port Number: 3306 as the standard port.后者是更常见的设置,也更灵活,你可以在MySQL服务器迁移到另一台计算机,仍然通过网络连接,因此将所有设置,是。 启用TCP / IP网络启用严格模式 ,离开端口号:作为标准端口3306。

Because you don't need to make this MySQL database server to serve data outside of your own desktop computer, it is not necessary to add exception to the Windows Firewall for this port.因为你没有必要作此MySQL数据库服务器,为您自己之外的台式计算机的数据,没有必要增加对这个端口例外,Windows防火墙。 While running the batch file later, if Windows asks you if you want to unblock this, feel free to choose Keep Blocking , unless you want to allow remote connections.在运行该批处理文件后,如果Windows会询问您是否要解除封锁此,觉得自由选择保持阻止 ,除非你要允许远程连接。

Next, you may set the character set for this database server.接下来,你可以为这个数据库服务器的字符集。 For English and other West European language, the Standard Character Set option is good to go.对于英国和其他西欧语言, 标准字符集的选择是好去。

You may want to Install As Windows Service .您可能需要安装为Windows服务 。 The Launch the MySQL Server automatically allows you to run MySQL as you start Windows.在启动MySQL服务器会自动允许您运行MySQL作为启动Windows。

This is certainly an option, although you could also run it along with the batch file above so you have the capability to start and stop it on demand from one place.这当然是一个选择,但你也可以运行该批处理文件上面沿着这样你有能力启动和停止从一个地方的需求了。 Starting and stopping Windows service is not hard, but it needs more clicks separately.启动和停止Windows服务并不难,但需要更多的点击分开。

If you choose to run it via the batch file above, uncheck the Install as Windows Service option.如果您选择通过运行上面的批处理文件,取消作为Windows服务选项安装

Include Bin Directory in Windows PATH is a good idea so you can run mysql from anywhere in the command line. 包括在Windows的PATH Bin目录是一个好主意,因此您可以从运行 mysql命令行的任何地方。

It is recommended that you enter the root password so access to the data is protected.我们建议您输入root的密码,以便获取数据的保护。 You will need this to manage MySQL data.您将需要此管理MySQL数据。 If you don't need other people from remote machines to access this database server, leave the Enable root access from remote machines option unchecked.如果你不需要从远程计算机上的其他人访问此数据库服务器,保留从远程计算机上启用root访问选项选中。

That's it.就是这样。 Now you have installed EMP on your Windows system.现在你已安装在您的Windows系统电磁脉冲。

Check to Make Sure WEMP Runs Properly检查以确保正常运行WEMP

Now is the time to run Start nginx or the start-nginx.bat batch file.现在是时候开始nginx的运行或启动nginx.bat批处理文件。 It first starts, php-cgi, binds to the loopback interface (localhost, IP 127.0.0.1).它第一次启动时,运行php - cgi的,绑定到环回接口(本地主机的IP 127.0.0.1)。 Next it runs nginx, followed by mysqld.下一步它运行nginx的,由mysqld其次。 Again, this is the same script that you run if you pick Start nginx from the Start Menu .再次,这是相同的脚本运行,如果你选择开始nginx的开始菜单

You can check if all the servers run properly by using Windows Task Manager (right click on the taskbar and pick Task Manager).您可以检查所有服务器正常运行使用任务栏上的Windows任务管理器 (右键点击并选择任务管理器)。 Look for nginx.exe , mysqld-nt.exe and php-cgi.exe on the list.为nginx.exe查询时,mysqld - nt.exe和PHP,名单上cgi.exe。 Sort by Image Name first to make it easy to locate program names.排序图片名称首先可以很容易地找到程序名称。

Note: There will be two instances of nginx.exe , one master process and the other one is the worker process. 注:将有两个nginx.exe情况下,一个主进程,另一个是工作进程。 Don't worry about it, it is just how it was designed to be.不要担心它,它只是它是怎么设计的。

If you see them all, for redundancy, check if all the servers are accepting connections in the right TCP/IP ports.如果你看到他们,冗余,检查是否所有的服务器都接受正确的TCP连接/ IP端口。

Run the following command in a command prompt windows:运行下面的命令在命令提示符窗口:

netstat -ban -p tcp

Basically, it tells netstat to:基本上,它告诉netstat以:

  • -b: displays the executable involved in creating each connection or listening port. -乙:显示可执行参与创建每个连接或监听端口。
  • -a: displays all connections and listening ports. - 1:显示所有连接和侦听端口。
  • -n: displays address and port numbers in numerical form.氮:显示地址和端口号以数字形式。
  • -p tcp: shows connections for TCP protocol only.磷的TCP:为TCP协议只显示连接。

Among the result you should see the following:其中的结果你应该看到以下内容:

  • Port 80 – System. For one reason or another it doesn't shows as nginx.exe, but you can confirm it as such. 端口80 -系统。为某种原因不作为nginx.exe显示,但可以确认它本身。
  • Port 3306 is occupied by mysqld-nt.exe , which is exactly the MySQL server you were starting just now. 端口3306是占领mysqld - nt.exe,这正是MySQL服务器你刚才开始。
  • Port 10000 – php-cgi.exe. Instead of 0.0.0.0 (all IP address in the system, this is specific only to loopback address (127.0.0.1). The PHP is now running in FastCGI mode, ready to accept connection. 端口10000 - PHP的cgi.exe而不是0.0.0.0。(所有系统的IP地址,这是具体只有环回地址(127.0.0.1)。现在的PHP FastCGI的运行模式,准备接受连接。

For a full test you need something that access the web server, calling PHP script and connect to MySQL database.对于一个完整的测试你需要的东西访问Web服务器,调用PHP脚本,并连接到MySQL数据库。

Because WordPress does exactly this, let's proceed by installing it on your WEMP setup.由于WordPress的不正是这一点,让我们继续通过安装在你的WEMP设置它。

你可能感兴趣的:(Nginx WIN7下安装PHP的MySQL)