Nginx+Apache+PHP+MySQL搭建集群服务器过程详解
概念介绍在本文未能提及,请自助上网科普,直接进入过程详解:
一、软件下载
序号 |
软件名称 |
软件版本 |
下载地址 |
1 |
操作系统 |
Windows Server 2008 Enterprise 64bit |
|
2 |
Php |
php-5.6.19-Win32-VC11-x64 Thread Safe(由于HTTP服务器用的apache) |
http://windows.php.net/downloads/releases/php-5.6.19-Win32-VC11-x64.zip |
3 |
VC11 |
Visual C++ Redistributable for Visual Studio 2012 Update 4(VSU_4\vcredist_x64.exe) |
https://www.microsoft.com/en-us/download/confirmation.aspx?id=30679 |
4 |
Nginx |
nginx/Windows-1.8.1 |
http://nginx.org/download/nginx-1.8.1.zip |
5 |
Apache |
Apache 2.4.18 x64 |
http://www.apachehaus.com/cgi-bin/download.plx?dli=gVwkjeaVVQy4ERntWTWFVMKVlUGR1UwZ3UVRGU |
6 |
MySql |
mysql-5.7.11.0 - win x64 |
http://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-5.7.11.0.msi |
7 |
Navicate |
Navicat Premium x64
|
http://download3.navicat.com/download/navicat112_premium_en_x64.exe |
8 |
PHPmyadmin |
phpMyAdmin-4.4.15.5-all-languages |
https://files.phpmyadmin.net/phpMyAdmin/4.4.15.5/phpMyAdmin-4.4.15.5-all-languages.zip |
二、VC11安装与配置
根据PHP版本选择安装对应版本的VC,php5.6对应的是VC11,根据VC11应用程序安装指引安装VC11。
三、PHP安装与配置
四、Apache安装与配置
a. Define SRVRROOT改为Apache的安装路径:
Define SRVROOT "C:/Program Files/Apache24"
#LoadModulephp5 support
LoadModule php5_module "C:/Program Files/php-5.6.19-Win32-VC11-x64/php5apache2_4.dll"
AddTypeapplication/x-httpd-php .php .html .htm
#configurethe path to php.ini
PHPIniDir "C:/ProgramFiles/php-5.6.19-Win32-VC11-x64"
3. 创建 Apache2.4 服务,具体命令:
-> C:Program Files\Apache24\bin\httpd.exe -k install -n"Apache2.4"
Tips:删除Apache2.4服务命令:
-> C:Program Files\Apache24\bin\httpd.exe -k uninstall -n"Apache2.4"
4. 使用命令行或应用程序重启httpd.exe;
5. 在浏览器中访问http://localhost:8080检查Apache页面是否配置正确,出现“It works”页面表示安装成功;
phpinfo(); ?>
五、Nginx安装与配置
上述软件安装成功后,开始着手配置安装Nginx
upstreammyCluster {
server ip address1 : 8080 ;
server ip address2 : 8081 ;
}
然后在server模块中加入
location ~\.php$ {
proxy_pass http://myCluster;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
六、 Mysql安装与配置
七、 PhpMyAdmin安装
/**
* Your phpMyAdmin URL.
*
* Complete the variable below with the fullURL ie
* http://www.your_web.net/path_to_your_phpMyAdmin_directory/
*
* It must contain characters that are validfor a URL, and the path is
* case sensitive on some Web servers, forexample Unix-based servers.
*
* In most cases you can leave this variableempty, as the correct value
* will be detected automatically. However, werecommend that you do
* test to see that the auto-detection codeworks in your system. A good
* test is to browse a table, then edit a rowand save it. There will be
* an error message if phpMyAdmin cannotauto-detect the correct value.
*
* @global string $cfg['PmaAbsoluteUri']
*/
$cfg['PmaAbsoluteUri'] = 'http://yourdomain/phpmyadmin/';
/**
* MySQL hostname or IP address
*
* @global string $cfg['Servers'][$i]['host']
*/
$cfg['Servers'][$i]['host'] = 'ip address';
/**
* Authentication method (valid choices:config, http, signon or cookie)
*
* @global string$cfg['Servers'][$i]['auth_type']
*/
$cfg['Servers'][$i]['auth_type']= 'cookie';
/**
* MySQL user
*
* @global string $cfg['Servers'][$i]['user']
*/
$cfg['Servers'][$i]['user']= 'your user name';
/**
* MySQL password (only needed with 'config'auth_type)
*
* @global string$cfg['Servers'][$i]['password']
*/
$cfg['Servers'][$i]['password']= 'your password';
注意:本人亲测:phpmyadmin不支持被配置为负载均衡。
3. 打开浏览器访问phpmyadmin,输入用户名和密码,进入到phpmyadmin控制台则表明PhpMyadmin配置成功。