LAMP实战之构建博客网站

1、首先检查LAMP环境

[root@cairui htdocs]# ps -ef | grep httpd
php      13160     1  0 Mar03 ?        00:00:00 /opt/apache2.2.34/bin/httpd -k start
root     19311     1  0 Mar03 ?        00:00:02 /opt/apache2.2.34/bin/httpd -k graceful
php      19401 19311  0 Mar03 ?        00:00:00 /opt/apache2.2.34/bin/httpd -k graceful
php      19402 19311  0 Mar03 ?        00:00:00 /opt/apache2.2.34/bin/httpd -k graceful
php      19403 19311  0 Mar03 ?        00:00:00 /opt/apache2.2.34/bin/httpd -k graceful
root     24835 24810  0 09:11 pts/0    00:00:00 grep httpd
[root@cairui htdocs]# ps -ef | grep mysql
root      1470     1  0 Mar01 ?        00:00:00 /bin/sh /opt/mysql-5.7.21/bin/mysqld_safe --datadir=/opt/mysql-5.7.21/data --pid-file=/opt/mysql-5.7.21/data/cairui.pid
mysql     1557  1470  0 Mar01 ?        00:02:51 /opt/mysql-5.7.21/bin/mysqld --basedir=/opt/mysql-5.7.21 --datadir=/opt/mysql-5.7.21/data --plugin-dir=/opt/mysql-5.7.21/lib/plugin --user=mysql --log-error=cairui.err --pid-file=/opt/mysql-5.7.21/data/cairui.pid
root     24837 24810  0 09:11 pts/0    00:00:00 grep mysql
[root@cairui htdocs]# lsof -i tcp:80
COMMAND     PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
AliYunDun  1335 root   18u  IPv4   9047      0t0  TCP 120.25.255.87:36408->106.11.68.13:http (ESTABLISHED)
httpd     19311 root    3u  IPv4 356362      0t0  TCP *:http (LISTEN)
httpd     19402  php    3u  IPv4 356362      0t0  TCP *:http (LISTEN)
httpd     19403  php    3u  IPv4 356362      0t0  TCP *:http (LISTEN)
[root@cairui htdocs]# lsof -i tcp:3306
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mysqld  1557 mysql   29u  IPv4   9380      0t0  TCP *:mysql (LISTEN)

2、配置博客软件(wordpress)

WordPress是使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL数据库的服务器上架设属于自己的网站。也可以把 WordPress当作一个内容管理系统(CMS)来使用。
WordPress是一款个人博客系统,并逐步演化成一款内容管理系统软件,它是使用PHP语言和MySQL数据库开发的。用户可以在支持 PHP 和 MySQL数据库的服务器上使用自己的博客。
WordPress有许多第三方开发的免费模板,安装方式简单易用。不过要做一个自己的模板,则需要你有一定的专业知识。比如你至少要懂的标准通用标记语言下的一个应用HTML代码、CSS、PHP等相关知识。
WordPress官方支持中文版,同时有爱好者开发的第三方中文语言包,如wopus中文语言包。WordPress拥有成千上万个各式插件和不计其数的主题模板样式。
[root@cairui software]# wget https://wordpress.org/latest.tar.gz
--2018-03-04 09:16:34--  https://wordpress.org/latest.tar.gz
Resolving wordpress.org... 198.143.164.252
Connecting to wordpress.org|198.143.164.252|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8565525 (8.2M) [application/octet-stream]
Saving to: “latest.tar.gz”

100%[=========================================================>] 8,565,525   2.83M/s   in 2.9s    

2018-03-04 09:16:38 (2.83 MB/s) - “latest.tar.gz” saved [8565525/8565525]

