美文网首页GIT
从0到1搭建wordpress

从0到1搭建wordpress

作者: 冠冠从小爱学习 | 来源:发表于2017-10-17 17:59 被阅读99次

推荐一个很棒的网站腾讯云的开发者实验室

作者就是跟着开发者实验室的教程搭的第一个wordpress,教程很棒不过有些小坑,根据其教程略作修改如下,另外由于价格原因最终选了阿里云搭建本博客= =!


本实验用centos 6.8 64位系统,其他系统可能在linux命令有点差别


  • 安装Nginx

    • 用yum安装Nginx
      yum install nginx -y
    • 修改/etc/nginx/default.conf(nginx的默认配置,没啥用,后面会被代替),去除对IPv6的监听,示例如下:

    CentOS 6 不支持 IPv6,需要取消对 IPv6 地址的监听,否则 Nginx 不能成功启动。

    server {
        listen       80 default_server;
        # listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;
    
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
    
        location / {
        }
    
        error_page 404 /404.html;
            location = /40x.html {
        }
    
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    
    }
    
    • 修改完成后启动nginx:
      nginx
    • 此时,可访问本机外网ip 来确认是否已经安装成功。
      *将nginx设为开机启动:
      chkconfig nginx on
  • 安装Mysql

    • 使用yum安装Mysql:
      yum install mysql-server -y
    • 安装完成后,启动Mysql服务:
      service mysqld restart
    • 设置Mysql账户root密码:
      /usr/bin/mysqladmin -u root password 'yourPassword'
    • 将Mysql设置为开机启动:
      chkconfig mysqld on
    • 安装PHP
    • 使用 yum 安装PHP:
      yum install php-fpm php-mysql php-gd -y

    腾讯教程上未安装php-gd包会导致,在wordpress上传图片裁剪时报错

    • 启动php-fpm 进程(默认监听9000):
      service php-fpm start
    • 设置PHP-FPM 为开机启动
      chkconfig php-fpm on
    • 至此LNMP环境安装完成
  • 安装WordPress

    • 使用yum 安装WordPress
      yum install wordpress -y

    在/usr/share/press 可以看到wordpress的源码

    默认安装了最新版英文包,会导致在wordpress后台选网站语言选中文没反应,因为缺少中文语言包。
    解决方案:到网上下载一个中文版,将wordpress-content中的lanuages文件夹加入到服务器相同目录下(wordpress-content文件夹下)

  • 配置wordpress数据库

    • 进入Mysql,创建 wordpress 数据库
    mysql -uroot --password='yourPassword';
    CREATE DATABASE wordpress;
    exit
    
    • 在wordpress配置文件(/etc/wordpress/wp-config.php)中配置数据库,配置文件如下:
<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don't have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://codex.wordpress.org/Editing_wp-config.php
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'yourPassword');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');

/**#@-*/

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';

/**
 * See http://make.wordpress.org/core/2013/10/25/the-definitive-guide-to-disabling-auto-updates-in-wordpress-3-7
 */

/* Disable all file change, as RPM base installation are read-only */
define('DISALLOW_FILE_MODS', true);

/* Disable automatic updater, in case you want to allow
   above FILE_MODS for plugins, themes, ... */
define('AUTOMATIC_UPDATER_DISABLED', true);

/* Core update is always disabled, WP_AUTO_UPDATE_CORE value is ignore */

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the Codex.
 *
 * @link https://codex.wordpress.org/Debugging_in_WordPress
 */
define('WP_DEBUG', false);

/* That's all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', '/usr/share/wordpress');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');


  • 配置nginx

    • 配置nginx 将请求转发给php
    • 删掉default.conf 文件, 在/etc/nginx/conf.d 创建wordpress.conf,文件内容如下:
    server {
        listen 80;
        root /usr/share/wordpress;
        location / {
            index index.php index.html index.htm;
            try_files $uri $uri/ /index.php index.php;
        }
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ .php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME      $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
    
    • 重启nginx,加载配置
      nginx -s reload

    如果有域名的话可以在wordpress 文件中配置,配置项 server_name www.yourdomain.com;

部署完成,通过ip访问地址: http://<您的域名>/wp-admin/install.php

域名购买,解析后续再说~
最后附上我搭建的博客,羞耻的域名~
网站没备案= =!被封了

相关文章

  • 从0到1搭建wordpress

    推荐一个很棒的网站腾讯云的开发者实验室 作者就是跟着开发者实验室的教程搭的第一个wordpress,教程很棒不过有...

  • 快速使用WordPress搭建个人博客

    突然想做一个个人网站,于是花了点时间纠结从0到1自己写一个还是用WordPress快速搭建,最终选择了WordPr...

  • week_11_基于amp搭建wordpress和phpmyad

    Q: 1、编译安装搭建wordpress2、搭建php-admin A: 1、编译安装搭建wordpress 下载...

  • 从0到1制作WordPress主题#1WordPress安装

    WordPress安装 大多数人可能已经知道如何做到这一点,首先在电脑上下载安装XAMPP或者WAMP环境(不懂得...

  • 网站搭建,从0到1

    第一步:购买域名、服务器、DNS解析 这里我们是在准备做一个网站的原材料,这三样缺一不可。目前来说,可以租用的虚拟...

  • iOS 外链技术网站集合

    1. iOS 从0到1搭建高效用App框架

  • 从0到1搭建大数据平台之计算存储系统

    前面已经给大家讲了《从0到1搭建大数据平台之数据采集系统》、《从0到1搭建大数据平台之调度系统》,今天给大家讲一下...

  • 2019-09-02

    wordpress 环境搭建 0.本地环境搭建 0.1准备工作:安装XMAPP环境 0.1.2 XAMPP保存路径...

  • 如何从0到1搭建自己的超级生态社群

    如何从0到1搭建自己的超级生态社群 见 让你立刻成为超级群主从以下两个维度出发: ①如何为自己搭建从0到1的超生态...

  • 从0到0,从0到1。

    昨天和一客户交流,听到这么一句话,我现在的阶段勉强算0到0的阶段,到那个1的阶段还没有看到,或者说并不知道那个1在...

网友评论

    本文标题:从0到1搭建wordpress

    本文链接:https://www.haomeiwen.com/subject/smaduxtx.html