线上部署 LAMP (Linux+Apache+Mysql+PHP)
案例操作系统: CentOS 7.5 64位
apache安装
yum命令安装apache:
sudo yum install -y httpd
启动apache
sudo service httpd start
主配置文件路径
/etc/httpd/conf/httpd.conf
php安装
切换目录
cd /etc/yum.repos.d
安装epel-release工具
sudo yum install -y epel-release
ls命令查看, 自动生成两个文件
epel.repo
epel-testing.repo
更新rpm包
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
ls命令查看 自动生成多个以rem开头的包
编辑remi-php73.repo(因为需要安装php7.3)
输入:set nu 回车 添加行号 修改第9行的0为1; 保存退出
安装php 以及php扩展包
sudo yum --enablerepo=remi install -y php php-common php-cli php-mysql php-pdo php-mbstring php-pecl-zip php-gd php-process
检测版本
php -v
mysql安装
一 安装
运行以下命令更新YUM源
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
运行以下命令安装MySQL
yum -y install mysql-community-server
运行以下命令查看MySQL版本号
mysql -V
配置mysql
运行以下命令启动MySQL服务
systemctl start mysqld
运行以下命令设置MySQL服务开机自启动
systemctl enable mysqld
运行以下命令查看/var/log/mysqld.log文件,获取并记录root用户的初始密码
grep 'temporary password' /var/log/mysqld.log
二 配置
运行下列命令对MySQL进行安全性配置
mysql_secure_installation
1重置root用户的密码
Enter password for user root: #输入上一步获取的root用户初始密码
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration of the plugin.
Using existing password for root.
Estimated strength of the password: 1