Chinaunix首页 | 论坛 | 博客
  • 博客访问: 600435
  • 博文数量: 129
  • 博客积分: 6240
  • 博客等级: 准将
  • 技术积分: 1765
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-18 15:42
文章分类

全部博文(129)

文章存档

2015年(1)

2012年(3)

2011年(6)

2010年(14)

2009年(105)

我的朋友

分类: 系统运维

2009-03-25 10:52:43

1、启动实例。
2、建立ebs卷,连接到实例上(attach it to /dev/sdh)。
3、连接到实例。
4、格式化新连接的磁盘设备(ebs)
   mkfs.ext3 /dev/sdh
5、建立新的目录,用户挂载ebs
   mkdir /ebs
6、挂载ebs卷。
   mount -t ext3 /dev/sdh /ebs
注意:如果你关闭了这个实例,在启动一个新的实例,只需要建立目录,然后再挂载就可以了。那个ebs已经被格式化了,里面的数据还在。
7、现在我们就用yum开始安装httpd,php,mysql
   yum -y install httpd php mysql mysql-server php-mysql
使服务在系统每次启动时自动启动。
  
/sbin/chkconfig httpd on
   /sbin/chkconfig –add mysqld
   /sbin/chkconfig mysqld on
8、启动httpd,mysql。
  
/sbin/service httpd start
   /sbin/service mysqld start

   mysqladmin -u root password ‘new-password’

Remove the test database:

DROP DATABASE test;

Disable anonymous access:

DELETE FROM mysql.user WHERE user = ”;
FLUSH PRIVILEGES;

Then exit mySQL using quit.

Now it’s time to move apache to EBS:

First we need to stop the service:

/sbin/service httpd stop

Then we move httpd to EBS:

mv /etc/httpd /ebs1/httpd

And create a symbolic link to it:

ln -s /ebs1/httpd /etc

Also do this for the document root:

mv /var/www /ebs1/www
ln -s /ebs1/www /var/

And restart apache:

/sbin/service httpd start

Note: If you terminate and start a new instance simply remove the /etc/httpd and /var/www folders and just run the commands to create the symbolic links.

Then we do the same for mySQL:

/sbin/service mysqld stop
mv /var/lib/mysql /ebs1/mysql
ln -s /ebs1/mysql /var/lib
/sbin/service mysqld start

This only moves the mySQL data, not the logs. You can edit /etc/my.cnf to configure where logs are stored and also move the log directory to EBS if you want to.

So now you have a fully functioning server on EC2 that stores and retrieves data to and from and EBS volume. The EBS volume and be backed up almost instantly using a snapshot. If you don’t use innodb for your tables it is advised that you lock your tables while you take the snapshot.

Next steps / thoughts:

Some might want to create a hosting enviroment for many websites. What you can do for this is to edit your httpd.conf file (located on EBS /ebs1/httpd/conf/httpd.conf) and enable Virtual Hosts. What I did is to create a directory /ebs1/sites and then create users on fedora using the following command:

useradd -d /ebs1/sites/mysite1.com user-for-mysite1

Also don’t forget to specify a password for the user using:

passwd user-for-mysite1

Once you have created the user you can point the document root for that specific site to his home directory.

Also to enable the user to upload files to his/her website using SCP you need to allow password access through SSH (be careful on security issues though). To do this, edit /etc/ssh/sshd_config and change the line “PasswordAuthentication no” to “PasswordAuthentication yes”. Also restart sshd by running /etc/init.d/sshd restart.

The final step is to link real domains to your new server. We assume that you have already assigned one or more IPs to your server. To point a domain to a specific IP you need to edit its DNS records and add an “A record” that points to that IP. Once the domain resolves on your server you will be able to use it for your website. If you need to host multiple websites, create one VirtualHost record for each domain (using the appropriate servername and documentroot values) and off you go!

Special thanks to http://agiletesting.blogspot.com/ for the useful information that I found there for this tutorial.


阅读(1362) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~