CentOS yum安装Apache+MySQL+PHP

安装Apahce

# yum -y install httpd

安装mysql

# yum -y instal mysql mysql-server

安装php及其php扩展

# yum -y install php php-common php-cli php-pear php-pdo php-mysql php-gd php-mbstring php-mcrypt php-xml php-xmlrpc php-pecl-zendopcache

启动服务配置

# chkconfig httpd on [设置apache为自启动]
# chkconfig mysqld on [设置mysql为自启动]
# service httpd start [启动 httpd 服务]
# service mysqld start [启动mysqld服务]

设置mysql数据库root帐号密码

# mysqladmin -u root password '新密码'[引号内填密码]

让MySQL数据库更安全

# mysql -u root -p [此时会要求你输入刚刚设置的密码,输入后回车即可
# mysql> DROP DATABASE test;[删除test 数据库]
# mysql> DELETE FROM mysql.user WHERE user ='';[删除匿名帐户]
# mysql> FLUSH PRIVILEGES; [重载权限]
# mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.x.x' IDENTIFIED BY '密码' WITH GRANT OPTION; [增加远程链接用户]

检查安装包

# rpm -qa | grep httpd
# rpm -qa | grep mysqld
# rpm -qa | grep php

配置文件存放的位置

按照以上的安装方式, 配置出来的默认站点目录为/var/www/html/
apache配置文件位置:/etc/httpd/conf/httpd.conf
php配置文件位置:/etc/php.ini 和/etc/php.d里面的文件
mysql配置文件位置:/etc/my.cnf