温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

CentOS 搭建WordPress个人网站

发布时间:2020-07-16 22:23:05 来源:网络 阅读:1275 作者:84368257 栏目:建站服务器

使用 Yum 安装必要软件
yum install nginx php php-fpm php-mysql mysql-server -y

将各软件设置为开机启动
chkconfig nginx on
chkconfig mysqld on
chkconfig php-fpm on

配置 Nginx
vim /etc/nginx/conf.d/default.conf

按字母“I”键或 “Insert” 键切换至编辑模式,将已有内容全部清除,复制并粘贴以下内容到 default.conf文件。
server {listen 80;root /usr/share/nginx/html;server_name localhost;
#charset koi8-r;#access_log /var/log/nginx/log/host.access.log main;
location / {
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;

}
#pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;

}
} index index.php index.html index.htm;

root /usr/share/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;

启动 Nginx
service nginx start

配置 MySQL
启动 MySQL 服务器
service mysqld start

设置 MySQL 服务器 root 用户的密码,本教程设置为 “123456”,后续步骤中需要用到此用户名和密码
/usr/bin/mysqladmin -u root password “123456”

配置 PHP
启动 PHP-FPM 服务
service php-fpm start

打开/etc/php.ini文件
vim /etc/php.ini
进入后直接输入以下内容,回车定位到 “session.save_path” 的位置:
session.save_path = “/var/lib/php/session”

更改/var/lib/php/session目录下所有文件的属组都改成 nginx 和 nginx
chown -R nginx:nginx /var/lib/php/session

请使用以下命令在 Web 目录下创建index.php文件
vim /usr/share/nginx/html/index.php

Test Page“;
echo “Hello World!”;
?>

先删除网站根目录下的index.html文件
rm /usr/share/nginx/html/index.html

依次下载 WordPress 并解压到当前目录
wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz

tar zxvf wordpress-4.9.4-zh_CN.tar.gz

配置数据库
使用 root 用户登录到 MySQL 服务器
mysql -uroot -p
为 WordPress 创建 MySQL 数据库 “wordpress”
CREATE DATABASE wordpress;
为已创建好的 MySQL 数据库创建一个新用户 “user@localhost
CREATE USER user@localhost;
并为此用户设置密码“wordpresspassword”
SET PASSWORD FOR user@localhost=PASSWORD(“wordpresspassword”);
为创建的用户开通数据库 “wordpress” 的完全访问权限。
GRANT ALL PRIVILEGES ON wordpress.* TO user@localhost IDENTIFIED BY ‘wordpresspassword’;
使用以下命令使所有配置生效
FLUSH PRIVILEGES;
配置完成,退出 MySQL
exit

写入数据库信息
创建新配置文件
cd wordpress/
cp wp-config-sample.php wp-config.php

打开并编辑新创建的配置文件
vim wp-config.php
// MySQL settings – You can get this info from your web host //
/* The name of the database for WordPress /
define(‘DB_NAME’, ‘wordpress’);

/* MySQL database username /
define(‘DB_USER’, ‘user’);

/* MySQL database password /
define(‘DB_PASSWORD’, ‘wordpresspassword’);

/* MySQL hostname /
define(‘DB_HOST’, ‘localhost’);

安装 WordPress
mv * /usr/share/nginx/html/

在 Web 浏览器地址栏输入 WordPress 站点的 IP 地址

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI