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)
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论