APNIC地址池
官方地址:https://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest
文件格式:
注册机构|国家/地址代码|类型|起始地址|IP数量|分配日期|状态
官方地址:https://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest
文件格式:
注册机构|国家/地址代码|类型|起始地址|IP数量|分配日期|状态
[root@node22 docker]# hostnamectl
Static hostname: node22
Icon name: computer-vm
Chassis: vm
Machine ID: a7e5992d13a64d1b948fcd4ad6efe042
Boot ID: 0012a7d9089b4a52bdf6c77975cbc5de
Virtualization: vmware
Operating System: CentOS Linux 8
CPE OS Name: cpe:/o:centos:centos:8
Kernel: Linux 4.18.0-348.el8.x86_64
Architecture: x86-64
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
yum makecache
yum -y install docker-ce
systemctl start docker
systemctl enable docker
ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/bin/docker-compose
后面发现docker-compose在后面版本中已被整合进docker命令里,可以直接用docker compose
调用,此步选做。
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://oxv7blf7.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
[root@node22 ~]# docker version
Client: Docker Engine - Community
Version: 24.0.7
API version: 1.43
Go version: go1.20.10
Git commit: afdd53b
Built: Thu Oct 26 09:09:18 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 24.0.7
API version: 1.43 (minimum version 1.12)
Go version: go1.20.10
Git commit: 311b9ff
Built: Thu Oct 26 09:08:20 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.24
GitCommit: 61f9fd88f79f081d64d6fa3bb1a0dc71ec870523
runc:
Version: 1.1.9
GitCommit: v1.1.9-0-gccaecfc
docker-init:
Version: 0.19.0
GitCommit: de40ad0
[root@node22 ~]# docker-compose -v
Docker Compose version v2.21.0
workspace.v1.1.zip调整内容:
selinux/config
文件替换步骤,使用lineinfile
模块代替shell模块;handler
和notify
关键词及触发器概念,将多次重启Apache步骤改为handler
操作;template
概念,使用预定义的模板文件生成wp-config.php
配置文件;uri
模块,用于代替手工Web端安装操作,实现wordpress
安装完全自动化;具体代码:
---
- hosts: 192.168.26.21
gather_facts: True
vars:
wp_db_hostname: localhost
wp_db_name: wordpressdb
wp_db_user: wordpress
wp_db_password: wordpress
tasks:
# common tasks
- name: Install epel-release
yum:
name: epel-release
state: present
- name: Temporary Disable SELinux
command: setenforce 0
- name: Ensure SELinux is set to disabled mode
lineinfile:
path: /etc/selinux/config
regexp: '^SELINUX='
line: SELINUX=disabled
# Install apache server
- name: Install httpd
yum:
name: httpd
state: present
- name: Start httpd
service:
name: httpd
state: started
enabled: True
- name: Permit 80/tcp port
firewalld:
service: http
permanent: True
immediate: True
state: enabled
#Install php82
- name: Install epel-release-latest-7
yum:
name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
state: present
- name: Install remirepo
yum:
name: https://rpms.remirepo.net/enterprise/remi-release-7.rpm
state: present
- name: Enable remi-php82 repo
shell: yum-config-manager --enable remi-php82
- name: Install php82
yum:
name:
- php82-php
- php82-php-mbstring
- php82-php-mysqlnd
- php82-php-gd
- php82-php-xml
state: present
notify:
- Restart httpd
- name: Install mariadb-server
yum:
name: mariadb-server
state: present
- name: Start mariadb-server
service:
name: mariadb
state: started
enabled: True
- name: Install pip
yum:
name: python2-pip
state: present
- name: Install Python Library
pip:
name: PyMySQL==0.10.0
state: present
- name: Create Database
mysql_db:
name: "{{ wp_db_name }}"
state: present
- name: Create database user
mysql_user:
name: "{{ wp_db_user }}"
password: "{{ wp_db_password }}"
priv: '{{ wp_db_name }}.*:ALL'
state: present
# Install wordpress
- name: Install wordpress
get_url:
url: https://wordpress.org/wordpress-6.2.tar.gz
dest: /tmp/wordpress-6.2.tar.gz
checksum: md5:34f279efe623025641bc11a69e3c02fa
- name: Extract wordpress-6.X.tar.gz into /var/www/wordpress
unarchive:
src: /tmp/wordpress-6.2.tar.gz
dest: /var/www/
remote_src: True
- name: Recursive Modify file permission
file:
path: /var/www/wordpress
owner: apache
group: apache
mode: '0766'
recurse: True
state: directory
- name: Add apache virtual host config
copy:
src: wordpress.conf
dest: /etc/httpd/conf.d/wordpress.conf
notify:
- Restart httpd
- name: Restart httpd
service:
name: httpd
state: restarted
- name: Fetch random salts for WordPress config
local_action: command curl https://api.wordpress.org/secret-key/1.1/salt/
register: "wp_salt"
become: no
- name: Add wordpress config
template:
src: templates/wp-config.php.j2
dest: /var/www/wordpress/wp-config.php
owner: apache
group: apache
mode: '0744'
- name: Install WordPress
uri:
url: "http://192.168.26.21/wp-admin/install.php?step=2"
method: POST
body_format: form-urlencoded
body:
weblog_title: HelloWorld
user_name: tony
admin_password: e!sGma&jmC#ernVBQV
admin_password2: e!sGma&jmC#ernVBQV
admin_email: lixm@lixm.cc
Submit: Install WordPress
status_code: 200
register: result
- name: Print result
debug:
msg: "{{ result }}"
handlers:
- name: Restart httpd
service:
name: httpd
state: restarted
模板文件:/templates/wp-config.php.j2
<?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/documentation/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( 'DB_NAME', '{{ wp_db_name }}' );
/** Database username */
define( 'DB_USER', '{{ wp_db_user }}' );
/** Database password */
define( 'DB_PASSWORD', '{{ wp_db_password }}' );
/** Database hostname */
define( 'DB_HOST', '{{ wp_db_hostname }}' );
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8mb4' );
/** 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
*/
{{ wp_salt.stdout }}
/**#@-*/
/**
* 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/documentation/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';
Apache配置文件:
<VirtualHost _default_:80>
DocumentRoot /var/www/wordpress/
ServerName www.example.com
<Directory /var/www/wordpress/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
</VirtualHost>
---
- hosts: 192.168.26.21
gather_facts: True
tasks:
# common tasks
- name: Install epel-release
yum:
name: epel-release
state: present
- name: Temporary Disable SELinux
command: setenforce 0
- name: Disable SELinux
shell: sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
# Install apache server
- name: Install httpd
yum:
name: httpd
state: present
- name: Start httpd
service:
name: httpd
state: started
enabled: True
- name: Permit 80/tcp port
firewalld:
service: http
permanent: True
immediate: True
state: enabled
#Install php82
- name: Install epel-release-latest-7
yum:
name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
state: present
- name: Install remirepo
yum:
name: https://rpms.remirepo.net/enterprise/remi-release-7.rpm
state: present
- name: Enable remi-php82 repo
shell: yum-config-manager --enable remi-php82
- name: Install php82
yum:
name:
- php82-php
- php82-php-mbstring
- php82-php-mysqlnd
- php82-php-gd
- php82-php-xml
state: present
- name: Install mariadb-server
yum:
name: mariadb-server
state: present
- name: Start mariadb-server
service:
name: mariadb
state: started
enabled: True
- name: Install pip
yum:
name: python2-pip
state: present
- name: Install Python Library
pip:
name: PyMySQL==0.10.0
state: present
- name: Create Database
mysql_db:
name: wordpressdb
state: present
- name: Create database user
mysql_user:
name: wordpress
password: wordpress
priv: 'wordpressdb.*:ALL'
state: present
# Install wordpress
- name: Install wordpress
get_url:
url: https://wordpress.org/wordpress-6.2.tar.gz
dest: /tmp/wordpress-6.2.tar.gz
checksum: md5:34f279efe623025641bc11a69e3c02fa
- name: Extract wordpress-6.X.tar.gz into /var/www/wordpress
unarchive:
src: /tmp/wordpress-6.2.tar.gz
dest: /var/www/
remote_src: True
- name: Recursive Modify file permission
file:
path: /var/www/wordpress
owner: apache
group: apache
mode: '0766'
recurse: True
state: directory
- name: Add apache virtual host config
copy:
src: wordpress.conf
dest: /etc/httpd/conf.d/wordpress.conf
- name: Restart httpd
service:
name: httpd
state: restarted
- name: Add wordpress config
copy:
src: wp-config.php
dest: /var/www/wordpress/wp-config.php
owner: apache
group: apache
mode: '0744'
打开VScode,在remote-ssh插件配置文件中填写如下内容,配置文件位置:C:\Users\lixm.ssh\config
Host 192.168.26.20
HostName 192.168.26.20
User root
Port 22
IdentityFile "C:\Users\lixm\.ssh\id_rsa"
pip install PyMySQL==0.10.0 -i https://mirrors.aliyun.com/pypi/simple/