LNMP应用之搭建个人博客

安装WordPress

[root@VM_88_143_centos ~]# yum install wordpress -y

安装包:

apr-1.3.9-5.el6_9.1.x86_64.rpm
apr-util-1.3.9-3.el6_0.1.x86_64.rpm
apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm
httpd-2.2.15-60.el6.centos.6.x86_64.rpm
httpd-tools-2.2.15-60.el6.centos.6.x86_64.rpm
libc-client-2007e-11.el6.x86_64.rpm
libicu-4.2.1-14.el6.x86_64.rpm
mailcap-2.1.31-2.el6.noarch.rpm
php-5.3.3-49.el6.x86_64.rpm
php-IDNA_Convert-0.8.0-1.el6.noarch.rpm
php-PHPMailer-5.2.26-1.el6.noarch.rpm
php-cli-5.3.3-49.el6.x86_64.rpm
php-fedora-autoloader-1.0.0-1.el6.noarch.rpm
php-gd-5.3.3-49.el6.x86_64.rpm
php-getid3-1.9.15-1.el6.noarch.rpm
php-imap-5.3.3-49.el6.x86_64.rpm
php-intl-5.3.3-49.el6.x86_64.rpm
php-mbstring-5.3.3-49.el6.x86_64.rpm
php-process-5.3.3-49.el6.x86_64.rpm
php-simplepie-1.3.1-3.el6.noarch.rpm
php-xml-5.3.3-49.el6.x86_64.rpm
wordpress-4.8.3-1.el6.noarch.rpm 

安装完成后,就可以在 /usr/share/wordpress 看到 WordPress 的源代码了

[root@VM_88_143_centos ~]# ll /usr/share/wordpress
total 160
-rw-r--r--  1 root root   418 Sep 25  2013 index.php
-rw-r--r--  1 root root  5447 Sep 28  2016 wp-activate.php
drwxr-xr-x  9 root root  4096 Dec 11 21:05 wp-admin
-rw-r--r--  1 root root   364 Dec 19  2015 wp-blog-header.php
-rw-r--r--  1 root root  1627 Aug 29  2016 wp-comments-post.php
lrwxrwxrwx  1 root root    36 Dec 11 21:05 wp-config.php -> ../../../etc/wordpress/wp-config.php
-rw-r--r--  1 root root  2853 Dec 16  2015 wp-config-sample.php
drwxr-xr-x  6 root root  4096 Dec 11 21:05 wp-content
-rw-r--r--  1 root root  3286 May 25  2015 wp-cron.php
drwxr-xr-x 16 root root 12288 Dec 11 21:05 wp-includes
-rw-r--r--  1 root root  2422 Nov 21  2016 wp-links-opml.php
-rw-r--r--  1 root root  3301 Oct 25  2016 wp-load.php
-rw-r--r--  1 root root 34327 May 13  2017 wp-login.php
-rw-r--r--  1 root root  8048 Jan 11  2017 wp-mail.php
-rw-r--r--  1 root root 16200 Apr  7  2017 wp-settings.php
-rw-r--r--  1 root root 29924 Jan 24  2017 wp-signup.php
-rw-r--r--  1 root root  4513 Oct 15  2016 wp-trackback.php
-rw-r--r--  1 root root  3065 Sep  1  2016 xmlrpc.php

配置数据库,进入 MySQL:

[root@VM_88_143_centos ~]# mysql -uroot --password='MyPas$word4Word_Press'
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (0.00 sec)

mysql> exit
Bye

把上述的 DB 配置同步到 WordPress 的配置文件中
进入目录:

[root@VM_88_143_centos ~]# cd /etc/wordpress/
[root@VM_88_143_centos wordpress]# ll
total 4
-rw-r----- 1 root apache 3215 Nov  1 13:46 wp-config.php

备份文件:

[root@VM_88_143_centos wordpress]# cp wp-config.php wp-config_back.php 

查看源文件:

[root@VM_88_143_centos wordpress]# cat 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', 'database_name_here');

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

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

