lamp+wordpress
时钟同步
//下载chrony包
[root@lamp ~]# yum -y install chrony
//重启服务
[root@lamp ~]# systemctl restart chronyd
[root@lamp ~]# systemctl enable chronyd
[root@lamp ~]# hwclock -w
[root@lamp ~]# timedatectl //查看是否时钟同步
安装软件包
// 安装 httpd mariadb mariadb-server 包
[root@lamp ~]# yum -y install httpd mariadb mariadb-server
//重启 httpd mariadb 服务
[root@lamp ~]# systemctl restart httpd
[root@lamp ~]# systemctl enable httpd
[root@lamp ~]# systemctl restart mariadb
[root@lamp ~]# systemctl enable mariadb
安装配置MySQL
[root@lamp ~]# mysql_secure_installation
Enter current password for root (enter for none): //输入数据库密码
Switch to unix_socket authentication [Y/n] //指针验证
Change the root password? [Y/n] y //设置数据库密码
New password: //输入新密码
Re-enter new password: //再次输入新密码
Remove anonymous users? [Y/n] y //移除匿名用户
Disallow root login remotely? [Y/n] n //不允许root用户远程登录
Remove test database and access to it? [Y/n] y //是否要移除测试数据库并移除访问
Reload privilege tables now? [Y/n] y //重新加载表的权限
//登录
[root@lamp ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.5.22-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
安装配置PHP
//安装PHP包
[root@lamp ~]# yum -y install php php-cli php-fpm php-gd php-curl php-zip php-mbstring php-opcache php-intl php-mysqlnd
//修改时区
[root@lamp ~]# vim /etc/php.ini
date.timezone = Asia/Shanghai
//重启PHP
[root@lamp ~]# systemctl restart php-fpm
[root@lamp ~]# systemctl enable php-fpm
//编写PHP网页
[root@lamp ~]# cd /var/www/html/
[root@lamp html]# vim index.php
<?php
phpinfo();
?>
//修改APache的默认文件
[root@lamp html]# vim /etc/httpd/conf/httpd.conf
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
//重启服务
[root@lamp html]# systemctl restart httpd
[root@lamp html]# systemctl enable httpd
直接输入本机IP可以访问PHP
安装配置wordpress
安装配置下载修改解压wordpress
//安装软件包 ------>方便将文件从真实机传输到虚拟机
[root@lamp html]# yum -y install lrzsz
//创建目录并将软件包上传到 /opt/software中,安装tar包并解压
[root@lamp html]# mkdir /opt/software
[root@lamp software]# yum -y install tar
[root@lamp software]# ls
wordpress wordpress-6.5.5.tar.gz
//复制文件、修改所有者和所属组和权限
[root@lamp software]# cp -r wordpress /var/www/html/
[root@lamp ~]# chown -R apache.apache /var/www/html/wordpress/
[root@lamp ~]# chmod -R 775 /var/www/html/wordpress/
配置数据库
//登录数据库
[root@lamp ~]# mysql -u root -p
//创建数据库(以“;”为结束)
MariaDB [(none)]> create database wordpress_db;
//创建用户
MariaDB [(none)]> CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';
user 创建的用户名
@'localhost' 本地登录
IDENTIFIED BY 设置的密码
//授权
MariaDB [(none)]> grant all on wordpress_db.* to 'wordpress_user'@'localhost';
wordpress_db.* //wordpress_db库下面的所有表
//刷新数据库
MariaDB [(none)]> flush privileges;
配置网站
//复制文件
[root@lamp ~]# cp -p /usr/share/doc/httpd-core/httpd-vhosts.conf /etc/httpd/conf.d/
//在 /etc/httpd/conf/httpd.conf 查找
<VirtualHost 192.168.100.10:80>
DocumentRoot "/var/www/html/wordpress" //网站位置
<Directory "/var/www/html/wordpress"> //什么权限
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
</VirtualHost>