centos7、mysql5.7、php7.1、nginx1.20
1、安装mysql5.7
安装mysql的yum源
rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
安装mysql
yum install mysql-community-server -y
启动mysql
systemctl start mysqld
查看生成的随机密码,并复制
grep password /var/log/mysqld.log
使用密码登录mysql,
mysql -uroot -p'/v&tdimOj1pv'
登录进去后,修改下密码策略,不想设那么复杂的密码,root用户设置123456
set global validate_password_length=6;
set global validate_password_policy=LOW;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
2、安装php
安装php yum源
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
安装php
yum install -y php71w php71w-fpm php71w-cli php71w-common php71w-devel php71w-gd php71w-pdo php71w-mysql php71w-mbstring php71w-bcmath
编辑配置,将启动用户和组都修改为nginx,并保存
vi /etc/php-fpm.d/www.conf
user = nginx
group = nginx
3、安装nginx
yum install nginx
修改配置,红色为新增内容
vi /etc/nginx/nginx.conf
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
location / {
index index.php index.html index.htm;
}
# 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 {
}
location ~ \.php$ {
# 设置监听端口
fastcgi_pass 127.0.0.1:9000;
# 设置nginx的默认首页文件(上面已经设置过了,可以删除)
fastcgi_index index.php;
# 设置脚本文件请求的路径
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# 引入fastcgi的配置文件
include fastcgi_params;
}
}
最后启动php和nginx
systemctl start php-fpm
systemctl start nginx
添加自启动
systemctl enable php-fpm
systemctl enable nginx
wordpress解压,拷贝到/usr/share/nginx/html/wordpress
chown -R nginx /usr/share/nginx/html/wordpress #这个坑,所属用户必须和php一致,有权限都不行,到安装插件会要求连ftp
把目录下wp-config-sample.php修改成wp-config.php,并配置数据库连接信息。
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', '123456');
/** MySQL hostname */
define('DB_HOST', '127.0.0.1');
然后http://ip/wordpress访问进行安装。
完!