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
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 {
# }
# }
}
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
编辑: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
4.初始化mariadb:mysql_secure_installation
5.验证php运行:vim /usr/share/nginx/html/phpinfo.php
<?php
phpinfo()
?>
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;
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';