CentOS 7 基于yum方式快速搭建LAMP wordpress

前端之家收集整理的这篇文章主要介绍了CentOS 7 基于yum方式快速搭建LAMP wordpress前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

LAMP是流行的经典快速部署互联网应用的标配。 它的全称是Linux+Apache+MysqL+PHP。之前写过基于CentOS6下编译以及yum方式搭建LAMP。本次主要主要是基于CentOS7来描述,同时演示了在该架构下安装wordpress,供大家参考。

有关CentOS 6下搭建文章可参考:
Linux 6 下yum方式安装配置LAMP平台
Linux 6下编译安装配置LAMP平台

一、安装LAMP

当前环境
[root@centos7-web ~]# more /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 

基于yum方式安装httpd,PHP,mariadb
[root@centos7-web ~]# yum install httpd -y
[root@centos7-web ~]# yum install PHP PHP-MysqL -y 
[root@centos7-web ~]# yum install mariadb-server -y

验证相关安装包
[root@centos7-web ~]# rpm -qa|grep httpd
httpd-2.4.6-40.el7.centos.x86_64
httpd-tools-2.4.6-40.el7.centos.x86_64

[root@centos7-web ~]# rpm -qa|grep PHP
PHP-cli-5.4.16-36.el7_1.x86_64
PHP-MysqL-5.4.16-36.el7_1.x86_64
PHP-common-5.4.16-36.el7_1.x86_64
PHP-pdo-5.4.16-36.el7_1.x86_64
PHP-5.4.16-36.el7_1.x86_64

[root@centos7-web ~]# rpm -qa|grep maria
mariadb-libs-5.5.44-2.el7.centos.x86_64
mariadb-server-5.5.44-2.el7.centos.x86_64
mariadb-5.5.44-2.el7.centos.x86_64

启动及验证httpd
[root@centos7-web ~]# systemctl start httpd
[root@centos7-web ~]# ss -nltp|grep httpd
LISTEN    0    128   :::80  :::*      users:(("httpd",pid=120703,fd=4),("httpd",pid=120702,pid=120701,pid=120700,pid=120699,pid=120688,fd=4))

[root@centos7-web ~]# echo "This is a httpd test page.">/var/www/html/index.html
[root@centos7-web ~]# curl http://localhost
This is a httpd test page.

启动及验证mariadb
[root@centos7-web ~]# rpm -ql mariadb-server|grep service
/usr/lib/systemd/system/mariadb.service

[root@centos7-web ~]# systemctl start mariadb.service
[root@centos7-web ~]# MysqL
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.44-MariaDB MariaDB Server

Copyright (c) 2000,2015,Oracle,MariaDB Corporation 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.44-MariaDB |
+---------------+----------------+
1 row in set (0.00 sec)

MariaDB [(none)]> show databases;

+--------------------+
| Database          |
+--------------------+
| information_schema |
| MysqL              |
| performance_schema |
| test              |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> exit
Bye

测试PHP
    由于当前PHP使用模块化方式被装载到httpd,因此无需单独启动及设置PHP,如下可以检测到已加载PHP5模块以及rewrite模块
[root@centos7-web ~]# httpd -M|grep PHP
PHP5_module (shared)
[root@centos7-web ~]# httpd -M|grep rewrite
rewrite_module (shared)

[root@centos7-web ~]# echo " 
<html>
<h1>This is a PHP test page.</h1>
<?PHP PHPinfo(); ?>
</html>">/var/www/html/index.PHP 

[root@centos7-web ~]# curl http://localhost/index.PHP
<html>
<h1>This is a PHP test page.</h1>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<style type="text/css"> body {background-color: #ffffff; color: #000000;} body,td,th,h1,h2 {font-family: sans-serif;} pre {margin: 0px; font-family: monospace;} a:link {color: #000099; text-decoration: none; background-color: #ffffff;} a:hover {text-decoration: underline;} table {border-collapse: collapse;} ............. 验证PHP连接mariadb数据库 [root@centos7-web ~]# vim /var/www/html/connMysqL.PHP <?PHP $conn if ($conn echo "succ"; else echo " MysqL_close(); ?> [root@centos7-web ~]# curl http://localhost/connMysqL.PHP succ

二、安装及配置wordpress

[root@centos7-web ~]# cd /usr/local/src
[root@centos7-web src]# ls -hltr
total 8.3M
-rw-r--r-- 1 root root 8.3M Sep 22 17:17 wordpress-4.8.1-zh_CN.tar.gz

[root@centos7-web src]# tar -xf wordpress-4.8.1-zh_CN.tar.gz
[root@centos7-web src]# cp -R wordpress /var/www/html/

[root@centos7-web ~]# cp /var/www/html/wordpress/wp-config-sample.PHP /var/www/html/wordpress/wp-config.php
[root@centos7-web ~]# vim /var/www/html/wordpress/wp-config.php
###主要是配置数据库名及用户密码
/** wordpress数据库名称 */
define('DB_NAME','wpdb');

/** MysqL数据库用户名 */
define('DB_USER','wpadmin');

/** MysqL数据库密码 */
define('DB_PASSWORD','pass');

/** MysqL主机 */
define('DB_HOST','localhost');

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

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

创建wordpress数据库用户
[root@centos7-web ~]# MysqL

MariaDB [(none)]> create database wpdb character set utf8;
Query OK,1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on wpdb.* to 'wpadmin'@'localhost' identified by 'pass';
Query OK,0 rows affected (0.00 sec)

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

配置wordpress
打开浏览器完成wordpress配置

安装wordpress后,即可登陆到后台管理面版


主页界面

原文链接:https://www.f2er.com/centos/375629.html

猜你在找的CentOS相关文章