Home >System Tutorial >LINUX >How to configure wordpress in centos7 based on lnmp

How to configure wordpress in centos7 based on lnmp

王林
王林forward
2024-04-10 17:28:081196browse

How to configure wordpress in centos7 based on lnmp

1.下载安装WordPress
wget http://wordpress.org/latest.zip     #下载WordPress安装文件

unzip latest.zip    #解压安装文件

由于我的主机装有discuz  所以会有点问题  先把discuz的文件全删了研究下WordPress  后面再研究两个共存的事

rm -rf var/www/html    #删除

mkdir -p /var/www/html    #创建网站根目录

cp -rf wordpress/* /var/www/html/      #复制安装文件到网站根目录

chmod -R 777 /var/www/html     #更改根目录权限
2.数据库创建WordPress数据库
mysql -u root -p

>create database wordpress;

>grant all privileges on wordpress.* to wordpress@'localhost' identified by 'password';

>flush privileges;

>exit
3.修改WordPress配置文件
cd /var/www/html      #进入目录

cp wp-config-sample.php wp-config.php     #复制一个文件

vi wp-config.php     #编辑配置文件

#修改如下内容

/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');            #数据库名称

/** MySQL database username */
define('DB_USER', '#你的用户');                        #数据库用户

/** MySQL database password */
define('DB_PASSWORD', '#你的密码');             #数据库密码

/** MySQL hostname */
define('DB_HOST', 'localhost');            #主机  可改可不改

systemctl restart nginx

systemctl restart mariadb          #重启服务

在浏览器中打开 192.168.100.13/wordpress   登陆wordpress界面

 

4.我打开WordPress界面的时候出现了404代码   修改nginx文件
vi /etc/nginx/nginx.conf

#在server{   }里添加以下内容

 if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

systemctl restart nginx

systemctl restart mariadb          #重启服务

打开网址   192.168.100.13/wordpress  登陆开始配置WordPress

The above is the detailed content of How to configure wordpress in centos7 based on lnmp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:linuxprobe.com. If there is any infringement, please contact admin@php.cn delete