文章目录:
一:检查系统环境
查询当前CENTOS版本:
cat /etc/reahat-release
1.1检查安装apache
rpm -qa | grep httpd
或apachectl -v
或 httpd -v
1.2检查是否安装mysql
service mysqld start
1.3清理Mysql
yum remove mysql
rm - f /etc/my.cnf
1.4卸载Apache包
rpm -qa |grep httpd
二:安装过程:
2.1安装apache
yum - y install httpd
2.2 安装php
yum -y install php
2.3安装php-fpm
yum -y install php-fpm
2.4安装mysql
yum -y install mysql (centos7.2以后的版本已经把mysql修改为mariadb)
2.5安装mysql-server
yum - y install mysql-server
返回Error:Nothing to do.
No package
解决方案:
Centos-默认将mariadb视为mysql
两种方案:
一:安装mariadb
yum install - y mariadb
二:从官网下载 mysql-server
wget htpp://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
回车Y
2.6 安装php-mysql
yum -y install php-mysql
三.安装基本常用扩展包
1.安装apache扩展包
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
2.安装PHP扩展包
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-devel
3.安装MySQL扩展包
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
四.配置Apache,mysql开机启动
Centos7+版本方法:
systemctl start httpd.service #启动apache
systemctl stop httpd.servic #停止apache
systemctl restart httpd.service #重启apache
systemctl enable httpd.service 设置开机启动
采用方法一安装的mariadb,使用以下命令开启数据库:
#启动MariaDB
systemctl start mariadb.service
#停止MariaDB
systemctl stop mariadb.service
#重启MariaDB
systemctl restart mariadb.service
#设置开机启动
systemctl enable mariadb.service
#重启对应服务
service mysqld restart
service php-fpm start
service httpd restart
如果是第二种 将mariadb.service 修改为mysql.service即可
五:配置mysql
mysql_secure_installation
出现根密码的设置 选择两次回车
输入密码 回车
确认密码 回车
会出现以下四个确定:
Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Remove test database and access to it? [Y/n]
Reload privilege tables now? [Y/n]
意思分别是:
删除匿名用户?[是/否]
不允许远程根登录?[是/否]
删除测试数据库并访问它?[是/否]
现在重新加载特权表?[是/否]
全部回车即可
网友评论