centos7安装配置wordpress博客系统

行云流水
2022-03-09 / 0 评论 / 738 阅读 / 正在检测是否收录...

前言

LAMP是 linux Apache MySQL PHP的简写,即把Apache MySQL PHP 安装在linux系统上,组成一个环境来运行PHP网站。这里的Apache是httpd服务。这些可以安装在一个机器上,也可以安装在多台机器上,但是httpd和PHP安装在一台机器上(php作为httpd的一个模块存在的。 他们两者必须要在一起,才能实现效果)

安装配置apache+php服务

apache和php安装命令

yum install httpd  httpd-devel
yum -y install epel-release
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y install yum-utils
yum-config-manager --enable remi-php74
yum -y 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

php配置优化

php安装后测试

php -v
php --modules

整体功能测试

echo '<?php phpinfo(); ?>' >  index.php
通过浏览器访问出现下图界面,即php安装正常

安装配置mysql数据库服务

清除默认的maradb

yum list installed | grep mariadb
yum -y remove  mariadb-libs.x86_64

安装依赖包

yum install -y perl.x86_64  libaio.x86_64  net-tools.x86_64 perl-Compress-Raw-Bzip2  perl-Compress-Raw-Zlib  perl-DBI perl-IO-Compress perl-Net-Daemon perl-PlRPC

下载mysql安装包,并安装

wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.6/MySQL-client-5.6.51-1.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.6/MySQL-server-5.6.51-1.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.6/MySQL-devel-5.6.51-1.el7.x86_64.rpm
yum localinstall MySQL-*

配置 mysql

vim /etc/my.cnf

配置内容

[mysql]
port                           = 3306
socket                         = /data/mysql/mysql.sock
prompt                         = "\\u@\\h \\D \\R:\\m:\\s [\\d]>
tee                            = /data/logs/mysql/query.log

[mysqld]
user                           = mysql
socket                         = /data/mysql/mysql.sock
pid-file                       = /data/mysql/mysql.pid
key-buffer-size                = 32M
max-allowed-packet             = 16M
max-connect-errors             = 10000
skip-name-resolve
sysdate-is-now                 = 1
datadir                        = /data/mysql/
log-bin                        = /data/mysql/mysql-bin
sync-binlog                    = 1
tmp-table-size                 = 32M
max-heap-table-size            = 32M
max-connections                = 500
thread-cache-size              = 50
open-files-limit               = 9999
table-definition-cache         = 4096
table-open-cache               = 4096
innodb-flush-method            = O_DIRECT
innodb-log-files-in-group      = 2
innodb-log-file-size           = 64M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table          = 1
innodb-buffer-pool-size        = 512M
log-error                      = /data/logs/mysql/mysql-error.log
log-queries-not-using-indexes  = 1
slow-query-log                 = 1
slow-query-log-file            = /data/logs/mysql/mysql-slow.log

创建目录,修改目录权限

mkdir  -p  /data/mysql/     /data/logs/      /data/logs/mysql/
chown -R  mysql:mysql /data/logs/mysql/

数据库初始化

mysql_install_db --user=mysql --datadir=/data/mysql 
systemctl  start mysql 
/usr/bin/mysqladmin -u root password -S /data/mysql/mysql.sock

查看mysql服务状态

systemctl status mysql

安装完成

安装配置wordpress博客

下载安装包

wget https://wordpress.org/wordpress-5.6.tar.gz
wget https://wp101.net/wordpress-5.6.tar.gz

解压

tar xvf wordpress-5.6.tar.gz
sudo mv wordpress /var/www/html/mywordpress/

更改代码目录权限

chown -R apache:apache  /var/www/html/mywordpress/

修改配置文件httpd服务的配置

vim /etc/httpd/conf/httpd.conf

配置内容

<VirtualHost *:80>
       ServerName   www.mywordpress.com
       DocumentRoot    /var/www/html/mywordpress
       <Directory "/var/www/html/mywordpress">
            Options Indexes FollowSymLinks Includes
            AllowOverride All
            order allow,deny
            Allow from all
       </Directory>
       DirectoryIndex   index.php
       #ErrorDocument   404  /404.html
       ErrorLog         /var/log/httpd/mywordpress.err.log
       CustomLog        /var/log/httpd/mywordpress.acc.log combined
</VirtualHost>

重启httpd服务,使配置生效

systemctl restart httpd

建库授权

CREATE DATABASE `wpdb` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
create user 'wpuser'@'localhost' IDENTIFIED BY 'wpuser123';
grant all privileges on wpdb.* to 'wpuser'@'localhost';
flush privileges;

绑定域名到指定IP

echo '192.168.88.2  www.mywordpress.com' >> /etc/hosts

通过浏览器访问,并配置博客

http://www.mywordpress.com/

FAQ

关闭自动更新

//wp-config.php
define('AUTOMATIC_UPDATER_DISABLED',true);

重定向次数过多

# 修改
vim wp-config.php
$_SERVER['HTTPS'] = 'on';
define('FORCE_SSL_LOGIN', true);
define('FORCE_SSL_ADMIN', true);

评论 (0)

取消
只有登录/注册用户才可评论