centos7 lnmp wordpress
一、基础环境配置
Centos 7.8
IP:10.78.246.71
关闭selinux
二、安装nginx
配置Nginx源
http://nginx.org/en/linux_packages.html#RHEL-CentOS
vi /etc/yum.repos.d/nginx.repo [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true [nginx-mainline] name=nginx mainline repo baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/ gpgcheck=1 enabled=0 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true
安装nginx
yum install -y nginx
编辑备份并编辑Nginx配置文件
mkdir -p /opt/nginx/htm
mv /usr/share/nginx/html/* /opt/nginx/html/
cd /etc/nginx/conf.d/ cp default.conf default.conf.bak vi default.conf server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; location / { root /opt/nginx/html; index index.php index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /opt/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
启动Nginx并设置开机启动
systemctl restart nginx systemctl enable nginx
配置防火墙
firewall-cmd --permanent --add-port=80/tcp firewall-cmd --reload
验证nginx
三、安装MariaDB
yum install mariadb-server mariadb -y systemctl restart mariadb systemctl enable mariadb
启动MariaDB安全配置向导
mysql_secure_installation
创建wordpress数据库及用户
mysql -uroot -p //创建数据库 create database wordpress; //创建wpdb用户,密码为123456 CREATE USER 'wpdb'@'localhost' IDENTIFIED BY '123456'; //配置wpdb用户wordpress数据库的所有权限 GRANT ALL PRIVILEGES ON wordpress.* TO 'wpdb'@'localhost' IDENTIFIED BY '123456'; //使配置生效 FLUSH PRIVILEGES; //推出mariadb exit
四、安装PHP
添加php软件源
rpm -Uvh https://mirrors.cloud.tencent.com/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装PHP7.2所需的包
yum -y install mod_php72w.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-mysqlnd php72w-fpm.x86_64
开启PHP-FPM
systemctl start php-fpm systemctl enable php-fpm
测试PHP
cd /opt/nginx/html/ vi info.php <?php phpinfo(); ?>
五、安装Wordpress
cd /opt/nginx/html/
下载wordpress压缩包
解压wordpress压缩包
yum -y install unzip unzip wordpress-5.4.2-zh_CN.zip
修改wordpress配置文件
cd /opt/nginx/html/wordpress/ cp wp-config-sample.php wp-config.php
vi wp-config.php
安装wordpress
http://10.78.246.71/wordpress