1.用yum安装Apache,Mysql,PHP.
1.1安装Apache
yum install httpd httpd-devel
安装完成后,用service httpd start
1.2 安装mysql
yum install mysql mysql-server mysql-devel
CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # rpm -ivh mysql-community-release-el7-5.noarch.rpm # yum install mysql-community-server
成功安装之后重启mysql服务
service mysqld restart
初次安装mysql是root账户是没有密码的
设置密码的方法
# mysql -uroot mysql> set password for ‘root’@‘localhost’ = password('mypasswd'); mysql> exit
同样,完成后,用/etc/init.d/mysqld start 启动mysql
1.3 设置mysql密码
mysql>; USE mysql;
mysql>; UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql>; FLUSH PRIVILEGES;
设置mysql密码还可以用:mysql_secure_installation 命令
1.4允许远程登录
mysql -u root -p
Enter Password: <your new password>
mysql>GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
完成后就能用mysql-front远程管理mysql了。
1.5安装php
yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
/etc/init.d/httpd start
2. 测试一下
先得重启下apache
在/var/www/html/新建个test.php文件,将以下内容写入,然后保存。
<?
phpinfo();
?>