[root@test01 ~]# yum install mariadb
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
nginx-mainline | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): nginx-mainline/7Server/x86_64/primary_db | 227 kB 00:00:02
(2/2): updates/x86_64/primary_db | 12 MB 00:00:03
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.68-1.el7 will be installed
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.68-1.el7 for package: 1:mariadb-5.5.68-1.el7.x86_64
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be updated
---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================================================
Installing:
mariadb x86_64 1:5.5.68-1.el7 base 8.8 M
Updating for dependencies:
mariadb-libs x86_64 1:5.5.68-1.el7 base 760 k
Transaction Summary
==================================================================================================================================================================================================================
Install 1 Package
Upgrade ( 1 Dependent package)
Total download size: 9.5 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/2): mariadb-libs-5.5.68-1.el7.x86_64.rpm | 760 kB 00:00:00
(2/2): mariadb-5.5.68-1.el7.x86_64.rpm | 8.8 MB 00:00:02
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 3.3 MB/s | 9.5 MB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 1:mariadb-libs-5.5.68-1.el7.x86_64 1/3
Installing : 1:mariadb-5.5.68-1.el7.x86_64 2/3
Cleanup : 1:mariadb-libs-5.5.56-2.el7.x86_64 3/3
Verifying : 1:mariadb-libs-5.5.68-1.el7.x86_64 1/3
Verifying : 1:mariadb-5.5.68-1.el7.x86_64 2/3
Verifying : 1:mariadb-libs-5.5.56-2.el7.x86_64 3/3
Installed:
mariadb.x86_64 1:5.5.68-1.el7
Dependency Updated:
mariadb-libs.x86_64 1:5.5.68-1.el7
Complete!
[root@test01 ~]# yum install mariadb-server
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package mariadb-server.x86_64 1:5.5.68-1.el7 will be installed
--> Processing Dependency: perl-DBI for package: 1:mariadb-server-5.5.68-1.el7.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.68-1.el7.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: 1:mariadb-server-5.5.68-1.el7.x86_64
--> Processing Dependency: perl(DBI) for package: 1:mariadb-server-5.5.68-1.el7.x86_64
--> Running transaction check
---> Package perl-DBD-MySQL.x86_64 0:4.023-6.el7 will be installed
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
--> Running transaction check
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Running transaction check
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================================================
Installing:
mariadb-server x86_64 1:5.5.68-1.el7 base 11 M
Installing for dependencies:
perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k
perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k
perl-DBD-MySQL x86_64 4.023-6.el7 base 140 k
perl-DBI x86_64 1.627-4.el7 base 802 k
perl-Data-Dumper x86_64 2.145-3.el7 base 47 k
perl-IO-Compress noarch 2.061-2.el7 base 260 k
perl-Net-Daemon noarch 0.48-5.el7 base 51 k
perl-PlRPC noarch 0.2020-14.el7 base 36 k
Transaction Summary
==================================================================================================================================================================================================================
Install 1 Package (+8 Dependent packages)
Total download size: 13 M
Installed size: 62 M
Is this ok [y/d/N]: y
Downloading packages:
(1/9): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm | 32 kB 00:00:00
(2/9): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm | 57 kB 00:00:00
(3/9): perl-DBD-MySQL-4.023-6.el7.x86_64.rpm | 140 kB 00:00:00
(4/9): perl-DBI-1.627-4.el7.x86_64.rpm | 802 kB 00:00:00
(5/9): perl-Data-Dumper-2.145-3.el7.x86_64.rpm | 47 kB 00:00:00
(6/9): perl-IO-Compress-2.061-2.el7.noarch.rpm | 260 kB 00:00:00
(7/9): perl-Net-Daemon-0.48-5.el7.noarch.rpm | 51 kB 00:00:00
(8/9): perl-PlRPC-0.2020-14.el7.noarch.rpm | 36 kB 00:00:00
(9/9): mariadb-server-5.5.68-1.el7.x86_64.rpm | 11 MB 00:00:03
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 3.4 MB/s | 13 MB 00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : perl-Data-Dumper-2.145-3.el7.x86_64 1/9
Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 2/9
Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 3/9
Installing : perl-IO-Compress-2.061-2.el7.noarch 4/9
Installing : perl-Net-Daemon-0.48-5.el7.noarch 5/9
Installing : perl-PlRPC-0.2020-14.el7.noarch 6/9
Installing : perl-DBI-1.627-4.el7.x86_64 7/9
Installing : perl-DBD-MySQL-4.023-6.el7.x86_64 8/9
Installing : 1:mariadb-server-5.5.68-1.el7.x86_64 9/9
Verifying : perl-Net-Daemon-0.48-5.el7.noarch 1/9
Verifying : perl-Data-Dumper-2.145-3.el7.x86_64 2/9
Verifying : 1:mariadb-server-5.5.68-1.el7.x86_64 3/9
Verifying : perl-DBD-MySQL-4.023-6.el7.x86_64 4/9
Verifying : perl-IO-Compress-2.061-2.el7.noarch 5/9
Verifying : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 6/9
Verifying : perl-DBI-1.627-4.el7.x86_64 7/9
Verifying : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 8/9
Verifying : perl-PlRPC-0.2020-14.el7.noarch 9/9
Installed:
mariadb-server.x86_64 1:5.5.68-1.el7
Dependency Installed:
perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBD-MySQL.x86_64 0:4.023-6.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7
perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7
Complete!
[root@test01 ~]# systemctl start mariadb
[root@test01 ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2021-11-06 17:59:50 CST; 6s ago
Process: 1715 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
Process: 1632 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 1714 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─1714 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─1879 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/v...
Nov 06 17:59:48 test01 mariadb-prepare-db-dir[1632]: MySQL manual for more instructions.
Nov 06 17:59:48 test01 mariadb-prepare-db-dir[1632]: Please report any problems at http://mariadb.org/jira
Nov 06 17:59:48 test01 mariadb-prepare-db-dir[1632]: The latest information about MariaDB is available at http://mariadb.org/.
Nov 06 17:59:48 test01 mariadb-prepare-db-dir[1632]: You can find additional information about the MySQL part at:
Nov 06 17:59:48 test01 mariadb-prepare-db-dir[1632]: http://dev.mysql.com
Nov 06 17:59:48 test01 mariadb-prepare-db-dir[1632]: Consider joining MariaDB's strong and vibrant community:
Nov 06 17:59:48 test01 mariadb-prepare-db-dir[1632]: https://mariadb.org/get-involved/
Nov 06 17:59:48 test01 mysqld_safe[1714]: 211106 17:59:48 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Nov 06 17:59:48 test01 mysqld_safe[1714]: 211106 17:59:48 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Nov 06 17:59:50 test01 systemd[1]: Started MariaDB database server.
[root@test01 ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
数据库的初始化过程:
- -basedir=path 指定mysql程序目录
- -datadir=path 指定数据信息的保存目录
- -user=mysql 让mysql管理数据目录700
[root@test01 ~]# mysqladmin -u root password '123456'
[root@test01 ~]# rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Retrieving https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
warning: /var/tmp/rpm-tmp.cAquxa: Header V4 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:epel-release-7-14 ################################# [100%]
[root@test01 ~]# rpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
warning: /var/tmp/rpm-tmp.AcRa3a: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:webtatic-release-7-3 ################################# [100%]
[root@test01 ~]# yum install php71w php71w-fpm php71w-cli php71w-common php71w-devel php71w-gd php71w-pdo php71w-mysql php71w-mbstring php71w-bcmath php71w-embedded php71w-mcrypt php71w-pecl-redis php71w-pecl-mongodb
[root@test01 ~]# egrep 'user|group' /etc/php-fpm.d/www.conf |grep -v '^;'
user = www
group = www
[root@test01 ~]# systemctl start php-fpm
[root@test01 ~]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2021-11-06 18:36:46 CST; 5s ago
Main PID: 2196 (php-fpm)
Status: "Ready to handle connections"
CGroup: /system.slice/php-fpm.service
├─2196 php-fpm: master process (/etc/php-fpm.conf)
├─2198 php-fpm: pool www
├─2199 php-fpm: pool www
├─2200 php-fpm: pool www
├─2201 php-fpm: pool www
└─2202 php-fpm: pool www
Nov 06 18:36:45 test01 systemd[1]: Starting The PHP FastCGI Process Manager...
Nov 06 18:36:46 test01 systemd[1]: Started The PHP FastCGI Process Manager.
[root@test01 conf.d]# cat blog.conf
server {
listen 80;
server_name blog.xcnyunyun.com;
location / {
root /html/blog;
index index.html;
}
location ~ \.php$ { 当访问动态页面启动这个location
root /html/blog; #指定站点目录
fastcgi_index index.php; #指定首页文件
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #指定url和uri信息
fastcgi_pass 127.0.0.1:9000; #和PHP关联
include fastcgi_params; #加载一个变量配置文件
}
}
编写一个php测试文件
[root@test01 blog]# cat index.php
<?php
phpinfo();
?>
[root@test01 blog]# cat index_mysql.php
<?php
$servername = "localhost";
$username = "root";
$passwd = "123456";
$conn = mysqli_connect($servername, $username, $passwd);
if ($conn) {
echo "succ";
}else{
die("fail:" . mysqli_connect_error());
}
?>
[root@test01 html]# cd /html/
[root@test01 html]# tar -xzvf wordpress-5.8.1.tar.gz
[root@test01 html]# cd wordpress
[root@test01 wordpress]# ls
index.php readme.html wp-admin wp-comments-post.php wp-content wp-includes wp-load.php wp-mail.php wp-signup.php xmlrpc.php
license.txt wp-activate.php wp-blog-header.php wp-config-sample.php wp-cron.php wp-links-opml.php wp-login.php wp-settings.php wp-trackback.php
[root@test01 wordpress]# mv ./* /html/blog/index
index.html index_mysql.php index.php
[root@test01 wordpress]# mv ./* /html/blog/
mv: overwrite ‘/html/blog/index.php’? y
[root@test01 wordpress]# ls
[root@test01 wordpress]# ls /html/blog/
index.html index.php readme.html wp-admin wp-comments-post.php wp-content wp-includes wp-load.php wp-mail.php wp-signup.php xmlrpc.php
index_mysql.php license.txt wp-activate.php wp-blog-header.php wp-config-sample.php wp-cron.php wp-links-opml.php wp-login.php wp-settings.php wp-trackback.php
[root@test01 wordpress]# cd /html/
[root@test01 html]# ls
bbs blog bog wordpress wordpress-5.8.1.tar.gz www
[root@test01 html]# ll
total 14740
drwxr-xr-x. 2 root root 24 Oct 27 04:29 bbs
drwxr-xr-x. 5 root root 4096 Nov 6 19:47 blog
drwxr-xr-x. 2 root root 6 Nov 6 19:09 bog
drwxr-xr-x. 2 nobody 65534 6 Nov 6 19:47 wordpress
-rw-r--r--. 1 root root 15087630 Nov 6 19:43 wordpress-5.8.1.tar.gz
drwxr-xr-x. 6 root root 106 Nov 4 05:17 www
[root@test01 html]# chown -R www.www blog
[root@test01 html]# ll
total 14740
drwxr-xr-x. 2 root root 24 Oct 27 04:29 bbs
drwxr-xr-x. 5 www www 4096 Nov 6 19:47 blog
drwxr-xr-x. 2 root root 6 Nov 6 19:09 bog
drwxr-xr-x. 2 nobody 65534 6 Nov 6 19:47 wordpress
-rw-r--r--. 1 root root 15087630 Nov 6 19:43 wordpress-5.8.1.tar.gz
drwxr-xr-x. 6 root root 106 Nov 4 05:17 www
[root@test01 html]# mysql -uroot -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create databases wordpress;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'databases wordpress' at line 1
MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| wordpress |
+--------------------+
5 rows in set (0.00 sec)
创建数据库管理用户
[root@test01 html]# mysql -uroot -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> grant all on wordpress.* to'wordpress'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
访问测试
在location /中没有index.php的首页文所以上面的定义的http://blog.xcnyunyun.com/wp-admin/找不到首页文件,所以不显示
[root@test01 blog]# cat /etc/nginx/conf.d/blog.conf
server {
listen 80;
server_name blog.xcnyunyun.com;
location / {
root /html/blog;
index index.php index.html;
}
location ~ \.php$ {
root /html/blog;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
delete from mysql.user where user="" and host="localhost";
删除user列是空的和host列是localhost的
delete from mysql.user where user="" and host="web01";
删除user列是空的和host列是web01的
添加新的用户信息
grant all on wordpress.* to 'wordpress'@'192.168.192.%' identified by '123456';
使192.168.192的网段可以使用wordpress连接