前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS 7 基于yum方式快速搭建LAMP wordpress

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

作者头像
Leshami
发布2018-08-06 10:44:18
7320
发布2018-08-06 10:44:18
举报
文章被收录于专栏:乐沙弥的世界

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

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

一、安装LAMP

代码语言:javascript
复制
当前环境
[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,fd=4),
("httpd",pid=120701,fd=4),("httpd",pid=120700,fd=4),("httpd",pid=120699,fd=4),("httpd",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

代码语言:javascript
复制
[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后,即可登陆到后台管理面版

主页界面

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017年10月11日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、安装LAMP
  • 二、安装及配置wordpress
相关产品与服务
云数据库 MariaDB
腾讯云数据库 MariaDB(TencentDB for MariaDB) 让您轻松在云端部署、使用 MariaDB 数据库。MariaDB 是在 MySQL 版权被 Oracle 收购后,由 MySQL 创始人 Monty 创立,其版权授予了“MariaDB基金会(非营利性组织)”以保证 MariaDB 永远开源,良好的开源策略,是企业级应用的最优选择,主流开源社区系统/软件的数据库系统,均已默认配置 MariaDB。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档