Skip to content

天楚锐齿

人工智能 云计算 大数据 物联网 IT 通信 嵌入式

天楚锐齿

  • 下载
  • 物联网
  • 云计算
  • 大数据
  • 人工智能
  • Linux&Android
  • 网络
  • 通信
  • 嵌入式
  • 杂七杂八

安装WordPress来建立公司网站和个人博客网站

2018-03-22

安装:

环境:CentOS7.3
下载 wordpress-4.9.4.tar.gz
安装mysql:
# yum install mariadb-server
# vi /etc/my.cnf
…
# mysql_install_db –user=mysql –datadir=/data/MariaDB_DATA/
# systemctl start mariadb
建立新用户和设置root密码:
# mysqladmin -u root password ‘xxxxx’
# mysql -uroot -p
MariaDB [(none)]> create database wordpress;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress.* TO wordpress@”localhost” IDENTIFIED BY “xxxxx”;
安装apache:
# yum install httpd
安装php:
# yum install php
# yum install php-mysql
增大文件上传大小限制:
# vi /etc/httpd/conf.d/php.conf
尾部增加:
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300
启动apache:
# systemctl start httpd
测试:
放入/var/www/htm/test.php:
<?php
phpinfo();
?>
访问:http://xxx.xx.xx.xx/test.php
可以看到php的各类信息,包括mysql连接信息。
安装wordpress:
# tar -zxvf wordpress-4.9.4.tar.gz
# mv wordpress /var/www/html/blog
然后访问:http://xxx.xx.xxx.xx/blog/ ,按照提示操作。

模板:

使用“Responsiveness”主题模板themes,也可以选择其他自己喜欢的模板,如果是公司网站,最好选择不带右侧sidebar的模板。

修改:

增加撰写编辑文章时字体设置等功能,在管理页面的“外观”->“编辑”->选择: 模板函数 (functions.php),底部添加:
function add_editor_buttons($buttons) {
$buttons[] = ‘fontselect’;
$buttons[] = ‘fontsizeselect’;
$buttons[] = ‘backcolor’;
$buttons[] = ‘underline’;
$buttons[] = ‘hr’;
$buttons[] = ‘sub’;
$buttons[] = ‘sup’;
$buttons[] = ‘cut’;
$buttons[] = ‘copy’;
$buttons[] = ‘paste’;
$buttons[] = ‘cleanup’;
$buttons[] = ‘wp_page’;
$buttons[] = ‘newdocument’;
return $buttons;
}
add_filter(“mce_buttons_2”, “add_editor_buttons”);
去掉sidebar里面“功能”部分的Wordpress.org链接:
# vi wp-includes/widgets/class-wp-widget-meta.php
…
                        <ul>
                        <?php wp_register(); ?>
<!– Max Shu modify on 2018/3/10
                        <li><?php wp_loginout(); ?></li>
–>
                        <li><a href=”<?php echo esc_url( get_bloginfo( ‘rss2_url’ ) ); ?>”><?php _e(‘Entries <abbr title=”Really Simple Syndication”>RSS</abbr>’); ?></a></li>
                        <li><a href=”<?php echo esc_url( get_bloginfo( ‘comments_rss2_url’ ) ); ?>”><?php _e(‘Comments <abbr title=”Really Simple Syndication”>RSS</abbr>’); ?></a></li>
                        <?php
                        /**
                         * Filters the “Powered by WordPress” text in the Meta widget.
                         *
                         * @since 3.6.0
                         * @since 4.9.0 Added the `$instance` parameter.
                         *
                         * @param string $title_text Default title text for the WordPress.org link.
                         * @param array  $instance   Array of settings for the current widget.
                         */
/* Max Shu modify on 2018/3/10
                        echo apply_filters( ‘widget_meta_poweredby’, sprintf( ‘<li><a href=”%s” title=”%s”>%s</a></li>’,
                                esc_url( __( ‘https://wordpress.org/’; ) ),
                                esc_attr__( ‘Powered by WordPress, state-of-the-art semantic personal publishing platform.’ ),
                                _x( ‘WordPress.org‘, ‘meta widget link text’ )
                        ), $instance );
*/
                        wp_meta();
                        ?>
                        </ul>
…
修改评论部分标题:
# vi ./wp-content/themes/responsiveness/comments.php
                <h3 class=”comments-title”>
                        <?php
                                $comment_number = get_comments_number();
                                $comment_locale = number_format_i18n( $comment_number );
/* Max Shu modify on 2018/3/10
                                if ( ‘1’ === $comment_number ) {
                                        esc_html_e( ‘One comment’, ‘responsiveness’ );
                                } else {
                                        // translators: %s: number of comments
                                        printf( esc_html( _n( ‘%s Commment’, ‘%s Commments’, $comment_locale, ‘responsiveness’ ) ), $comment_locale ); // WPCS: XSS OK.
                                }
*/
printf( esc_html( _n( ‘%s条评论’, ‘%s Commments’, $comment_locale, ‘responsiveness’ ) ), $comment_locale );
                        ?>
                </h3>
