LAMP平台-wordpress的搭建

                        LAMP平台-wordpress的搭建

                                              作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

 

  Linux+Apache+Mysql/MariaDB+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。

 

一.什么是PHP

   PHP是通用服务器端脚本编程语言,其主要用于web开发以实现动态web页面,它也是最早实现将脚本嵌入HTML源码文档中的服务器脚本语言之一。同时,PHP还提供了一个命令行接口,因此,其也可以在大多数系统上作为一个独立的shell来使用,在Linux上我们可以直接用yum的方式进行安装。PHP(外文名:PHP: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言语法吸收了C语言JavaPerl的特点,利于学习,使用广泛,主要适用于Web开发领域。

  PHP于1994年由Rasmus Lerdorf创建,刚刚开始是Rasmus Lerdorf为了要维护个人网页而制作的一个简单的用Perl语言编写的程序。这些工具程序用来显示 Rasmus Lerdorf 的个人履历,以及统计网页流量。后来又用C语言重新编写,包括可以访问数据库。他将这些程序和一些表单直译器整合起来,称为 PHP/FI。PHP/FI 可以和数据库连接,产生简单的动态网页程序。

 

二.PHP的开源项目

  互联网上有很多PHP的开源项目用来提供PHP格式的网站。比如discuz(论坛网站,他有一个好干爹,即腾讯),之所以找是因为他的竞争对手phpwind(这样是一个开源的PHP论坛程序)hpwind和discuz都是国人开发的,而在的就是,国人用的比较少,外国人用的倒是不少,不过phpbb现在已经被汉化了,对中文的支持也不错。

1.论坛程序

  a>.phpwind是杭州的一家公司,它找了一个好干爹就是阿里巴巴。

  b>.discuz是phpwind竞争对手,看人家phpwind找了一个好干爹,自己也不甘寂寞,就找了腾讯做干爹,哈哈~这是一个拼爹的年代。

  c>.phpbb是全球比较流行,国人用的比较少,外国人用的倒是不少,不过phpbb现在已经被汉化了,对中文的支持也不错。

  phpwind和discuz都是国人开发的,没错,不知道为什么自己就是相当的自豪,尽管我不是PHP程序员。phpbb是外国人开发的,在全球的影响力还是相当不错的哟。

2.博客系统

  WordPress后来成为了一个“生态系统”,它的作者也因此收入了数以千万美元的收入。WordPress本身也是开源的,围绕在WordPress背后形成了一个庞当的“生态圈”,有提供模板的,插件的,内容管理系统的(CMS)等等,我们可以去官网下载软件进行安装。https://cn.wordpress.org/

3.门户站点

  其实discuz就有门户站点的功能,国外也有drupal和xooms等等。这些都是开源的,因为我们都可以在网上下载下来安装测试,但是如果你想用这些软件进行营利的话,你可能就得向官方购买授权啦~

 

三.搭建wordpress博客系统

1.yum安装LAMP环境
  1 [root@yinzhengjie ~]# yum -y install php php-mysql mysql-server mysql 
 
2.启动msyqld服务
1 [root@yinzhengjie ~]# ls /var/lib/mysql/
2 [root@yinzhengjie ~]# service mysqld start                #第一次启动会自动初始化mysql数据库的。
3 [root@yinzhengjie ~]# ls /var/lib/mysql/                    #mysql的数据库目录在这里存放。
4 ibdata1  ib_logfile0  ib_logfile1  mysql  mysql.sock  test
5 [root@yinzhengjie ~]# 
3.验证是否可用启动成功
 1 [root@yinzhengjie ~]# mysql
 2 Welcome to the MySQL monitor.  Commands end with ; or \g.
 3 Your MySQL connection id is 3
 4 Server version: 5.1.73 Source distribution
 5 
 6 Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
 7 
 8 Oracle is a registered trademark of Oracle Corporation and/or its
 9 affiliates. Other names may be trademarks of their respective
10 owners.
11 
12 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
13 
14 mysql> select version();
15 +-----------+
16 | version() |
17 +-----------+
18 | 5.1.73    |
19 +-----------+
20 1 row in set (0.00 sec)
21 
22 mysql> \q
23 Bye
24 [root@yinzhengjie ~]# 

4.下载并安装wordpress软件

 1 [root@yinzhengjie ~]# wget https://cn.wordpress.org/wordpress-4.8.1-zh_CN.tar.gz
 2 [root@yinzhengjie ~]# tar -xf wordpress-4.8.1-zh_CN.tar.gz 
 3 [root@yinzhengjie ~]# cp wordpress/* /var/www/html/ -r         #我们解压完毕后,直接把解压的项目移动到web的根目录即可。
 4 [root@yinzhengjie html]# cp wp-config-sample.php wp-config.php
 5 [root@yinzhengjie html]# ll
 6 total 192
 7 -rw-r--r--.  1 root root   418 Nov 11 11:37 index.php
 8 -rw-r--r--.  1 root root 19935 Nov 11 11:37 license.txt
 9 -rw-r--r--.  1 root root  6956 Nov 11 11:37 readme.html
10 -rw-r--r--.  1 root root  5447 Nov 11 11:37 wp-activate.php
11 drwxr-xr-x.  9 root root  4096 Nov 11 11:37 wp-admin
12 -rw-r--r--.  1 root root   364 Nov 11 11:37 wp-blog-header.php
13 -rw-r--r--.  1 root root  1627 Nov 11 11:37 wp-comments-post.php
14 -rw-r--r--.  1 root root  2917 Nov 11 11:43 wp-config.php
15 -rw-r--r--.  1 root root  2930 Nov 11 11:37 wp-config-sample.php
16 drwxr-xr-x.  5 root root  4096 Nov 11 11:37 wp-content
17 -rw-r--r--.  1 root root  3286 Nov 11 11:37 wp-cron.php
18 drwxr-xr-x. 18 root root 12288 Nov 11 11:37 wp-includes
19 -rw-r--r--.  1 root root  2422 Nov 11 11:37 wp-links-opml.php
20 -rw-r--r--.  1 root root  3301 Nov 11 11:37 wp-load.php
21 -rw-r--r--.  1 root root 34327 Nov 11 11:37 wp-login.php
22 -rw-r--r--.  1 root root  8048 Nov 11 11:37 wp-mail.php
23 -rw-r--r--.  1 root root 16200 Nov 11 11:37 wp-settings.php
24 -rw-r--r--.  1 root root 29924 Nov 11 11:37 wp-signup.php
25 -rw-r--r--.  1 root root  4513 Nov 11 11:37 wp-trackback.php
26 -rw-r--r--.  1 root root  3065 Nov 11 11:37 xmlrpc.php
27 [root@yinzhengjie html]# 

5.编辑workpress的配置文件

1 [root@yinzhengjie html]# more wp-config.php  | grep DB_NAME
2 define('DB_NAME', 'yinzhengjie');     ------>在配置文件我们可以明显的看到中文提示,这里是设置连接数据库名称
3 [root@yinzhengjie html]# more wp-config.php  | grep DB_USER
4 define('DB_USER', 'yinzhengjie');   ——----->连接数据库的用户名
5 [root@yinzhengjie html]# more wp-config.php  | grep DB_PASSWORD
6 define('DB_PASSWORD', 'wordpress');  -------->连接数据库的密码
7 [root@yinzhengjie html]# more wp-config.php  | grep DB_HOST
8 define('DB_HOST', '10.0.0.115');      -------->连接数据库的IP,因此我们在MySQL授权的时候要注意IP地址的网段哟! 
9 [root@yinzhengjie html]#     

6.在MySQL服务器上进行授权

 1 [root@yinzhengjie ~]# more grant_wordpress.sql 
 2 #!/bin/bash
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie
 5 #EMAIL:y1053419035@qq.com
 6 
 7 #创建wordpress存放的数据库目录
 8 create database yinzhengjie;
 9 
10 #创建用户并授权wrodpress
11 grant all privileges on yinzhengjie.* to 'yinzhengjie'@'10.%.%.%' identified by 'wordpress';
12 
13 #通知MySQL服务重读授权表,让授权立即生效。
14 flush privileges;
15 
16 
17 [root@yinzhengjie ~]# 
18 [root@yinzhengjie ~]# mysql < grant_wordpress.sql   #此处我们采用的是批处理模式连接去执行数据库,想要了解更多关于mysql的执行模式,请参考:http://www.cnblogs.com/yinzhengjie/p/7818092.html
19 [root@yinzhengjie ~]# 

 7.启动httpd服务器

 1 [root@yinzhengjie ~]# iptables -X
 2 [root@yinzhengjie ~]# iptables -F
 3 [root@yinzhengjie ~]# service iptables save
 4 iptables: Saving firewall rules to /etc/sysconfig/iptables: [  OK  ]
 5 [root@yinzhengjie ~]# service iptables stop
 6 iptables: Setting chains to policy ACCEPT: filter [  OK  ]
 7 iptables: Flushing firewall rules: [  OK  ]
 8 iptables: Unloading modules: [  OK  ]
 9 [root@yinzhengjie ~]# 
10 [root@yinzhengjie ~]# chkconfig iptables off
11 [root@yinzhengjie ~]# chkconfig iptables --list   #以上步骤是关闭防火墙
12 iptables        0:off   1:off   2:off   3:off   4:off   5:off   6:off
13 [root@yinzhengjie ~]# 
14 [root@yinzhengjie ~]# setenforce 0
15 [root@yinzhengjie ~]# getenforce          #这里是关闭SELinux。
16 Permissive
17 [root@yinzhengjie ~]# 
18 [root@yinzhengjie ~]# service httpd start     #启动web服务器
19 Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
20 [  OK  ]
21 [root@yinzhengjie ~]# 

8.客户端安装

 

点击登录

输入用户名和密码即可完成登录

登录成功的界面

 当然你可以也可以通过首页登录

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值