[root@cairui software]# ls
cmake-3.9.6         httpd-2.2.34         latest.tar.gz  libiconv-1.15.tar.gz  php-7.2.3
cmake-3.9.6.tar.gz  httpd-2.2.34.tar.gz  libiconv-1.15  mysql-5.7.21          php-7.2.3.tar.gz
[root@cairui software]# tar zxf latest.tar.gz 
[root@cairui software]# ls
cmake-3.9.6         httpd-2.2.34.tar.gz  libiconv-1.15.tar.gz  php-7.2.3.tar.gz
cmake-3.9.6.tar.gz  latest.tar.gz        mysql-5.7.21          wordpress
httpd-2.2.34        libiconv-1.15        php-7.2.3
[root@cairui software]# cd wordpress/
[root@cairui wordpress]# ls
index.php        wp-admin              wp-content         wp-load.php      wp-signup.php
license.txt      wp-blog-header.php    wp-cron.php        wp-login.php     wp-trackback.php
readme.html      wp-comments-post.php  wp-includes        wp-mail.php      xmlrpc.php
wp-activate.php  wp-config-sample.php  wp-links-opml.php  wp-settings.php
[root@cairui wordpress]# cd ..
[root@cairui software]# cp wordpress/* /opt/apache/htdocs/
cp: overwrite `/opt/apache/htdocs/index.php'? y
cp: omitting directory `wordpress/wp-admin'
cp: omitting directory `wordpress/wp-content'
cp: omitting directory `wordpress/wp-includes'
[root@cairui apache]# mv /home/cairui/software/wordpress/* /opt/apache/htdocs/

上述mv的原因是cp出错,查看错误日志

[Sun Mar 04 09:04:36 2018] [error] [client 114.239.215.144] File does not exist: /opt/apache2.2.34/htdocs/favicon.ico, referer: http://120.25.255.87/

缺少文件,所以cp无法全部拷贝,使用mv

输入120.25.255.87,进入wordpress设置

3、配置数据库

因为博客的安装需要用到数据库

mysql> create database wordpress default character set gbk collate gbk_chinese_ci;  #创建一个gbk数据库,默认是拉丁字符集
Query OK, 1 row affected (0.02 sec)

mysql> show databses;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'databses' at line 1
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| managerie          |
| mysql              |
| performance_schema |
| sys                |
| test               |
| wordpress          |
+--------------------+
7 rows in set (0.00 sec)

mysql> grant select,delete,insert,update,create on wordpress.* to wordpress@localhost identified by'wordpress';  #给用户wordpress设置权限
Query OK, 0 rows affected, 1 warning (0.08 sec)

mysql> flush privileges;  #刷新权限
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host from mysql.user;
+---------------+-----------+
| user          | host      |
+---------------+-----------+
| mysql.session | localhost |
| mysql.sys     | localhost |
| root          | localhost |
| wordpress     | localhost |
+---------------+-----------+
4 rows in set (0.00 sec)

mysql> show grants for wordpress@localhost;
+------------------------------------------------------------------------------------------+
| Grants for wordpress@localhost                                                           |
+------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'wordpress'@'localhost'                                            |
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE ON `wordpress`.* TO 'wordpress'@'localhost' |
+------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

权限不够,因为把httpd.conf用户改为了php

