[Windows Azure] 创建支持Apache,PHP以及MySQL的CentOS Web Virtual Machine Server

本文介绍如何在Linux虚拟机上安装并配置MySQL数据库和Apache Web服务器,包括创建虚拟机、安装MySQL及Apache、设置端口映射及测试等关键步骤。

创建Linux虚机

1. 打开 https://manage.windowsazure.com/ 并使用您的账户登录Windows Azure Portal。

2. 在下方菜单中选择New | Compute | Virtual Machine | From Gallery 开始创建一个新的虚机。

image

3. 在VM OS Selection页面左侧的Platform Images 选择OpenLogic CentOS 6.2 操作系统并点击继续。

4. 在Virtual machine configuration 中输入虚机名称(比如:"centosvm1")以及用户名和密码,密码要求复杂格式但确保您能记住,完成后点击右侧向右按钮。

image

5. 在Virtual machine mode 页面中选择Standalone Virtual Machine, 输入该虚机的DNS Name,并选择Storage Account 或选择默认的Use Automatically Generated Storage Account,然后Region/Affinity Group/Virtual Network.点击向右按钮继续。

image

6. 在Virtual machine options选择默认值并点击 Finish 按钮完成虚机的创建。

image

7. 在左侧的 Virtual Machines 节点中,你会看到你创建的VM状态为 Starting (provisioning),等到它变成Running 继续下面的步骤。

image

Note: 这个操作也许会花费8-10分钟,请耐心等待.

8. 获得Putty.exe工具,该工具用户远程连接您的虚机

image

image

9. 在Virtual Machines 节点中找到虚机,点击进入虚机控制面板,查看虚机详细信息:

image

image

10. 将DNS输入到Putty工具的Host Name栏,选择默认SSH,点击Open:

image

11. 安全确认点击Yes:

image

12. 输入您刚才设置的用户名和密码进行登陆:

image

13. 登陆成功后执行如下命令,进行高级权限激活,并要求在此输入登录密码,待您看到root@centosvm1即可:

sudo –s

image

14. 开始安装MySQL5,首先我们应该先用下面的命令安装MySQL:

yum install mysql mysql-server

image

image

15. 选择Y进行安装:

image

image

16. 然后我们需要启动MySQL服务器,运行如下命令:

/etc/init.d/mysqld start

image

17. 为MySQL root帐户设置密码,运行如下命令:

mysql_secure_installation

会出现下面的一系列提示:

[root@centosvm1 yourusername] # mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, well need the current

password for the root user. If youve just installed MySQL, and

you havent set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none):这里输入旧密码,由于旧密码为空直接回车即可

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation.

Set root password? [Y/n] 回车表示Y

New password: 输入您的新密码

Re-enter new password: 在此输入您的新密码

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account created for

them. This is intended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] 回车表示Y

... Success!

Normally, root should only be allowed to connect from localhost. This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] 回车表示Y

... Success!

By default, MySQL comes with a database named test that anyone can

access. This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] 回车表示Y

- Dropping test database...

... Success!

- Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] 回车表示Y

... Success!

Cleaning up...

All done! If youve completed all of the above steps, your MySQL

installation should now be secure.

Thanks for using MySQL!

[root@centosvm1 yourusername] #

至此MySQL用户设置完成。

18. 安装Apache2,执行如下命令:

yum install httpd

image

19. 输入Y进行确认安装:

image

20. 执行如下命令启动Apache:

/etc/init.d/httpd start

image

Note: Apache的默认文档根目录是在CentOS上的/var/www/html 目录 ,配置文件是/etc/httpd/conf/httpd.conf。配置存储在的/etc/httpd/conf.d/目录。

21. 回到Windows Azure Portal中,选择当前虚机的Endpoint:

image

22. 打开后选择下方菜单中Add Endpoint:

image

23. 选择Add endpoint,点击右下方向右按钮:

image

24. 在Name中输入Web,Protocol选择TCP,Public Port输入80,Private Port输入80,完成后点击右下对号按钮:

image

25. 等待端口添加完成再进行后续步骤:

image

26. 在浏览器中输入http://youdnsname.cloudapp.net,如网页是否显示如下则正确:

image

27. 安装PHP 5,我们可以用下面的命令来安装PHP5

yum install php

image

28. 输入Y确认安装:

image