Responsiveness: 样式表 (style.css) 选择要编辑的主题(有必要的话):
h2.comments-title {
    text-align: center;
    font-weight: 600;
    color: #333
}
Responsiveness: 样式表 (style.css) 给每个段落的开头增加两个字的缩进:
.entry-content p {
    text-indent:2em;
    margin: 1.5rem 0
}
修改“Continue Reading”按钮为中文:
# vi ./wp-content/themes/responsiveness/inc/template-tags.php
function responsiveness_fancy_excerpt() {
    global $post;
    if( is_archive() ) {
        echo ‘<div class=”continue-reading”>’;
        echo ‘<a class=”more-link more-link-activated” href=”‘ . esc_url( get_permalink() ) . ‘” title=”‘ . esc_html__( ‘继续阅读 ‘, ‘responsiveness’ ) . get_the_title() . ‘” rel=”bookmark”>’ . esc_html__( ‘继续阅读’, ‘responsiveness’ ) . ‘</a>’;
        echo ‘</div>’;
    } elseif ( is_page_template( ‘page-templates/page-child-pages.php’ ) ) {
        the_excerpt();
         echo ‘<div class=”continue-reading”>’;
        echo ‘<a class=”continue-reading-arrow” href=”‘ . esc_url( get_permalink() ) . ‘” title=”‘ . esc_html__( ‘继续阅读 ‘, ‘responsiveness’ ) . get_the_title() . ‘” rel=”bookmark”>&rarr;</a>’;
        echo ‘</div>’;
    } elseif ( has_excerpt() || is_page_template( ‘page-templates/frontpage-portfolio.php’ ) ) {
        the_excerpt();
        echo ‘<div class=”continue-reading”>’;
        echo ‘<a class=”more-link more-link-activated” href=”‘ . esc_url( get_permalink() ) . ‘” title=”‘ . esc_html__( ‘继续阅读 ‘, ‘responsiveness’ ) . get_the_title() . ‘” rel=”bookmark”>’ . esc_html__( ‘继续阅读’, ‘responsiveness’ ) . ‘</a>’;
        echo ‘</div>’;
    } elseif ( strpos ( $post->post_content, ‘<!–more–>’ ) ) {
        the_content();
                echo ‘<div class=”continue-reading”>’;
        echo ‘<a class=”more-link more-link-activated” href=”‘ . esc_url( get_permalink() ) . ‘” title=”‘ . esc_html__( ‘继续阅读 ‘, ‘responsiveness’ ) . get_the_title() . ‘” rel=”bookmark”>’ . esc_html__( ‘继续阅读’, ‘responsiveness’ ) . ‘</a>’;
        echo ‘</div>’;
    } elseif ( str_word_count ( $post->post_content ) < 200 ) {
        the_content();
    } else {
        the_excerpt();
        echo ‘<div class=”continue-reading”>’;
        echo ‘<a class=”more-link more-link-activated” href=”‘ . esc_url( get_permalink() ) . ‘” title=”‘ . esc_html__( ‘继续阅读 ‘, ‘responsiveness’ ) . get_the_title() . ‘” rel=”bookmark”>’ . esc_html__( ‘继续阅读’, ‘responsiveness’ ) . ‘</a>’;
        echo ‘</div>’;
    }
}
修改“Previous Post:”“Next Post:”为中文:
# vi ./wp-content/themes/responsiveness/inc/template-tags.php
    <nav class=”navigation post-navigation” role=”navigation”>
        <p class=”screen-reader-text”><?php esc_html_e( ‘Post navigation’, ‘responsiveness’ ); ?></p>
        <div class=”nav-links” data-equalizer>
                <?php
                        previous_post_link( ‘<div class=”nav-previous” data-equalizer-watch><div class=”nav-indicator”>’ . esc_html_x( ‘前一篇:’, ‘Previous post’, ‘responsiveness’ ) . ‘<
/div><h4>%link</h4></div>’, ‘%title’ );
                        next_post_link(     ‘<div class=”nav-next” data-equalizer-watch><div class=”nav-indicator”>’     . esc_html_x( ‘后一篇:’, ‘Next post’, ‘responsiveness’ ) . ‘</div
><h4>%link</h4></div>’, ‘%title’ );
                ?>
        </div> <!– .nav-links –>
    </nav> <!– .navigation –>
页面加入meta信息:
# vi ./wp-content/themes/responsiveness/header.php
<html <?php language_attributes(); ?>>
<head>
<meta http-equiv=”X-UA-Compatible” content=”IE=edge,chrome=1″>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<meta name=”keywords” content=”人工智能,云计算,大数据,物联网,IT,通信,嵌入式” />
<meta name=”description” content=”天楚,锐齿,天楚锐齿,锐齿咨询,见龙在天,Adai,Max Shu;从事人工智能、云计算、大数据、物联网、IT、通信、嵌入式研发。” />
<meta name=”author” content=”Max Shu” />
  <meta charset=”<?php bloginfo( ‘charset’ ); ?>”>