/** 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');

修改文件:

[root@VM_88_143_centos wordpress]# vim wp-config.php 
[root@VM_88_143_centos wordpress]# cat 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', 'MyPas$word4Word_Press');

/** 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,WordPress 已经安装完毕,我们配置 Nginx 把请求转发给 PHP-FPM 来处理,首先,重命名默认的配置文件:

[root@VM_88_143_centos wordpress]# cd /etc/nginx/conf.d/
[root@VM_88_143_centos conf.d]# mv default.conf defaut.conf.bak
[root@VM_88_143_centos conf.d]# ll
total 12
-rw-r--r-- 1 root root 452 Dec 11 21:00 defaut.conf.bak
-rw-r--r-- 1 root root 686 Oct 31  2016 ssl.conf
-rw-r--r-- 1 root root 283 Oct 31  2016 virtual.conf

在 /etc/nginx/conf.d 创建 wordpress.conf 配置:

[root@VM_88_143_centos conf.d]# vim wordpress.conf
[root@VM_88_143_centos conf.d]# cat 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 进程重新加载:

[root@VM_88_143_centos conf.d]# nginx -s reload

查看源文件:

[root@VM_88_143_centos conf.d]# cd /usr/share/
[root@VM_88_143_centos share]# ll
total 320
drwxr-xr-x.   3 root root  4096 Nov  9  2016 abrt
drwxr-xr-x.   2 root root  4096 Nov  9  2016 aclocal
drwxr-xr-x.   8 root root  4096 Nov  9  2016 alsa
drwxr-xr-x.   3 root root  4096 Nov  9  2016 anaconda
drwxr-xr-x.   2 root root  4096 Nov  9  2016 applications
drwxr-xr-x.   3 root root  4096 Nov  9  2016 augeas
drwxr-xr-x.   2 root root  4096 Nov  9  2016 authconfig
drwxr-xr-x.   2 root root  4096 Nov  9  2016 awk
drwxr-xr-x.   2 root root  4096 Nov  9  2016 backgrounds
drwxr-xr-x.   2 root root  4096 Nov  9  2016 cracklib
drwxr-xr-x.   5 root root  4096 Nov  9  2016 dbus-1
drwxr-xr-x.   2 root root  4096 Sep 23  2011 desktop-directories
drwxr-xr-x.   2 root root  4096 Sep 23  2011 dict
drwxr-xr-x. 252 root root 12288 Dec 11 21:05 doc
drwxr-xr-x.   3 root root  4096 Nov  9  2016 dracut
drwxr-xr-x.   3 root root  4096 Nov  9  2016 emacs
dr-xr-xr-x.   2 root root  4096 Sep 23  2011 empty
drwxr-xr-x.   2 root root  4096 Nov  9  2016 file
drwxr-xr-x.   3 root root  4096 Nov  9  2016 firstboot
drwxr-xr-x    2 root root  4096 May 27  2014 fonts
drwxr-xr-x    2 root root  4096 Dec 11 21:03 fpm
drwxr-xr-x.   2 root root  4096 Sep 23  2011 games
drwxr-xr-x    2 root root  4096 Dec 11 20:59 GeoIP
drwxr-xr-x.   3 root root  4096 Nov  9  2016 ghostscript
drwxr-xr-x.   2 root root  4096 May 11  2016 glib-2.0
drwxr-xr-x.   2 root root  4096 Sep 23  2011 gnome
drwxr-xr-x.   2 root root  4096 Nov  9  2016 gnome-background-properties
drwxr-xr-x.   2 root root  4096 Nov  9  2016 gnupg
drwxr-xr-x.   4 root root  4096 Nov  9  2016 groff
drwxr-xr-x.   3 root root  4096 Nov  9  2016 grub
drwxr-xr-x.   3 root root  4096 Nov  9  2016 hwdata
drwxr-xr-x.   4 root root  4096 Nov  9  2016 i18n
drwxr-xr-x.   4 root root  4096 Nov  9  2016 icons
drwxr-xr-x.   2 root root  4096 Sep 23  2011 idl
drwxr-xr-x.   2 root root  4096 Nov  9  2016 info
drwxr-xr-x.   3 root root  4096 Nov  9  2016 kde4
drwxr-xr-x.   3 root root  4096 Nov  9  2016 kde-settings
drwxr-xr-x.   2 root root  4096 Nov  9  2016 kdump
drwxr-xr-x. 576 root root 12288 Nov  9  2016 locale
drwxr-xr-x.   3 root root  4096 Nov  9  2016 lua
lrwxrwxrwx.   1 root root    10 Nov  9  2016 magic -> misc/magic
drwxr-xr-x.  51 root root  4096 Nov  9  2016 man
drwxr-xr-x.  14 root root  4096 Nov  9  2016 mime
drwxr-xr-x.   2 root root  4096 Sep 23  2011 mime-info
drwxr-xr-x.   2 root root  4096 Nov  9  2016 misc
drwxr-xr-x.   2 root root  4096 Nov 12  2010 myspell
drwxr-xr-x.  26 root root  4096 Dec 11 21:02 mysql
drwxr-xr-x.   2 root root  4096 Nov  9  2016 nano
drwxr-xr-x    4 root root  4096 Dec 11 20:59 nginx
drwxr-xr-x.   2 root root  4096 Sep 23  2011 omf
drwxr-xr-x.   3 root root  4096 Nov  9  2016 p11-kit
drwxr-xr-x.  44 root root  4096 Nov  9  2016 perl5
drwxr-xr-x    7 root root  4096 Dec 11 21:05 php
drwxr-xr-x    3 root root  4096 Dec 11 21:05 PHPMailer
drwxr-xr-x.   3 root root  4096 Nov  9  2016 pixmaps
drwxr-xr-x.   2 root root  4096 Nov  9  2016 pkgconfig
drwxr-xr-x.   4 root root  4096 Nov  9  2016 pki
drwxr-xr-x.   3 root root  4096 Nov  9  2016 plymouth
drwxr-xr-x.   2 root root  4096 Nov  9  2016 python-dmidecode
drwxr-xr-x.   5 root root  4096 Nov  9  2016 selinux
drwxr-xr-x.   3 root root  4096 Nov  9  2016 setuptool
drwxr-xr-x.   3 root root  4096 Nov  9  2016 sos
drwxr-xr-x.   3 root root  4096 Nov  9  2016 sounds
drwxr-xr-x.   2 root root  4096 Nov  9  2016 system-config-firewall
drwxr-xr-x.   3 root root  4096 Nov  9  2016 systemtap
drwxr-xr-x.   2 root root  4096 Nov  9  2016 tabset
drwxr-xr-x.   2 root root  4096 Nov  9  2016 tc
drwxr-xr-x.  22 root root  4096 Nov  9  2016 terminfo
drwxr-xr-x.   2 root root  4096 Sep 23  2011 themes
drwxr-xr-x.   4 root root  4096 Nov  9  2016 vim
drwxr-xr-x.   3 root root  4096 Nov  9  2016 wallpapers
drwxr-xr-x    5 root root  4096 Dec 11 21:05 wordpress
drwxr-xr-x.   3 root root  4096 Dec 11 20:59 X11
drwxr-xr-x.   2 root root  4096 Sep 23  2011 xsessions
drwxr-xr-x.   2 root root  4096 Nov  9  2016 yum-cli
drwxr-xr-x.   2 root root  4096 May 12  2016 yum-plugins
drwxr-xr-x.  20 root root  4096 Nov  9  2016 zoneinfo
[root@VM_88_143_centos share]# cd wordpress/
[root@VM_88_143_centos wordpress]# ll
total 160
-rw-r--r--  1 root root   418 Sep 25  2013 index.php
-rw-r--r--  1 root root  5447 Sep 28  2016 wp-activate.php
drwxr-xr-x  9 root root  4096 Dec 11 21:05 wp-admin
-rw-r--r--  1 root root   364 Dec 19  2015 wp-blog-header.php
-rw-r--r--  1 root root  1627 Aug 29  2016 wp-comments-post.php
lrwxrwxrwx  1 root root    36 Dec 11 21:05 wp-config.php -> ../../../etc/wordpress/wp-config.php
-rw-r--r--  1 root root  2853 Dec 16  2015 wp-config-sample.php
drwxr-xr-x  6 root root  4096 Dec 11 21:05 wp-content
-rw-r--r--  1 root root  3286 May 25  2015 wp-cron.php
drwxr-xr-x 16 root root 12288 Dec 11 21:05 wp-includes
-rw-r--r--  1 root root  2422 Nov 21  2016 wp-links-opml.php
-rw-r--r--  1 root root  3301 Oct 25  2016 wp-load.php
-rw-r--r--  1 root root 34327 May 13  2017 wp-login.php
-rw-r--r--  1 root root  8048 Jan 11  2017 wp-mail.php
-rw-r--r--  1 root root 16200 Apr  7  2017 wp-settings.php
-rw-r--r--  1 root root 29924 Jan 24  2017 wp-signup.php
-rw-r--r--  1 root root  4513 Oct 15  2016 wp-trackback.php
-rw-r--r--  1 root root  3065 Sep  1  2016 xmlrpc.php
[root@VM_88_143_centos wordpress]# cat index.php 
<?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );

此时已经配置完毕,在浏览器输入:http://127.0.0.1:9000就可以登录博客了

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值