LNMP应用之搭建个人博客

来源:互联网 发布:考勤系统怎么改数据 编辑:程序博客网 时间:2024/06/16 13:50

安装WordPress

[root@VM_88_143_centos ~]# yum install wordpress -yLoaded plugins: fastestmirror, securitySetting up Install ProcessLoading mirror speeds from cached hostfileResolving Dependencies--> Running transaction check---> Package wordpress.noarch 0:4.8.3-1.el6 will be installed--> Processing Dependency: php >= 5.2.4 for package: wordpress-4.8.3-1.el6.noarch--> Processing Dependency: php-simplepie >= 1.3.1 for package: wordpress-4.8.3-1.el6.noarch--> Processing Dependency: httpd for package: wordpress-4.8.3-1.el6.noarch--> Processing Dependency: php-PHPMailer for package: wordpress-4.8.3-1.el6.noarch--> Processing Dependency: php-dom for package: wordpress-4.8.3-1.el6.noarch--> Processing Dependency: php-gd for package: wordpress-4.8.3-1.el6.noarch--> Processing Dependency: php-getid3 for package: wordpress-4.8.3-1.el6.noarch--> Processing Dependency: php-mbstring for package: wordpress-4.8.3-1.el6.noarch--> Processing Dependency: php-posix for package: wordpress-4.8.3-1.el6.noarch--> Processing Dependency: php-xml for package: wordpress-4.8.3-1.el6.noarch--> Running transaction check---> Package httpd.x86_64 0:2.2.15-60.el6.centos.6 will be installed--> Processing Dependency: httpd-tools = 2.2.15-60.el6.centos.6 for package: httpd-2.2.15-60.el6.centos.6.x86_64--> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-60.el6.centos.6.x86_64--> Processing Dependency: /etc/mime.types for package: httpd-2.2.15-60.el6.centos.6.x86_64--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.15-60.el6.centos.6.x86_64--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.15-60.el6.centos.6.x86_64---> Package php.x86_64 0:5.3.3-49.el6 will be installed--> Processing Dependency: php-cli(x86-64) = 5.3.3-49.el6 for package: php-5.3.3-49.el6.x86_64---> Package php-PHPMailer.noarch 0:5.2.26-1.el6 will be installed--> Processing Dependency: php-imap for package: php-PHPMailer-5.2.26-1.el6.noarch--> Processing Dependency: php-intl for package: php-PHPMailer-5.2.26-1.el6.noarch---> Package php-gd.x86_64 0:5.3.3-49.el6 will be installed---> Package php-getid3.noarch 1:1.9.15-1.el6 will be installed--> Processing Dependency: php-composer(fedora/autoloader) for package: 1:php-getid3-1.9.15-1.el6.noarch---> Package php-mbstring.x86_64 0:5.3.3-49.el6 will be installed---> Package php-process.x86_64 0:5.3.3-49.el6 will be installed---> Package php-simplepie.noarch 0:1.3.1-3.el6 will be installed--> Processing Dependency: php-IDNA_Convert for package: php-simplepie-1.3.1-3.el6.noarch---> Package php-xml.x86_64 0:5.3.3-49.el6 will be installed--> Running transaction check---> Package apr.x86_64 0:1.3.9-5.el6_9.1 will be installed---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be installed---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed---> Package httpd-tools.x86_64 0:2.2.15-60.el6.centos.6 will be installed---> Package mailcap.noarch 0:2.1.31-2.el6 will be installed---> Package php-IDNA_Convert.noarch 0:0.8.0-1.el6 will be installed---> Package php-cli.x86_64 0:5.3.3-49.el6 will be installed---> Package php-fedora-autoloader.noarch 0:1.0.0-1.el6 will be installed---> Package php-imap.x86_64 0:5.3.3-49.el6 will be installed--> Processing Dependency: libc-client.so.2007()(64bit) for package: php-imap-5.3.3-49.el6.x86_64---> Package php-intl.x86_64 0:5.3.3-49.el6 will be installed--> Processing Dependency: libicuuc.so.42()(64bit) for package: php-intl-5.3.3-49.el6.x86_64--> Processing Dependency: libicuio.so.42()(64bit) for package: php-intl-5.3.3-49.el6.x86_64--> Processing Dependency: libicui18n.so.42()(64bit) for package: php-intl-5.3.3-49.el6.x86_64--> Processing Dependency: libicudata.so.42()(64bit) for package: php-intl-5.3.3-49.el6.x86_64--> Running transaction check---> Package libc-client.x86_64 0:2007e-11.el6 will be installed---> Package libicu.x86_64 0:4.2.1-14.el6 will be installed--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================================================================= Package                                             Arch                                 Version                                                Repository                             Size=============================================================================================================================================================================================Installing: wordpress                                           noarch                               4.8.3-1.el6                                            epel                                  6.5 MInstalling for dependencies: apr                                                 x86_64                               1.3.9-5.el6_9.1                                        updates                               124 k apr-util                                            x86_64                               1.3.9-3.el6_0.1                                        os                                     87 k apr-util-ldap                                       x86_64                               1.3.9-3.el6_0.1                                        os                                     15 k httpd                                               x86_64                               2.2.15-60.el6.centos.6                                 updates                               836 k httpd-tools                                         x86_64                               2.2.15-60.el6.centos.6                                 updates                                80 k libc-client                                         x86_64                               2007e-11.el6                                           os                                    515 k libicu                                              x86_64                               4.2.1-14.el6                                           os                                    4.9 M mailcap                                             noarch                               2.1.31-2.el6                                           os                                     27 k php                                                 x86_64                               5.3.3-49.el6                                           os                                    1.1 M php-IDNA_Convert                                    noarch                               0.8.0-1.el6                                            epel                                   35 k php-PHPMailer                                       noarch                               5.2.26-1.el6                                           epel                                  136 k php-cli                                             x86_64                               5.3.3-49.el6                                           os                                    2.2 M php-fedora-autoloader                               noarch                               1.0.0-1.el6                                            epel                                  9.5 k php-gd                                              x86_64                               5.3.3-49.el6                                           os                                    111 k php-getid3                                          noarch                               1:1.9.15-1.el6                                         epel                                  450 k php-imap                                            x86_64                               5.3.3-49.el6                                           os                                     55 k php-intl                                            x86_64                               5.3.3-49.el6                                           os                                     76 k php-mbstring                                        x86_64                               5.3.3-49.el6                                           os                                    460 k php-process                                         x86_64                               5.3.3-49.el6                                           os                                     44 k php-simplepie                                       noarch                               1.3.1-3.el6                                            epel                                  465 k php-xml                                             x86_64                               5.3.3-49.el6                                           os                                    108 kTransaction Summary=============================================================================================================================================================================================Install      22 Package(s)Total download size: 18 MInstalled size: 61 MDownloading Packages:(1/22): apr-1.3.9-5.el6_9.1.x86_64.rpm                                                                                                                                | 124 kB     00:00     (2/22): apr-util-1.3.9-3.el6_0.1.x86_64.rpm                                                                                                                           |  87 kB     00:00     (3/22): apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm                                                                                                                      |  15 kB     00:00     (4/22): httpd-2.2.15-60.el6.centos.6.x86_64.rpm                                                                                                                       | 836 kB     00:00     (5/22): httpd-tools-2.2.15-60.el6.centos.6.x86_64.rpm                                                                                                                 |  80 kB     00:00     (6/22): libc-client-2007e-11.el6.x86_64.rpm                                                                                                                           | 515 kB     00:00     (7/22): libicu-4.2.1-14.el6.x86_64.rpm                                                                                                                                | 4.9 MB     00:00     (8/22): mailcap-2.1.31-2.el6.noarch.rpm                                                                                                                               |  27 kB     00:00     (9/22): php-5.3.3-49.el6.x86_64.rpm                                                                                                                                   | 1.1 MB     00:00     (10/22): php-IDNA_Convert-0.8.0-1.el6.noarch.rpm                                                                                                                      |  35 kB     00:00     (11/22): php-PHPMailer-5.2.26-1.el6.noarch.rpm                                                                                                                        | 136 kB     00:00     (12/22): php-cli-5.3.3-49.el6.x86_64.rpm                                                                                                                              | 2.2 MB     00:00     (13/22): php-fedora-autoloader-1.0.0-1.el6.noarch.rpm                                                                                                                 | 9.5 kB     00:00     (14/22): php-gd-5.3.3-49.el6.x86_64.rpm                                                                                                                               | 111 kB     00:00     (15/22): php-getid3-1.9.15-1.el6.noarch.rpm                                                                                                                           | 450 kB     00:00     (16/22): php-imap-5.3.3-49.el6.x86_64.rpm                                                                                                                             |  55 kB     00:00     (17/22): php-intl-5.3.3-49.el6.x86_64.rpm                                                                                                                             |  76 kB     00:00     (18/22): php-mbstring-5.3.3-49.el6.x86_64.rpm                                                                                                                         | 460 kB     00:00     (19/22): php-process-5.3.3-49.el6.x86_64.rpm                                                                                                                          |  44 kB     00:00     (20/22): php-simplepie-1.3.1-3.el6.noarch.rpm                                                                                                                         | 465 kB     00:00     (21/22): php-xml-5.3.3-49.el6.x86_64.rpm                                                                                                                              | 108 kB     00:00     (22/22): wordpress-4.8.3-1.el6.noarch.rpm                                                                                                                             | 6.5 MB     00:00     ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Total                                                                                                                                                         29 MB/s |  18 MB     00:00     Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction  Installing : php-xml-5.3.3-49.el6.x86_64                                                                                                                                              1/22   Installing : php-mbstring-5.3.3-49.el6.x86_64                                                                                                                                         2/22   Installing : apr-1.3.9-5.el6_9.1.x86_64                                                                                                                                               3/22   Installing : apr-util-1.3.9-3.el6_0.1.x86_64                                                                                                                                          4/22   Installing : php-gd-5.3.3-49.el6.x86_64                                                                                                                                               5/22   Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                                                                                                                                     6/22   Installing : httpd-tools-2.2.15-60.el6.centos.6.x86_64                                                                                                                                7/22   Installing : php-IDNA_Convert-0.8.0-1.el6.noarch                                                                                                                                      8/22   Installing : php-simplepie-1.3.1-3.el6.noarch                                                                                                                                         9/22   Installing : php-process-5.3.3-49.el6.x86_64                                                                                                                                         10/22   Installing : mailcap-2.1.31-2.el6.noarch                                                                                                                                             11/22   Installing : httpd-2.2.15-60.el6.centos.6.x86_64                                                                                                                                     12/22   Installing : php-fedora-autoloader-1.0.0-1.el6.noarch                                                                                                                                13/22   Installing : 1:php-getid3-1.9.15-1.el6.noarch                                                                                                                                        14/22   Installing : libicu-4.2.1-14.el6.x86_64                                                                                                                                              15/22   Installing : php-intl-5.3.3-49.el6.x86_64                                                                                                                                            16/22   Installing : php-cli-5.3.3-49.el6.x86_64                                                                                                                                             17/22   Installing : php-5.3.3-49.el6.x86_64                                                                                                                                                 18/22   Installing : libc-client-2007e-11.el6.x86_64                                                                                                                                         19/22   Installing : php-imap-5.3.3-49.el6.x86_64                                                                                                                                            20/22   Installing : php-PHPMailer-5.2.26-1.el6.noarch                                                                                                                                       21/22   Installing : wordpress-4.8.3-1.el6.noarch                                                                                                                                            22/22   Verifying  : php-imap-5.3.3-49.el6.x86_64                                                                                                                                             1/22   Verifying  : wordpress-4.8.3-1.el6.noarch                                                                                                                                             2/22   Verifying  : libc-client-2007e-11.el6.x86_64                                                                                                                                          3/22   Verifying  : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                                                                                                                                     4/22   Verifying  : php-cli-5.3.3-49.el6.x86_64                                                                                                                                              5/22   Verifying  : php-5.3.3-49.el6.x86_64                                                                                                                                                  6/22   Verifying  : apr-1.3.9-5.el6_9.1.x86_64                                                                                                                                               7/22   Verifying  : php-IDNA_Convert-0.8.0-1.el6.noarch                                                                                                                                      8/22   Verifying  : php-mbstring-5.3.3-49.el6.x86_64                                                                                                                                         9/22   Verifying  : httpd-tools-2.2.15-60.el6.centos.6.x86_64                                                                                                                               10/22   Verifying  : php-xml-5.3.3-49.el6.x86_64                                                                                                                                             11/22   Verifying  : php-simplepie-1.3.1-3.el6.noarch                                                                                                                                        12/22   Verifying  : httpd-2.2.15-60.el6.centos.6.x86_64                                                                                                                                     13/22   Verifying  : php-intl-5.3.3-49.el6.x86_64                                                                                                                                            14/22   Verifying  : apr-util-1.3.9-3.el6_0.1.x86_64                                                                                                                                         15/22   Verifying  : libicu-4.2.1-14.el6.x86_64                                                                                                                                              16/22   Verifying  : php-fedora-autoloader-1.0.0-1.el6.noarch                                                                                                                                17/22   Verifying  : php-gd-5.3.3-49.el6.x86_64                                                                                                                                              18/22   Verifying  : mailcap-2.1.31-2.el6.noarch                                                                                                                                             19/22   Verifying  : php-process-5.3.3-49.el6.x86_64                                                                                                                                         20/22   Verifying  : 1:php-getid3-1.9.15-1.el6.noarch                                                                                                                                        21/22   Verifying  : php-PHPMailer-5.2.26-1.el6.noarch                                                                                                                                       22/22 Installed:  wordpress.noarch 0:4.8.3-1.el6                                                                                                                                                             Dependency Installed:  apr.x86_64 0:1.3.9-5.el6_9.1                       apr-util.x86_64 0:1.3.9-3.el6_0.1            apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1        httpd.x86_64 0:2.2.15-60.el6.centos.6         httpd-tools.x86_64 0:2.2.15-60.el6.centos.6        libc-client.x86_64 0:2007e-11.el6            libicu.x86_64 0:4.2.1-14.el6                  mailcap.noarch 0:2.1.31-2.el6                 php.x86_64 0:5.3.3-49.el6                          php-IDNA_Convert.noarch 0:0.8.0-1.el6        php-PHPMailer.noarch 0:5.2.26-1.el6           php-cli.x86_64 0:5.3.3-49.el6                 php-fedora-autoloader.noarch 0:1.0.0-1.el6         php-gd.x86_64 0:5.3.3-49.el6                 php-getid3.noarch 1:1.9.15-1.el6              php-imap.x86_64 0:5.3.3-49.el6                php-intl.x86_64 0:5.3.3-49.el6                     php-mbstring.x86_64 0:5.3.3-49.el6           php-process.x86_64 0:5.3.3-49.el6             php-simplepie.noarch 0:1.3.1-3.el6            php-xml.x86_64 0:5.3.3-49.el6                     Complete!

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

