【Web】PHP+MySql+worldpress创建worldpress站点

   |   5 minute read   |   Using 941 words

【Web】PHP + MySql + worldpress 创建 worldpress 站点

在ECS服务器上,执行以下命令,安装Apache服务及其扩展包。

yum -y install httpd httpd-manual mod_ssl mod_perl mod_auth_mysql

执行以下命令,启动Apache服务

systemctl start httpd.service

执行以下命令,安装PHP。

yum -y install php php-mysql gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap

执行以下命令,创建PHP测试页面。

echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php

执行以下命令,重启Apache服务。

systemctl restart httpd

打开浏览器,访问http:///phpinfo.php,显示如下页面表示PHP安装成功。

执行以下命令,安装WordPress yum -y install wordpress

修改WordPress配置文件。

a. 执行以下命令,修改wp-config.php指向路径为绝对路径。

进入/usr/share/wordpress目录。

cd /usr/share/wordpress

修改路径。

ln -snf /etc/wordpress/wp-config.php wp-config.php

查看修改后的目录结构。

ll

b. 执行以下命令,移动WordPress到Apache根目录。

在Apache的根目录/var/www/html下,创建一个wp-blog文件夹。

mkdir /var/www/html/wp-blog mv * /var/www/html/wp-blog/

c. 执行以下命令,修改wp-config.php配置文件。

database_name_here为之前步骤中创建的数据库名称,本示例为wordpress。 username_here为之前步骤中创建的数据库用户名,本示例为test_user。 password_here为之前步骤中创建的数据库登录密码,本示例为Password1213。

数据库地址为RDS的连接地址(在RDS管理控制台 实例详情 页查看或者开通资源后再左侧资源栏列表中查看RDS连接地址)。

sed -i 's/database_name_here/wordpress/' /var/www/html/wp-blog/wp-config.php
sed -i 's/username_here/test_user/' /var/www/html/wp-blog/wp-config.php
sed -i 's/password_here/Password1213/' /var/www/html/wp-blog/wp-config.php
sed -i 's/localhost/数据库地址/' /var/www/html/wp-blog/wp-config.php

d. 执行以下命令,查看配置文件信息是否修改成功。

cat -n /var/www/html/wp-blog/wp-config.php

修改内容如下图所示:

执行以下命令,重启Apache服务。

systemctl restart httpd

初始化WordPress。

cat -n /var/www/html/wp-blog/wp-config.php

cat -n /var/www/html/wp-blog/wp-config.php
 <?php
     2  /**
     3   * The base configuration for WordPress
     4   *
     5   * The wp-config.php creation script uses this file during the
     6   * installation. You don't have to use the web site, you can
     7   * copy this file to "wp-config.php" and fill in the values.
     8   *
     9   * This file contains the following configurations:
    10   *
    11   * * MySQL settings
    12   * * Secret keys
    13   * * Database table prefix
    14   * * ABSPATH
    15   *
    16   * @link https://codex.wordpress.org/Editing_wp-config.php
    17   *
    18   * @package WordPress
    19   */
    20
    21  // ** MySQL settings - You can get this info from your web host ** //
    22  /** The name of the database for WordPress */
    23  define( 'DB_NAME', 'wordpress' );
    24
    25  /** MySQL database username */
    26  define( 'DB_USER', 'test_user' );
    27
    28  /** MySQL database password */
    29  define( 'DB_PASSWORD', 'Password1213' );
    30
    31  /** MySQL hostname */
    32  define( 'DB_HOST', '数据库地址' );
    33
    34  /** Database Charset to use in creating database tables. */
    35  define( 'DB_CHARSET', 'utf8' );
    36
    37  /** The Database Collate type. Don't change this if in doubt. */
    38  define( 'DB_COLLATE', '' );
    39
    40  /**#@+
    41   * Authentication Unique Keys and Salts.
    42   *
    43   * Change these to different unique phrases!
    44   * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
    45   * 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.
    46   *
    47   * @since 2.6.0
    48   */
    49  define( 'AUTH_KEY',         'put your unique phrase here' );
    50  define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
    51  define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
    52  define( 'NONCE_KEY',        'put your unique phrase here' );
    53  define( 'AUTH_SALT',        'put your unique phrase here' );
    54  define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
    55  define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
    56  define( 'NONCE_SALT',       'put your unique phrase here' );
    57
    58  /**#@-*/
    59
[root@iZuf657h6indvo5v56gd57Z wordpress]# systemctl restart httpd
[root@iZuf657h6indvo5v56gd57Z wordpress]# cat  /var/www/html/wp-blog/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', 'clay' );

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

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

/** MySQL hostname */
define( 'DB_HOST', 'rm-uf606td77l5ip9340.mysql.rds.aliyuncs.com' );

/** 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 publishing. */

/** 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@iZuf657h6indvo5v56gd57Z wordpress]# 








© 2025 by clayliu. All Rights Reserved.