增加手工上传文件的目录,用来保存视频等特别大的文件:
# mkdir /var/www/html/blog/./upload_manual
# chown -R apache:apache ./upload_manual
通过管理后台上传媒体文件的保存位置:
./wp-content/uploads/
修改后台管理页面上传文档的大小限制:
# vi /etc/httpd/conf.d/php.conf
尾部增加,然后重启httpd:
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300

插件:

Dyanomic QR Code Generator:
在“外观”“小工具”里面“Sidebar”的About This site(个人介绍)增加短代码:
扫描二维码分享该文章(反斜杠不需要):
[d\q\r_c\o\d\e]
修改以下代码以在sidebar方式下产生首页二维码(估计是bug):
# vi ./wp-content/plugins/dynamic-qr-code-generator/dynamic_qr_code_generator.php
    public function shortcode_dqr_code($atts)
    {
        $args = shortcode_atts( array(
            ‘post_id’ => ‘0’,
            ‘url’ => ”,
            ‘size’ =>’200′,
            ‘color’ =>’#000000′,
            ‘bgcolor’=> ‘#ffffff’
        ), $atts );
        if($args[‘url’]==”){
            if($args[‘post_id’]==”0″){
                //no url or post id provided in shortcode return current page permalink
                $url= get_permalink();
if (empty($url)){ $url= ‘http://www.max-shu.com/blog/’;}
                $js_id=”qrcode-current”;
            }else{
                $url= get_permalink($args[‘post_id’]);
                $js_id=”qrcode-“.$args[‘post_id’];
            }
WP-PostViews:
设置中会出现一个“PostViews”的条目。
在“小工具”可以添加到sidebar,在“所有文章”处可以看到所有文章浏览量。
在编辑主题模板的single.php,加入以下代码,每篇文章尾部显示浏览量:
        <?php
        while ( have_posts() ) : the_post();
            get_template_part( ‘components/post/content’, get_post_format() );
            if(function_exists(‘the_views’)) { the_views(); }
            responsiveness_post_navigation();
            // If comments are open or we have at least one comment, load up the comment template.
            if ( comments_open() || get_comments_number() ) :
                comments_template();
            endif;
        endwhile; // End of the loop.
        ?>

最终sidebar显示:

1,180次阅读

Post navigation

前一篇:

PMP项目管理

后一篇:

使用find和cpio来备份或拷贝目录

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

个人介绍

需要么,有事情这里找联系方式:关于天楚锐齿

=== 美女同欣赏,好酒共品尝 ===

微信扫描二维码赞赏该文章:

扫描二维码分享该文章:

分类目录

  • Linux&Android (79)
  • Uncategorized (1)
  • 下载 (28)
  • 云计算 (37)
  • 人工智能 (8)
  • 大数据 (24)
  • 嵌入式 (34)
  • 杂七杂八 (34)
  • 物联网 (59)
  • 网络 (23)
  • 通信 (21)

文章归档

近期文章

  • 使用Python渲染OpenGL的.obj和.mtl文件
  • 用LVGL图形库绘制二维码
  • Android使用Messenger和SharedMemory实现跨app的海量数据传输
  • CAN信号的c语言解析代码
  • QT qml下DBus的使用例子

近期评论

  • 硕发表在《使用Android的HIDL+AIDL方式编写从HAL层到APP层的程序》
  • maxshu发表在《使用Android的HIDL+AIDL方式编写从HAL层到APP层的程序》
  • Ambition发表在《使用Android的HIDL+AIDL方式编写从HAL层到APP层的程序》
  • Ambition发表在《使用Android的HIDL+AIDL方式编写从HAL层到APP层的程序》
  • maxshu发表在《Android9下用ethernet 的Tether模式来做路由器功能》

阅读量

  • 使用Android的HIDL+AIDL方式编写从HAL层到APP层的程序 - 16,804次阅读
  • 卸载深信服Ingress、SecurityDesktop客户端 - 12,078次阅读
  • 车机技术之Android Automotive - 6,661次阅读
  • 车机技术之车规级Linux-Automotive Grade Linux(AGL) - 5,860次阅读
  • Linux策略路由及iptables mangle、ip rule、ip route关系及一种Network is unreachable错误 - 5,709次阅读
  • 在Android9下用ndk编译vSomeIP和CommonAPI以及使用例子 - 5,658次阅读
  • linux下的unbound DNS服务器设置详解 - 5,601次阅读
  • linux的tee命令导致ssh客户端下的shell卡住不动 - 4,998次阅读
  • 车机技术之360°全景影像(环视)系统 - 4,897次阅读
  • libwebp(处理webp图像)的安装和使用 - 4,749次阅读

功能

  • 文章RSS
  • 评论RSS

联系方式

地址
深圳市科技园

时间
周一至周五:  9:00~12:00,14:00~18:00
周六和周日:10:00~12:00

标签

android AT命令 centos Hadoop hdfs ip ipv6 kickstart linux mapreduce mini6410 modem OAuth openstack os python socket ssh uboot 内核 协议 安装 嵌入式 性能 报表 授权 操作系统 数据 数据库 月报 模型 汽车 测试 深信服 深度学习 源代码 神经网络 统计 编译 网络 脚本 虚拟机 调制解调器 车机 金融
© 2023 天楚锐齿