• wordpress网站搭建(centos stream 9)


    一、基本环境配置

    1.修改root密码:sudo passwd root
    2.使用root账号登录:ssh root@IPADDRESS
    3.安装epel源:dnf install epel-release
    4.安装dnf-utils:dnf install dnf-utils
    5.安装php7.4的源:dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
    6.系统更新:dnf upgrade&&dnf update
    7.重启:reboot

    1.修改用户名:usermod -l xiaoyu ecs-user
    2.修改家目录:usermod -d /home/xiaoyu -m xiaoyu
    3.修改组名:groupmod -n xiaoyu ecs-user
    4.权限继承:vim /etc/sudoers.d/90-cloud-init-users
    5.查看:id xiaoyu

    1.修改ssh登录欢迎信息:vim /etc/motd

    二、搭建LNMP环境

    1.安装nginx:dnf install nginx gcc pcre pcre-devel zlib zlib-devel
    2.安装php 7.4:dnf module install php:remi-7.4
    3.安装php 7.4:yum install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-redis
    3.安装mariadb:dnf install mariadb mariadb-server

    三、修改配置文件

    1.修改nginx配置文件vim /etc/nginx/nginx.conf

    # For more information on configuration, see:
    #   * Official English Documentation: http://nginx.org/en/docs/
    #   * Official Russian Documentation: http://nginx.org/ru/docs/
    
    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    
    # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
    include /usr/share/nginx/modules/*.conf;
    
    events {
        worker_connections 1024;
    }
    
    http {
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
    
        access_log  /var/log/nginx/access.log  main;
    
        sendfile            on;
        tcp_nopush          on;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 4096;
    
        include             /etc/nginx/mime.types;
        default_type        application/octet-stream;
    
        # Load modular configuration files from the /etc/nginx/conf.d directory.
        # See http://nginx.org/en/docs/ngx_core_module.html#include
        # for more information.
        include /etc/nginx/conf.d/*.conf;
    
        server {
            listen       80;
            listen       [::]:80;
            server_name  _;
            root         /usr/share/nginx/html;
            index index.php index.html index.htm;
    
            location / {
                    # This is cool because no php is touched for static content.
                    # include the "?$args" part so non-default permalinks doesn't break when using query string
                    try_files $uri $uri/ /index.php?$args;
            }
    
            location ~ \.php$ {
                    #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                    include fastcgi_params;
                    fastcgi_intercept_errors on;
                    fastcgi_pass   unix:/run/php-fpm/www.sock;
                    #The following parameter can be also included in fastcgi_params file
                    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            }
    
            # Load configuration files for the default server block.
            include /etc/nginx/default.d/*.conf;
    
            error_page 404 /404.html;
            location = /404.html {
            }
    
            error_page 500 502 503 504 /50x.html;
            location = /50x.html {
            }
        }
    
    # Settings for a TLS enabled server.
    #
    #    server {
    #        listen       443 ssl http2;
    #        listen       [::]:443 ssl http2;
    #        server_name  _;
    #        root         /usr/share/nginx/html;
    #
    #        ssl_certificate "/etc/pki/nginx/server.crt";
    #        ssl_certificate_key "/etc/pki/nginx/private/server.key";
    #        ssl_session_cache shared:SSL:1m;
    #        ssl_session_timeout  10m;
    #        ssl_ciphers PROFILE=SYSTEM;
    #        ssl_prefer_server_ciphers on;
    #
    #        # Load configuration files for the default server block.
    #        include /etc/nginx/default.d/*.conf;
    #
    #        error_page 404 /404.html;
    #            location = /40x.html {
    #        }
    #
    #        error_page 500 502 503 504 /50x.html;
    #            location = /50x.html {
    #        }
    #    }
    
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99

    2.测试nginx:nginx -t
    3.启动nginx:systemctl start nginx.service
    4.自启动nginx:systemctl enable nginx.service
    5.启动mariadb:systemctl start mariadb.service
    6.初始化mariadb:mysql_secure_installation
    3.查看php-fpm:systemctl status php-fpm.service
    编辑vim /etc/php.ini

    ;cgi.fix_pathinfo=1
    cgi.fix_pathinfo=0
    
    • 1
    • 2

    编辑:vim /etc/php-fpm.d/www.conf

    ;user = apache
    user = nginx
    
    ;group = apache
    group = nginx
    
    ;listen.owner = nobody
    ;listen.group = nobody
    ;listen.mode = 0660
    listen.owner = nobady
    listen.group = nobody
    listen.mode = 0666
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    4.初始化mariadb:mysql_secure_installation
    5.验证php运行:vim /usr/share/nginx/html/phpinfo.php

    <?php
    phpinfo()
    ?>
    
    • 1
    • 2
    • 3

    四、数据库创建用户

    1.创建数据库:CREATE DATABASE wordpress;
    2.创建用户:CREATE USER 'wpadmin'@'localhost' IDENTIFIED BY 'wppasswd';
    3.用户提权:GRANT ALL PRIVILEGES ON wordpress.* TO wpadmin@localhost;
    4.刷新数据库缓存:FLUSH PRIVILEGES;
    5.查看:SHOW GRANTS FOR wpadmin@localhost;

    五、配置wordpress

    1.获取wordpress:wget https://cn.wordpress.org/latest-zh_CN.tar.gz
    2.解压缩:tar xzvf latest-zh_CN.tar.gz
    3.迁移至web根目录:cp -rf wordpress/* /usr/share/nginx/html/
    4.设置属主属组:chown -R nginx:nginx /usr/share/nginx/html/
    5.设置权限:chmod -R 755 /usr/share/nginx/html/
    6.拷贝wp-config.php:cp /usr/share/nginx/html/wp-config-sample.php /usr/share/nginx/html/wp-config.php
    6.编辑wp-config.php:vim /usr/share/nginx/html/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:
     *
     * * Database settings
     * * Secret keys
     * * Database table prefix
     * * ABSPATH
     *
     * @link https://wordpress.org/support/article/editing-wp-config-php/
     *
     * @package WordPress
     */
    
    // ** Database settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('WP_CACHE', true);
    define( 'WPCACHEHOME', '/usr/share/nginx/html/wp-content/plugins/wp-super-cache/' );
    define( 'DB_NAME', 'wordpress' );
    
    /** Database username */
    define( 'DB_USER', 'wpadmin' );
    
    /** Database password */
    define( 'DB_PASSWORD', 'wppasswd' );
    
    /** Database 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_';
    
    /**
     * 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 documentation.
     *
     * @link https://wordpress.org/support/article/debugging-in-wordpress/
     */
    define( 'WP_DEBUG', false );
    
    /* Add any custom values between this line and the "stop editing" line. */
    
    
    
    /* That's all, stop editing! Happy publishing. */
    
    /** Absolute path to the WordPress directory. */
    if ( ! defined( 'ABSPATH' ) ) {
    	define( 'ABSPATH', __DIR__ . '/' );
    }
    
    /** Sets up WordPress vars and included files. */
    require_once ABSPATH . 'wp-settings.php';
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
  • 相关阅读:
    【DTEmpower案例操作教程】向导式建模
    3D视觉应用案例:引导板件定位抓取
    ensp中查看带宽信息
    springboot毕设项目宠物社区网站mud2d(java+VUE+Mybatis+Maven+Mysql)
    根号2是无理数的两种证明以及如何计算根号2的值
    golang validator v10 自定义验证方法和错误
    STM32国产替代方案
    kubenetes-容器网络接口CNI
    Python究竟属不属于嵌入式语言?
    Linux内核读取spi-nor flash sn
  • 原文地址:https://blog.csdn.net/xinxiaoyu_/article/details/126498951