ithzhang 2019-12-02
yum remove php-mysql php php-fpm php-common
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install -y php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb
[ conf.d] # cat /etc/nginx/conf.d/blog.conf
server {
listen 80;
server_name blog.oldboy.com;
client_max_body_size 10m;
location / {
root /html/blog;
index index.html index.htm;
}
location ~ \.php$ {
root /html/blog;
fastcgi_pass 127.0.0.1:9000;????????????????9000是php-fpm的端口
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;????????????????解析变量
}
}
mkdir -p /html/blog/????????????????创建站点目录
?
touch test_phpinfo.php????????????????创建资源信息
<?php
phpinfo();
?>
[ conf.d] # vim /etc/php-fpm.d/www.conf
1 ; Start a new pool named ‘www‘.
2 [www]
3
4 ; Unix user/group of processes
5 ; Note: The user is mandatory. If the group is not set, the default user‘s group
6 ; will be used.
7 ; RPM: apache Choosed to be able to access some dir as httpd
8 user = www
9 ; RPM: Keep a group allowed to write in log dir.
10 group = www
systemctl start php-fpm.service
systemctl enable php-fpm.service
?
yum install mariadb-server mariadb -y
systemctl start mariadb.service
systemctl enable mariadb.service
[ ~] # mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 191
Server version: 5.5.64-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)]>????????????????看见这个信息就是进入了mysql
show databases;????????????????????????????????????????查看数据库
use mysql????????????????????????????????????????????使用某个数据库
show tables????????????????????????????????????????????查看表的信息
create database 数据库????????????????????????????????????创建数据库
drop database 数据库????????????????????????????????????删除数据库
select user,host from mysql.user;????????????????????????????查看某个表的信息
delete from mysql.user where name=xx????????????????????????删除指定的name数据
mysqladmin -uroot password ‘oldboy123‘????????????????????设置root的密码
mysqldump -uroot -poldboy123 -A > /tmp/aa.sql????????????????将所有的数据库进行备份
mysql -uroot -poldboy123 < /tmp/aa,sql????????????????????????将库还原到数据库里面
查看tmp目录是不是1777权限
查看配置文件是不是在/etc/my.cnf
cd /html/blog????????????????切换站点目录
?
vim test_mysql.php????????????编辑测试文件
<?php
$servername = "localhost";
$username = "root";
$password = "oldboy123";
//$link_id=mysql_connect(‘主机名‘,‘用户‘,‘密码‘);
//mysql -u用户 -p密码 -h 主机
$conn = mysqli_connect($servername, $username, $password);
if ($conn) {
echo "mysql successful by root !\n";
}else{
die("Connection failed: " . mysqli_connect_error());
}
?>
https://cn.wordpress.org/download/????????????wordpress(blog)
[ conf.d] # cat /etc/nginx/conf.d/blog.conf
server {
listen 80;
server_name blog.oldboy.com;
client_max_body_size 10m;
location / {
root /html/blog;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /html/blog;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
[ conf.d] # cd /html/blog/
?
[ blog] # ll
total 204
-rw-r--r-- 1 www www 420 Dec 1 2017 index.php
-rw-r--r-- 1 www www 19935 Oct 15 17:06 license.txt
-rw-r--r-- 1 www www 7005 Oct 15 17:07 readme.html
-rw-r--r-- 1 root root 428 Nov 11 23:25 test_mysql.php
-rw-r--r-- 1 www www 6919 Jan 12 2019 wp-activate.php
drwxr-xr-x 9 www www 4096 Oct 15 17:00 wp-admin
-rw-r--r-- 1 www www 369 Dec 1 2017 wp-blog-header.php
-rw-r--r-- 1 www www 2283 Jan 21 2019 wp-comments-post.php
-rw-r--r-- 1 www www 2973 Nov 12 11:13 wp-config.php
-rw-r--r-- 1 www www 2776 Oct 15 17:07 wp-config-sample.php
drwxr-xr-x 6 www www 84 Nov 12 10:57 wp-content
-rw-r--r-- 1 www www 3847 Jan 9 2019 wp-cron.php
drwxr-xr-x 20 www www 8192 Oct 15 17:07 wp-includes
-rw-r--r-- 1 www www 2502 Jan 16 2019 wp-links-opml.php
-rw-r--r-- 1 www www 3306 Dec 1 2017 wp-load.php
-rw-r--r-- 1 www www 39551 Jun 10 21:34 wp-login.php
[ blog] #
create database wordpress
grant all on wordpress.* to ‘wordpress‘@‘localhost‘ identified by ‘oldboy123‘;
[ blog] # cat wp-config.php
<?php
/**
* WordPress基础配置文件。
*
* 这个文件被安装程序用于自动生成wp-config.php配置文件,
* 您可以不使用网站,您需要手动复制这个文件,
* 并重命名为"wp-config.php",然后填入相关信息。
*
* 本文件包含以下配置选项:
*
* * MySQL设置
* * 密钥
* * 数据库表名前缀
* * ABSPATH
*
* @link https://codex.wordpress.org/zh-cn:%E7%BC%96%E8%BE%91_wp-config.php
*
* @package WordPress
*/
?
// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
/** WordPress数据库的名称 */
define( ‘DB_NAME‘, ‘wordpress‘ );
?
/** MySQL数据库用户名 */
define( ‘DB_USER‘, ‘wordpress‘ );
?
/** MySQL数据库密码 */
define( ‘DB_PASSWORD‘, ‘oldboy123‘ );
?
/** MySQL主机 */
define( ‘DB_HOST‘, ‘172.16.1.51‘ );
?
/** 创建数据表时默认的文字编码 */
define( ‘DB_CHARSET‘, ‘utf8mb4‘ );
?
/** 数据库整理类型。如不确定请勿更改 */
define( ‘DB_COLLATE‘, ‘‘ );
?
/**#@+
* 身份认证密钥与盐。
*
* 修改为任意独一无二的字串!
* 或者直接访问{@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org密钥生成服务}
* 任何修改都会导致所有cookies失效,所有用户将必须重新登录。
*
* @since 2.6.0
*/
define( ‘AUTH_KEY‘, ‘ oZ$<2[Ngf&r0UZ9(a.iz,LNROA~ON$|S>R+94r#BFk3Hvz*9oVj:F.7*KL5qJ6Q‘ );
define( ‘SECURE_AUTH_KEY‘, ‘!/:02gSG&#%+erC://`O,qFe]lXGfXc<%Ev~^rR}{7o<rY%G%e‘ );
define( ‘LOGGED_IN_KEY‘, ‘+>),x;J0>9:I|rN,/=vSd3V0z%sTE~W2l*D!fj/jR_|f5jIV3C&?FgrhT8CiYm/M‘ );
define( ‘NONCE_KEY‘, ‘Y8$FE|UT(?`76Uy:@EHi5gJ&U<uyQl,]kq/0^u40%t/d^ >`>7rz~Tp7Ue]8vgSd‘ );
define( ‘AUTH_SALT‘, ‘pI)Pe30w)9k>w~vn7c?C:S1A5Q#Y1<*clB7ilK:vx9[r3o3erh/pw3||<Lh‘ );
define( ‘SECURE_AUTH_SALT‘, ‘zA!%g1`8&yH`d|M,ix:h)R_x1x-^^=fP*QI+C_$MWtqPA9u=D<!KlYZ,kh 3JPp6‘ );
define( ‘LOGGED_IN_SALT‘, ‘z- OgDNXu6DOxX}|0VPae.gbK(XqIV*:mM# =b]UP%f`2U|S]0dK$]NN]MM0[*N9‘ );
define( ‘NONCE_SALT‘, ‘H|bg,FwOJ|yqtkHN:4EtJ*_$+bnUM67/Ny<#mLjfbOZl7:gW&^Q<ELSs64?rMR1q‘ );
?
/**#@-*/
?
/**
* WordPress数据表前缀。
*
* 如果您有在同一数据库内安装多个WordPress的需求,请为每个WordPress设置
* 不同的数据表前缀。前缀名只能为数字、字母加下划线。
*/
$table_prefix = ‘wp_‘;
?
/**
* 开发者专用:WordPress调试模式。
*
* 将这个值改为true,WordPress将显示所有用于开发的提示。
* 强烈建议插件开发者在开发环境中启用WP_DEBUG。
*
* 要获取其他能用于调试的信息,请访问Codex。
*
* @link https://codex.wordpress.org/Debugging_in_WordPress
*/
define(‘WP_DEBUG‘, false);
?
/* 好了!请不要再继续编辑。请保存本文件。使用愉快! */
?
/** WordPress目录的绝对路径。 */
if ( ! defined( ‘ABSPATH‘ ) ) {
????define( ‘ABSPATH‘, dirname( __FILE__ ) . ‘/‘ );
}
?
/** 设置WordPress变量和包含文件。 */
require_once( ABSPATH . ‘wp-settings.php‘ );
?
[ blog] #
问题的原因:这种上传不上去是因为客户将数据给了web服务器,会进行身份的转换,由于是动态的请求需要将信息抛给php处理,php在存储的时候由于自己本身的属主和属组是apache,而用户上传的数据是root权限是没有办法进行存储的
chmod o+x /html/blog/wp-content
chown -R apache. /html/blog/
2????[www]
3????
4????; Unix user/group of processes
5????; Note: The user is mandatory. If the group is not set, the default user‘s group
6????; will be used.
7????; RPM: apache Choosed to be able to access some dir as httpd
8????user = www????????????????????将属主修改成www
9????; RPM: Keep a group allowed to write in log dir.
10????group = www????????????????????将属组修改成www
?
[ conf.d] # cat /etc/nginx/conf.d/blog.conf
server {
listen 80;
server_name blog.oldboy.com;
client_max_body_size 10m; ????????????????????设置大小为10M
location / {
root /html/blog;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /html/blog;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
vim /etc/php.ini
779 upload_max_filesize = 10M????????????????指定最大上传文件大小限制
656 post_max_size = 10M????????????????????请求主体最大尺寸
802 max_execution_time = 300????????????????执行上传数据操作最大执行时间
yum install -y mariadb mariadb-server????????????????安装数据库
systemctl start mariadb.service????????????????????启动数据库
mysqladmin -uroot password ‘oldboy123‘????????????设置密码
?
mysqldump -uroot -poldboy123 -A >/tmp/mysql_backup.sql????????????备份数据库
?
rsync -avz /tmp/mysql_backup.sql 172.16.1.51:/tmp????????????????将数据进行传输
mysql -uroot -poldboy123 < /tmp/mysql_backup.sql
mysql -uroot -p123456 -e "grant all on wordpress.* to ‘wordpress‘@‘172.16.1.%‘ identified by ‘oldboy123‘;"
[ ~] # cat /html/blog/wp-config.php
<?php
?
define( ‘DB_NAME‘, ‘wordpress‘ );
?
/** MySQL数据库用户名 */
define( ‘DB_USER‘, ‘wordpress‘ );
?
/** MySQL数据库密码 */
define( ‘DB_PASSWORD‘, ‘oldboy123‘ );
?
/** MySQL主机 */
define( ‘DB_HOST‘, ‘172.16.1.51‘ );????????????改成远程的数据库服务器内网IP
1) 检查连接数据库代码文件配置是否正确
mysql -uwordpress -poldboy123 -h172.16.1.51
2) 修改数据库用户信息
方法一: 允许用户使用 ‘web01‘ 连接
grant all on wordpress.* to ‘wordpress‘@‘web01‘ identified by ‘oldboy123‘;
方法二: 关闭数据库反向解析操作(跳过反向解析过程)????
delete from mysql.user where user=‘wordpress‘ and host=‘web01‘; 删除表信息
flush privileges;
vim /etc/my.cnf
[mysqld]
skip-name-resolve
重启数据库服务
?
[ yum.repos.d] # cd /html/blog/wp-content/uploads????????????????????已经找见
You have new mail in /var/spool/mail/root
[ uploads] # ll
total 0
drwxr-xr-x 3 www www 16 Nov 17 22:04 2019
[ uploads] #
[ uploads] # mv /html/blog/wp-content/uploads/* /tmp
[ uploads] # showmount -e 172.16.1.31
Export list for 172.16.1.31:
/data/zhihu 172.16.1.0/24
/data/blog 172.16.1.0/24
/data/bbs 172.16.1.0/24
[ uploads] #
[ uploads] # mount -t nfs 172.16.1.31:/data/blog /html/blog/wp-content/uploads
[ uploads] # mv /tmp/* /html/blog/wp-content/uploads/
执行命令brew install php72,出现下图即为安装成功;需要按照提示添加环境变量;重新加载配置|重启|停止|退出 nginxnginx -s reload|reopen|stop|quit