centos 7 配置php

对于我们的目的而言,安装 Apache 只需要在 CentOS 命令终端敲入这条命令就行了:

$ sudo yum install httpd

$ sudo systemctl enable httpd.service

在服务器上启动 Apache 服务的命令为:

$sudo systemctl start httpd.service

重新启动 Apache:

$sudo systemctl restart httpd.service

停止 Apache:

$sudo systemctl stop httpd.service

2、mysql 安装

开始安装 MySQL 之前,请更新系统上的软件到最新版:

$ sudo yum update

由于 CentOS 7 的软件仓库不再提供 MySQL 的安装包,我们必须从 MySQL 社区仓库 (https://dev.mysql.com/downloads/repo/yum/) 获取 MySQL 安装包。

首先,获取 MySQL 社区仓库:

$ wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

载入 MySQL 社区仓库:

$ sudo yum install mysql57-community-release-el7-8.noarch.rpm

更新系统上的软件到最新版:

$ sudo yum update

在更新过程中,你会被询问是否想接受这个 .rpm 文件 GPG 校验得出的结果,如果没有错误或者不匹配出现,请输入 y 以完成更新。

接着,我们就能一如往常一样安装 MySQL 了:

$ sudo yum install mysql-server

接下来,请按照这里的指南,重置 MySQL root 账户的密码为你能够记住的密码:

http://stackoverflow.com/questions/33510184/change-mysql-root-password-on-centos7(下面有修改密码的命令)

然后,启动 MySQL 服务:

$ sudo systemctl start mysqld

现在 MySQL 数据库已经开始运行了。我们希望运行一个安全防御脚本,将一些危险的默认配置移除掉,并为我们的数据库系统加上一点安全机制。请在命令行终端里运行下面这一条命令:

$ sudo mysql_secure_installation

命令行终端将会提示你输入 MySQL 内 root 用户的密码。键入上面重置 MySQL root 密码后的新密码。然后,命令行终端将会要求你更新 root 用户的密码。

Enter current password for root:

The existing password for the user account root has expired. Please set a new password.

New password:

Re-enter new password:

The 'validate_password' plugin is installed on the server.

The subsequent steps will run with the existing configurationof the plugin.

Using existing password for root.

对于命令行终端接下来给出的选择,你应该敲击 ENTER 键选择忽略修改 root 密码,接着键入 y 同意移除掉出于示例目的而存在的用户,而后键入 y 同意禁用远程登录 root 用户,再次键入 y 同意移除测试数据库,最后键入 y 载入这些新的规则使得 MySQL 立即响应我们做的变更。

最后,如果希望 MySQL 服务在服务器启动时自动开启,那么你应该使用这一条的命令:

$ sudo systemctl enable mysqld.service

你可以通过重新启动服务器,然后在命令行终端中敲入这条命令来验证MySQL 服务是否在服务器启动时自动开启了:

$ sudo systemctl is-enabled mysqld.service

如果你看到了这样的响应:

enabled

则说明 MySQL 服务已经配置为在服务器启动时自动开启了。

现在,你的数据库系统已经安装妥当,我们可以继续后面的内容了。

[  1. Stop mysql:
systemctl stop mysqld

2. Set the mySQL environment option 
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

3. Start mysql usig the options you just set
systemctl start mysqld

4. Login as root
mysql -u root

5. Update the root user password with these mysql commands
mysql> UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword')
    -> WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit

6. Stop mysql
systemctl stop mysqld

7. Unset the mySQL envitroment option so it starts normally next time
systemctl unset-environment MYSQLD_OPTS

8. Start mysql normally:
systemctl start mysqld

Try to login using your new password:
7. mysql -u root -p]
3、php 安装
原文地址:https://www.cnblogs.com/ampl/p/8483801.html