wordpress搭建

安装php-fpm

yum install php-fpm  -y

启动

sudo systemctl start  php-fpm 

下载nginx

yum install nginx -y
  • -y:面临y or n的时候自动写入y

进入nginx安装包

./configure

配置文件

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

systemctl start nginx

安装mysql

yum install mysql-server -y

启动

sudo systemctl start mysqld

配置mysql

  • 执行安全安装脚本,根据要求设置
    • 设置密码 – 为 root 用户设置密码。
    • 删除匿名用户 – 删除允许没有密码的匿名用户登录的账号。
    • 禁止 root 远程登录 – 防止 root 用户从远程登录,这是一个安全措施。
    • 删除测试数据库 – 删除默认安装时创建的测试数据库。
    • 重新加载权限表 – 确保所有更改立即生效。
    sudo mysql_secure_installation
  • 登录 MySQL 服务器:

bash

复制

mysql -u root -p

系统将提示您输入密码。如果这是第一次设置,可能不会有密码。

  1. 选择 MySQL 数据库:
USE mysql;
  1. 更改 root 用户的密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

new_password 替换为您想要设置的密码。

  1. 如果您想为新的用户创建密码,可以使用以下命令:
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'new_password';
  1. 授予新用户权限(例如,授予所有数据库的所有权限):
GRANT ALL PRIVILEGES ON *.* TO 'new_user'@'localhost' WITH GRANT OPTION;
  1. 刷新权限:
FLUSH PRIVILEGES;
  1. 创建wordpress表
    CREATE DATABASE wordpress;

下载最新的wordpress压缩包

sudo wget https://wordpress.org/latest.tar.gz

配置文件

  • 进入安装包内,如果没有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', '数据库用户');
    
    /** MySQL database password */
    define('DB_PASSWORD', '数据库密码');
    
    /** 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', false);
    
    /* 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');
    • 注意,如果以下配置不这么改,你无法去网上下载其他主题
    define('DISALLOW_FILE_MODS', false);

下载主题

  • 安装vsftpd
sudo yum install vsftpd
  • 启动
sudo systemctl start vsftpd
# 开机自启动
sudo systemctl enable vsftpd 
  • 创建用户
sudo useradd -m ftpuser
  • 设置密码
sudo passwd ftpuser
  • 配置文件
sudo nano /etc/vsftpd/vsftpd.conf
  • 确保以下行没有被注释
local_enable=YES
write_enable=YES
  • 重启
sudo systemctl restart vsftpd

访问网站,直接就会跳转到初始化

  • 填入你的用户信息以及数据库信息即可

Tags:

Comments are closed

       

粤公网安备44011302004556号