[root@VM_88_143_centos ~]# ll /usr/share/wordpresstotal 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.phpdrwxr-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.phplrwxrwxrwx  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.phpdrwxr-xr-x  6 root root  4096 Dec 11 21:05 wp-content-rw-r--r--  1 root root  3286 May 25  2015 wp-cron.phpdrwxr-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 3Server version: 5.1.73 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.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> exitBye


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

[root@VM_88_143_centos ~]# cd /etc/wordpress/[root@VM_88_143_centos wordpress]# lltotal 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]# lltotal 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]# lltotal 320drwxr-xr-x.   3 root root  4096 Nov  9  2016 abrtdrwxr-xr-x.   2 root root  4096 Nov  9  2016 aclocaldrwxr-xr-x.   8 root root  4096 Nov  9  2016 alsadrwxr-xr-x.   3 root root  4096 Nov  9  2016 anacondadrwxr-xr-x.   2 root root  4096 Nov  9  2016 applicationsdrwxr-xr-x.   3 root root  4096 Nov  9  2016 augeasdrwxr-xr-x.   2 root root  4096 Nov  9  2016 authconfigdrwxr-xr-x.   2 root root  4096 Nov  9  2016 awkdrwxr-xr-x.   2 root root  4096 Nov  9  2016 backgroundsdrwxr-xr-x.   2 root root  4096 Nov  9  2016 cracklibdrwxr-xr-x.   5 root root  4096 Nov  9  2016 dbus-1drwxr-xr-x.   2 root root  4096 Sep 23  2011 desktop-directoriesdrwxr-xr-x.   2 root root  4096 Sep 23  2011 dictdrwxr-xr-x. 252 root root 12288 Dec 11 21:05 docdrwxr-xr-x.   3 root root  4096 Nov  9  2016 dracutdrwxr-xr-x.   3 root root  4096 Nov  9  2016 emacsdr-xr-xr-x.   2 root root  4096 Sep 23  2011 emptydrwxr-xr-x.   2 root root  4096 Nov  9  2016 filedrwxr-xr-x.   3 root root  4096 Nov  9  2016 firstbootdrwxr-xr-x    2 root root  4096 May 27  2014 fontsdrwxr-xr-x    2 root root  4096 Dec 11 21:03 fpmdrwxr-xr-x.   2 root root  4096 Sep 23  2011 gamesdrwxr-xr-x    2 root root  4096 Dec 11 20:59 GeoIPdrwxr-xr-x.   3 root root  4096 Nov  9  2016 ghostscriptdrwxr-xr-x.   2 root root  4096 May 11  2016 glib-2.0drwxr-xr-x.   2 root root  4096 Sep 23  2011 gnomedrwxr-xr-x.   2 root root  4096 Nov  9  2016 gnome-background-propertiesdrwxr-xr-x.   2 root root  4096 Nov  9  2016 gnupgdrwxr-xr-x.   4 root root  4096 Nov  9  2016 groffdrwxr-xr-x.   3 root root  4096 Nov  9  2016 grubdrwxr-xr-x.   3 root root  4096 Nov  9  2016 hwdatadrwxr-xr-x.   4 root root  4096 Nov  9  2016 i18ndrwxr-xr-x.   4 root root  4096 Nov  9  2016 iconsdrwxr-xr-x.   2 root root  4096 Sep 23  2011 idldrwxr-xr-x.   2 root root  4096 Nov  9  2016 infodrwxr-xr-x.   3 root root  4096 Nov  9  2016 kde4drwxr-xr-x.   3 root root  4096 Nov  9  2016 kde-settingsdrwxr-xr-x.   2 root root  4096 Nov  9  2016 kdumpdrwxr-xr-x. 576 root root 12288 Nov  9  2016 localedrwxr-xr-x.   3 root root  4096 Nov  9  2016 lualrwxrwxrwx.   1 root root    10 Nov  9  2016 magic -> misc/magicdrwxr-xr-x.  51 root root  4096 Nov  9  2016 mandrwxr-xr-x.  14 root root  4096 Nov  9  2016 mimedrwxr-xr-x.   2 root root  4096 Sep 23  2011 mime-infodrwxr-xr-x.   2 root root  4096 Nov  9  2016 miscdrwxr-xr-x.   2 root root  4096 Nov 12  2010 myspelldrwxr-xr-x.  26 root root  4096 Dec 11 21:02 mysqldrwxr-xr-x.   2 root root  4096 Nov  9  2016 nanodrwxr-xr-x    4 root root  4096 Dec 11 20:59 nginxdrwxr-xr-x.   2 root root  4096 Sep 23  2011 omfdrwxr-xr-x.   3 root root  4096 Nov  9  2016 p11-kitdrwxr-xr-x.  44 root root  4096 Nov  9  2016 perl5drwxr-xr-x    7 root root  4096 Dec 11 21:05 phpdrwxr-xr-x    3 root root  4096 Dec 11 21:05 PHPMailerdrwxr-xr-x.   3 root root  4096 Nov  9  2016 pixmapsdrwxr-xr-x.   2 root root  4096 Nov  9  2016 pkgconfigdrwxr-xr-x.   4 root root  4096 Nov  9  2016 pkidrwxr-xr-x.   3 root root  4096 Nov  9  2016 plymouthdrwxr-xr-x.   2 root root  4096 Nov  9  2016 python-dmidecodedrwxr-xr-x.   5 root root  4096 Nov  9  2016 selinuxdrwxr-xr-x.   3 root root  4096 Nov  9  2016 setuptooldrwxr-xr-x.   3 root root  4096 Nov  9  2016 sosdrwxr-xr-x.   3 root root  4096 Nov  9  2016 soundsdrwxr-xr-x.   2 root root  4096 Nov  9  2016 system-config-firewalldrwxr-xr-x.   3 root root  4096 Nov  9  2016 systemtapdrwxr-xr-x.   2 root root  4096 Nov  9  2016 tabsetdrwxr-xr-x.   2 root root  4096 Nov  9  2016 tcdrwxr-xr-x.  22 root root  4096 Nov  9  2016 terminfodrwxr-xr-x.   2 root root  4096 Sep 23  2011 themesdrwxr-xr-x.   4 root root  4096 Nov  9  2016 vimdrwxr-xr-x.   3 root root  4096 Nov  9  2016 wallpapersdrwxr-xr-x    5 root root  4096 Dec 11 21:05 wordpressdrwxr-xr-x.   3 root root  4096 Dec 11 20:59 X11drwxr-xr-x.   2 root root  4096 Sep 23  2011 xsessionsdrwxr-xr-x.   2 root root  4096 Nov  9  2016 yum-clidrwxr-xr-x.   2 root root  4096 May 12  2016 yum-pluginsdrwxr-xr-x.  20 root root  4096 Nov  9  2016 zoneinfo[root@VM_88_143_centos share]# cd wordpress/[root@VM_88_143_centos wordpress]# lltotal 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.phpdrwxr-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.phplrwxrwxrwx  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.phpdrwxr-xr-x  6 root root  4096 Dec 11 21:05 wp-content-rw-r--r--  1 root root  3286 May 25  2015 wp-cron.phpdrwxr-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就可以登录博客了