[root@cairui apache]# chown -R php.php /opt/apache/htdocs/
[root@cairui apache]# cd htdocs/
[root@cairui htdocs]# ls
index.php        wp-admin              wp-content         wp-load.php      wp-signup.php
license.txt      wp-blog-header.php    wp-cron.php        wp-login.php     wp-trackback.php
readme.html      wp-comments-post.php  wp-includes        wp-mail.php      xmlrpc.php
wp-activate.php  wp-config-sample.php  wp-links-opml.php  wp-settings.php
[root@cairui htdocs]# ll
total 188
-rw-r--r--  1 php php   418 Sep 25  2013 index.php
-rw-r--r--  1 php php 19935 Jan  7 03:32 license.txt
-rw-r--r--  1 php php  7413 Dec 12  2016 readme.html
-rw-r--r--  1 php php  5434 Sep 23 20:21 wp-activate.php
drwxr-xr-x  9 php php  4096 Feb  6 23:49 wp-admin
-rw-r--r--  1 php php   364 Dec 19  2015 wp-blog-header.php
-rw-r--r--  1 php php  1627 Aug 29  2016 wp-comments-post.php
-rw-r--r--  1 php php  2853 Dec 16  2015 wp-config-sample.php
drwxr-xr-x  4 php php  4096 Feb  6 23:49 wp-content
-rw-r--r--  1 php php  3669 Aug 20  2017 wp-cron.php
drwxr-xr-x 18 php php 12288 Feb  6 23:49 wp-includes
-rw-r--r--  1 php php  2422 Nov 21  2016 wp-links-opml.php
-rw-r--r--  1 php php  3306 Aug 22  2017 wp-load.php
-rw-r--r--  1 php php 36583 Oct 13 10:10 wp-login.php
-rw-r--r--  1 php php  8048 Jan 11  2017 wp-mail.php
-rw-r--r--  1 php php 16246 Oct  4 08:20 wp-settings.php
-rw-r--r--  1 php php 30071 Oct 19 01:36 wp-signup.php
-rw-r--r--  1 php php  4620 Oct 24 06:12 wp-trackback.php
-rw-r--r--  1 php php  3065 Sep  1  2016 xmlrpc.php
mysql> use wordpress
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-----------------------+
| Tables_in_wordpress   |
+-----------------------+
| wp_commentmeta        |
| wp_comments           |
| wp_links              |
| wp_options            |
| wp_postmeta           |
| wp_posts              |
| wp_term_relationships |
| wp_term_taxonomy      |
| wp_termmeta           |
| wp_terms              |
| wp_usermeta           |
| wp_users              |
+-----------------------+
12 rows in set (0.01 sec)

 错误:进入详情界面无法显示(原因,链接内包含中文,把链接改为英文即可)

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏乐沙弥的世界

理解 using backup controlfile

        using backup controlfile 通常用于恢复由于当前控制文件丢失且原来备份的控制文件较当前发生变化的情形之下。using ba...

11630
来自专栏杨建荣的学习笔记

11g Active DataGuard初探(r5笔记第54天)

原本dataguard中日志应用和数据库只读查询是一个互斥的关系,两者不能并存。如果需要应用日志,则数据库只能在Mount状态下 使用recover manag...

31270
来自专栏乐沙弥的世界

SHUTDOWN: Active processes prevent shutdown operation

      在使用shutdown immediate关闭数据库时hang住,查看alert 日志,遭遇了SHUTDOWN: Active processes ...

9820
来自专栏Hadoop实操

Hive Load本地数据文件异常分析

使用beeline登录HiveServer2向my_table表Load本地数据文件时报如下异常:

65040
来自专栏杨建荣的学习笔记

分分钟搭建MySQL一主多从环境(r12笔记第31天)

之前写过一篇分分钟搭建MySQL Group Replication的测试环境,如果我们在一台服务器上想搭建一主多从的测试环境,怎么能够分分钟搞定呢,其实...

38060
来自专栏battcn

一起来学SpringBoot | 第七篇:整合Mybatis

MyBatis 是一款优秀的持久层框架,它支持定制化 SQL、存储过程以及高级映射,几乎避免了所有的 JDBC 代码和手动设置参数以及获取结果集,使用简单的 X...

14420
来自专栏杨建荣的学习笔记

MySQL中使用undrop来恢复drop的表(上)

MySQL中可以使用编程语言(比如Python)来解析binlog中DML的逆操作来达到闪回的效果,如果数据不多,手工解析也可以。这也是现在大家碰到的很多DML...

43050
来自专栏DannyHoo的专栏

开发后期在各个页面中添加友盟统计

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010105969/article/details/...

31720
来自专栏耕耘实录

CentOS7中mysql-5.7.21-el7-x86_64.tar.gz版MySQL的安装与配置

版权声明:本文为耕耘实录原创文章,各大自媒体平台同步更新。欢迎转载,转载请注明出处,谢谢

9720
来自专栏pangguoming

springboot 项目mybatis plus 设置 jdbcTypeForNull (oracle数据库需配置JdbcType.NULL, 默认是Other)

45320

扫码关注云+社区

领取腾讯云代金券