Redhat快速安装LAMP和WordPress

时间:2024-04-06 20:48:02

一、安装环境

[[email protected]_haobin ~]# more /etc/redhat-release
Red Hat Enterprise Linux Server release 7.0 (Maipo)

二、基于yum方式安装httpd、php、mariadb

[[email protected]_haobin ~]# yum -y install httpd
[[email protected]_haobin ~]# yum -y install mariadb-server
[[email protected]_haobin ~]# yum -y install php php-mysql

验证安装包

[[email protected]_haobin ~]# rpm -qa|grep httpd
httpd-2.4.6-17.el7.x86_64
httpd-tools-2.4.6-17.el7.x86_64

[[email protected]_haobin ~]# rpm -qa|grep php
php-pdo-5.4.16-21.el7.x86_64
php-common-5.4.16-21.el7.x86_64
php-mysql-5.4.16-21.el7.x86_64
php-5.4.16-21.el7.x86_64
php-cli-5.4.16-21.el7.x86_64

[[email protected]_haobin ~]# rpm -qa|grep maria
mariadb-5.5.35-3.el7.x86_64
mariadb-server-5.5.35-3.el7.x86_64
mariadb-libs-5.5.35-3.el7.x86_64

启动httpd

[[email protected]_haobin ~]# systemctl start httpd

验证httpd

[[email protected]_haobin ~]# echo “The httpd is running.”>/var/www/html/index.html

在浏览器输入http://localhost 出现下面的页面则说明httpd安装成功
Redhat快速安装LAMP和WordPress

启动mariadb

[[email protected]_haobin ~]# systemctl start mariadb

验证mariadb

[[email protected]_haobin ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]> show variables like ‘version’;
+—————+—————-+
| Variable_name | Value |
+—————+—————-+
| version | 5.5.35-MariaDB |
+—————+—————-+
1 row in set (0.01 sec)

MariaDB [(none)]> exit
Bye

测试php

[[email protected]_haobin ~]# echo ”
The PHP is running.
?php
phpinfo();
?>
“>/var/www/html/index.php

在浏览器输入http://localhost/index.php出现下面的页面则说明php安装成功

Redhat快速安装LAMP和WordPress

三、安装及配置Wordpress

将WordPress上传到服务器

[[email protected]_haobin Desktop]# ll
total 9032
-rw-r–r–. 1 root root 9245300 Dec 11 16:04 wordpress-4.7.4-zh_CN.zip

解压WordPress,并解压到/var/www/html/目录下,并配置

[[email protected]_haobin Desktop]# unzip -q wordpress-4.7.4-zh_CN.zip -d /var/www/html/
[[email protected]_haobin Desktop]# cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
[[email protected]_haobin Desktop]# vim /var/www/html/wordpress/wp-config.php
/* WordPress数据库的名称 /
define(‘DB_NAME’, ‘wordpress’);

/* MySQL数据库用户名 /
define(‘DB_USER’, ‘admin’);

/* MySQL数据库密码 /
define(‘DB_PASSWORD’, ‘admin’);

/* MySQL主机 /
define(‘DB_HOST’, ‘localhost’);

/* 创建数据表时默认的文字编码 /
define(‘DB_CHARSET’, ‘utf8’);

/* 数据库整理类型。如不确定请勿更改 /
define(‘DB_COLLATE’, ”);

创建wordpress数据库及用户

[[email protected]_haobin Desktop]#mysql
MariaDB [(none)]> create database wordpress character set utf8;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on wordpress.* to ‘admin’@’localhost’ identified by ‘admin’;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

配置wordpress

打开浏览器完成wordpress配置
在浏览器输入http://localhost/wordpress

Redhat快速安装LAMP和WordPress

填写信息,点击安装WordPress

Redhat快速安装LAMP和WordPress

输入密码,点击登录

Redhat快速安装LAMP和WordPress

Redhat快速安装LAMP和WordPress

出现上面的页面证明WordPress已经安装完成了。