1. 安装apachephpmysql
=======================================
yum -y install httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc mysql-connector-odbc mysql-devel libdbi-dbd-mysql
2. 挂载第二块磁盘/dev/xvdb
----------------------------
fdisk /dev/xvdb
n
p
1
w
/dev/xvdb1 /mnt/xvdb1 ext3 defaults 0 0
----------------------------
a)查看硬盘
fdisk -l
b)格式化
mkfs.ext3 /dev/xvdb
c)建立挂载目录
mkdir /hf
d)挂载
mount /dev/xvdb /hf
e)确认挂载状况
df -k -h
f)开机自动挂载
vi /etc/fstab
/dev/xvdb /hf ext3 defaults 1 2
g)重启机器确认自动挂载状况
reboot
h)建立2个目录: data数据库用, website网站用
mkdir -p /hf/data/mysql
mkdir -p /hf/website
3. 配置mysql
=======================================
a)修改data目录
vi /etc/my.cnf
datadir=/hf/data/mysql
b)启动mysql
/etc/rc.d/init.d/mysqld start
c)修改mysql密码
/usr/bin/mysqladmin -u root password 'mysql'
d)登录mysql确认
mysql -uroot -p
e)数据库常用操作
1)创建数据库:
create database hf;
2)删除数据库:
drop database hf;
3)分配数据库权限
grant all privileges on hf.* to hf@'localhost' identified by '111111';
4. 配置apache
=======================================
a)开启.htaccess
vi /etc/httpd/conf/httpd.conf
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
b)修改默认页
mkdir -p /hf/website/localhost/htdocs
vi /hf/website/localhost/htdocs/index.php
<?php
echo('hello');
?>
vi /etc/httpd/conf/httpd.conf
把{ DocumentRoot "/var/www/html" }修改为{ DocumentRoot "/hf/website/localhost/htdocs" }
c)查看php环境
vi /hf/website/localhost/htdocs/phpinfo.php
<?php
phpinfo();
?>
5. 配置httpdmysql开机自动启动
=======================================
chkconfig --add httpd
chkconfig httpd on
chkconfig --add mysqld
chkconfig mysqld on