29. 安装完成后使用如下命令重启Apache:

/etc/init.d/httpd restart

image

30. 接下来我们要在/srv/www/html中创建一个Info.php页面来测试PHP环境是否正常,运行如下命令:

vi /var/www/html/info.php

31. 进入编辑状态后输入以下内容:

<?php

Phpinfo();

?>

image

32. 输入完成偶按Esc退出编辑状态,按:键,输入wq保存并退出编辑状态:

image

33. 访问http://youdnsname.cloudapp.net/info.php,查看页面是否如下:

image

34. 让PHP 5获得MySOL的支持,运行如下命令:

yum search php

image

35. 再运行如下命令安装必要组件:

yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc

image

36. 输入Y进行安装:

image

37. 运行如下命令重新启动Apache:

/etc/init.d/httpd restart

image

38. 访问http://youdnsname.cloudapp.net/info.php,并查看MySQL模块支持:

image

39. 接下来测试MySQL数据库工作情况,首先使用如下命令创建测试页面:

vi /var/www/html/mysql.php

40. 进入编辑状态输入:

<?php

$mysql_server_name='localhost';

$mysql_username='root';

$mysql_password='您之前设置的MySQL密码';

$mysql_database='mycounter';

$conn=mysql_connect($mysql_server_name,$mysql_username,$mysql_password,$mysql_database);

$sql='CREATE DATABASE mycounter DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci;

';

mysql_query($sql);

$sql='CREATE TABLE `counter` (`id` INT(255) UNSIGNED NOT NULL AUTO_INCREMENT ,`count` INT(255) UNSIGNED NOT NULL DEFAULT 0,PRIMARY KEY ( `id` ) ) TYPE = innodb;';

mysql_select_db($mysql_database,$conn);

$result=mysql_query($sql);

//echo $sql;

mysql_close($conn);

echo "Hello!...mycounter…….";

?>

image

41. 完成后按Esc,输入:后输入wq进行保存并退出编辑状态,访问http://youdnsname.cloudapp.net/mysql.php,如果看到如下信息证明成功:

image


<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
(1)普通用户端(全平台) 音乐播放核心体验: 个性化首页:基于 “听歌历史 + 收藏偏好” 展示 “推荐歌单(每日 30 首)、新歌速递、相似曲风推荐”,支持按 “场景(通勤 / 学习 / 运动)” 切换推荐维度。 播放页功能:支持 “无损音质切换、倍速播放(0.5x-2.0x)、定时关闭、歌词逐句滚动”,提供 “沉浸式全屏模式”(隐藏冗余控件,突出歌词与专辑封面)。 多端同步:自动同步 “播放进度、收藏列表、歌单” 至所有登录设备(如手机暂停后,电脑端打开可继续播放)。 音乐发现与管理: 智能搜索:支持 “歌曲名 / 歌手 / 歌词片段” 搜索,提供 “模糊匹配(如输入‘晴天’联想‘周杰伦 - 晴天’)、热门搜索词推荐”,结果按 “热度 / 匹配度” 排序。 歌单管理:创建 “公开 / 私有 / 加密” 歌单,支持 “批量添加歌曲、拖拽排序、一键分享到社交平台”,系统自动生成 “歌单封面(基于歌曲风格配色)”。 音乐分类浏览:按 “曲风(流行 / 摇滚 / 古典)、语言(国语 / 英语 / 日语)、年代(80 后经典 / 2023 新歌)” 分层浏览,每个分类页展示 “TOP50 榜单”。 社交互动功能: 动态广场:查看 “关注的用户 / 音乐人发布的动态(如‘分享新歌感受’)、好友正在听的歌曲”,支持 “点赞 / 评论 / 转发”,可直接点击动态中的歌曲播放。 听歌排行:个人页展示 “本周听歌 TOP10、累计听歌时长”,平台定期生成 “全球 / 好友榜”(如 “好友中你本周听歌时长排名第 3”)。 音乐圈:加入 “特定曲风圈子(如‘古典音乐爱好者’)”,参与 “话题讨论(如‘你心中最经典的钢琴曲’)、线上歌单共创”。 (2)音乐人端(创作者中心) 作品管理: 音乐上传:支持 “无损音频(FLAC/WAV)+ 歌词文件(LRC)+ 专辑封面” 上传,填写 “歌曲信息
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值