安装并运行最简单的LAMP

Published on 2015 - 02 - 09

安装最简单的LAMP

系统:CentOS 6 & 7 都可

yum install httpd php php-mysql php-gd mysql-server php-xml mysql    

接着运行以下命令进行数据库初始化

service mysqld start

mysql_secure_installation

设置完成后登录数据库

 mysql -u root -p    

创建用户,并赋予创建权限

CREATE USER 'USER'@'localhost' IDENTIFIED BY 'THISpasswordSHOULDbeCHANGED';  //创建用户指定密码    

GRANT ALL PRIVILEGES ON *.* TO 'wiki'@'localhost' IDENTIFIED BY 'THISpasswordSHOULDbeCHANGED' WITH GRANT OPTION;  //赋予权限    

FLUSH PRIVILEGES;  //刷新配置文件    

exit; 

创建数据库

CREATE DATABASE database name;    

显示当先数据库

SHOW DATABASES;    

赋予权限,刷新配置

GRANT ALL PRIVILEGES ON databasename.* TO 'user'@'localhost' IDENTIFIED BY 'Thisispassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit    

设置web与mysql开机启动

chkconfig httpd on
chkconfig mysqld on