27.Linux 使用yum安装lamp,部署wordpress
Linux : 使用yum安装lamp,部署wordpress
实验前需要关闭防火墙和selinux,yum源使用网络yum源(wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo)
1.同步时钟服务器
[root@lamp ~]# systemctl restart chronyd
[root@lamp ~]# systemctl enable chronyd
[root@lamp ~]# hwclock -w
2.安装httpd和mariadb(mysql)数据库
yum install httpd mariadb mariadb-server
3.初始化数据库
systemctl restart mariadb
systemctl enable mariadb
mysql_secure_installation
(除了不允许用户远程登录选n,其他全都是y,密码为redhat)
Set root password? [Y/n]y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
安装php
[root@xieyuhui2 ~]# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
[root@xieyuhui2 ~]# yum install yum-utils -y
[root@xieyuhui2 ~]# yum-config-manager --enable remi-php70
安装php相关插件
[root@xieyuhui2 ~]# yum install php php-cli php-fpm php-gd php-curl php-zip php-mbstring php-opcache php-intl php-mysqlnd -y
配置php文件,将时区改为亚洲/上海
[root@xieyuhui2 ~]# vim /etc/php.ini
重启服务
[root@xieyuhui2 ~]# systemctl restart php-fpm
[root@xieyuhui2 ~]# systemctl enable php-fpm
配置默认网页
[root@xieyuhui2 ~]# vim /etc/httpd/conf/httpd.conf
[root@xieyuhui2 ~]# vim /var/www/html/index.php
重启服务
[root@xieyuhui2 ~]# systemctl restart httpd
[root@xieyuhui2 ~]# systemctl enable httpd
查看php版本是否正确
上传wordpress压缩包然后解压
将wordpress复制到/var/www/html内
[root@xieyuhui2 ~]# cp -R wordpress /var/www/html/
设置wordpress所属者和所属组为apache,权限为775
[root@xieyuhui2 ~]# chown -R apache.apache /
var/www/html/wordpress/
[root@xieyuhui2 ~]# chmod -R 775 /var/www/html/wordpress/
配置wordpress数据库
[root@xieyuhui2 html]# mysql -uroot -p
MariaDB [(none)]> create database wordpress;
MariaDB [(none)]> create user 'wordpress_use'@'localhost' identified by 'redhat';
MariaDB [(none)]> grant all on wordpress.* to 'wordpress_user'@'localhost';
MariaDB [(none)]> flush privileges;
为wordpress配置站点
[root@xieyuhui2 ~]# cp -p /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /etc/httpd/conf.d/ #覆盖虚拟机主配置文件,<Directory>是httpd/conf/httpd.conf里的配置文件
重启服务
[root@xieyuhui2 ~]# systemctl restart httpd
在浏览器访问wordpress站点(192.168.100.20/wp-admin)