LAMP的环境原理 wordpress 搭建流程

小白入门,简单介绍LAMP的什么以及工作方式。

LAMP的环境原理

LAMP:是由Linux、Apache(httpd)、MySQL/MariaDB和PHP/Perl/Python这些开源软件所搭建起来的web应用平台。平台主机可以是独立的也可以在一台主机上

image

访问流程:客户端访问web服务,web服务器遵循二八法则直接将大部分静态访问资源反馈给客户,如果是动态资源则通过FastCGI协议调用php程序获取数据库的数据处理成为静态资源在返回给客户。

LAMP:web平台的搭配:

web服务器 脚本 数据库
httpd / nginx PHP:fpm Mysql
jsp:tomcat MariaDB
Python:Django
ruby:ror

使用一台主机搭建 wordpress博客

1、安装web服务器(httpd)

  1. [root@ ~]# yum -y install httpd
  2. 配置:
  3. [root@ ~]# vim /etc/httpd/conf/httpd.conf
  4. ServerName www.example.com:80 去掉注释
  5. [root@ ~]# httpd -t 检查语法错误
  6. [root@ ~]# systemctl start httpd.service 启动服务
  7. [root@ ~]# ss -tnl 查看端口
  8. State Recv-Q Send-Q Local Address:Port Peer Address:Port
  9. LISTEN 0 128 *:80 *:*
  10. LISTEN 0 128 *:22 *:*

2、安装脚本php-fpm

  1. [root@ ~]# yum -y install php

3、安装数据库,创建数据库 wordpress,用户名 admin,密码 admin

  1. [root@ ~]# yum -y install mariadb-server
  2. [root@ ~]# mysql
  3. ...
  4. ...
  5. MariaDB [(none)]> GRANT ALL ON wordpress.* TO 'admin'@'%' IDENTIFIED BY 'admin';
  6. MariaDB [(none)]>exit
  7. Bye
创建格式:GRANT ALL ON wordpress.* ‘user’@’IP’ IDENTIFIED BY ‘password’

IP域限制例如172.16.%.% ,172.16.1.% ;

测试:

  1. [root@ ~]# mysql -uadmin -h192.168.1.2 -padmin
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is 3
  4. Server version: 5.5.56-MariaDB MariaDB Server
  5. Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
  6. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  7. MariaDB [(none)]> exit
  8. Bye

4、安装扩展php-mysql

  1. [root@ ~]# yum -y install php-mysql

5、配置安装 wordpress

1、wordpress博客是一个动态资源站点,当客户端访问时需要通过脚本服务器的php-fpm脚本来进行数据处理实现用户与站点的交互。

服务器环境要求
* PHP 5.2.4或更新版本
* MySQL 5.0或更新版本
* Apache mod_rewrite模块(可选,用于支持“固定链接”和“站点网络”功能)

  1. [root@ ~]# mkdir /wordpress
  2. [root@ ~]# cd /wordpress
  3. [root@ ~]# wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.zip
  4. [root@ ~]# unzip wordpress-4.9.4-zh_CN.zip
  5. [root@ ~]# cp -a wordpress /var/www/html/blog
  6. [root@ ~]# cd /var/www/html/blog
  7. [root@ ~]# cp wp-config-sample.php wp-config.php
  8. [root@ ~]# vim wp-config.php
  9. // ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
  10. /** WordPress数据库的名称 */
  11. define('DB_NAME', 'wordpress');
  12. /** MySQL数据库用户名 */
  13. define('DB_USER', 'admin');
  14. /** MySQL数据库密码 */
  15. define('DB_PASSWORD', 'admin');
  16. /** MySQL主机 */
  17. define('DB_HOST', '192.168.1.2');

6、浏览器打开进行安装配置即可

  • 登录主页:192.168.1.2/blog
  • 登录后台:192.168.1.2/blog/wp-login.php
注意:跳过域名解析 -如果服务器设置了域名解析,修改配置文件
  1. [root@ ~]# vim /etc/my.cnf.d/server.cnf
  2. 添加一项:
  3. skip-name-resolve=ON 跳过主机名解析。

关闭SELinux

  1. [root@localhost blog]# setenforce 0
  2. [root@localhost blog]# getenforce
  3. Permissive

马哥笔记 网络资料 网络资料2 网络资料3 百度百科 网络资料4 php-fpm是什么

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/101646

(2)
N28_刚好遇到小熊猫N28_刚好遇到小熊猫
上一篇 2018-06-24 23:32
下一篇 2018-06-25

相关推荐

  • N31-6

    网络简介及相关命令

    Linux笔记 2018-07-29
  • 系统启动

    1 第一步 POST:Power-On-Self-Test,加电自检 检查负责完成对CPU、主 板、内存、硬盘子系统、显示子系统、串并行接口、键盘、CD-ROM光驱等硬件情况的检测 2 选择第一个硬盘做为启动设备 在硬盘里找第一个扇区 (MBR) 446个字节 属于grub的 第一个阶段 统称为 bootloade 引导加载器 3 因为系统的启动程序都放在b…

    Linux笔记 2018-05-13
  • linux基础之自动登陆和自动开启网卡设置

    Centos7.4设置自动登陆以及设置网卡开机自动启用功能 1、进入命令行模式,输入 nano /etc/gdm/custom.conf ,在[daemon]下添加2条命令,分别是 AutomaticLoginEnable=true AutomaticLogin=root 2、然后按住Ctrl+X退出并保存,接着选择Y,再按回车键即可保存更改,到这里设置自动…

    2018-03-29
  • 第七周

    总结

    Linux笔记 2018-05-13
  • Linux系统启动流程详解

    Linux系统从按下电源键开始到系统启动要求用户输入用户名,中间究竟发生什么?了解Linux系统的启动流程,不仅有助于我们更加深入的理解linux底层设计理念,更能帮助我们再出现系统启动故障时,迅速排查出故障原因。

    2018-05-10
  • Linux运维初步—第三周

    Linux运维初步—第三周总结与练习 标签(空格分隔): linux入门 linux 运维 — 写作:N27_loong 2017-7-27[TOC] 一、本周主要内容回顾: 用户(组)管理: – 增加用户或组,指定用户权限、家目录路径、用户属组属主的变更; – 用户密码和组密码加密和验证的设计和文件存储位置;…

    Linux笔记 2018-07-27