Linux

关注公众号 jb51net

关闭
首页 > 网站技巧 > 服务器 > Linux > Linux使用yum安装lamp部署wordpress

Linux使用yum安装lamp以及部署wordpress实践

作者:xx.ii

文章指导如何通过yum安装LAMP环境并部署WordPress,需关闭防火墙和SELinux,配置阿里云yum源,安装Apache、MySQL和PHP,设置时区为上海,初始化数据库,调整权限,部署站点后访问验证

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)

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文