wordPress 小白建站,教你亲手搭建一个自己的个人网站
wordPress 搭建
前期准备
- 服务器
- 域名
- linux系统
- nginx
- mysql
- php
- wordpress
1. 服务器
搭建个人网站的前提是你需要购买一个自己的服务器。购买服务器这里推荐阿里云或者腾讯云都可以。自己使用的话配置 1核2G就够用 价格也合适。
阿里云网站
腾讯云
2. 域名
可以在阿里云购买一个.com的域名,一年的费用大概是55块钱;或者也可以购买.top域名,一年几块钱。
域名注册购买以后需要做实名认证。实名认证过后2到3天。继续做域名备案。这样就可以通过你的域名访问你的个人网站了。
阿里云域名注册地址
3. nginx
在你的服务器上下载安装nginx。可以通过yum命令。yum install nginx -y
下载好以后,等安装完wordpress再改配置文件。
4.MySQL
在服务器上安装mysql
1.wget -i -c http://dev.mysql.com/get/mysql57-community- release-el7-10.noarch.rpm
2.yum install mysql57-community-release-el7-10.noarch.rpm -y
3.yum install mysql-community-server -y
安装好以后,启动mysql服务service mysqld restart
查看你的mysql默认密码grep "password" /var/log/mysqld.log
登录mysql,并修改密码mysql -uroot -p 输入上一步看到的密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
5. php
在服务器上安装phpyum install php-fpm php-mysql -y
启动php-fpm进程service php-fpm start
6. wordPress
下载wordPressyum install wordpress -y
登录mysql并创建数据库
mysql -uroot -p
CREATE DATABASE wordpress;
exit;
将数据库信息写入wordPress配置文件
cd /etc/wordpress/
vim wp-config.php
在文件中改写这几个值
define( 'DB_NAME', '创建的数据库名' );
/** MySQL database username */
define( 'DB_USER', 'root' );
/** MySQL database password */
define( 'DB_PASSWORD', '你前面设置的数据库密码' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
修改nginx配置文件
cd ../../nginx/conf 找到你的nginx安装目录
vim nginx.conf
将配置文件按如下配置
server {
listen 80;
server_name localhost;
root /usr/share/wordpress;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php index.php;
}
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;
}
启动nginx服务
cd nginx/sbin/
./nginx -c /usr/local/nginx/conf/nginx.conf
终 :大功告成
这个时候你就能通过网页浏览你的wordpress后台了http://《你的ip或者域名》/wp-admin/install.php
如果安装过程有什么问题,欢迎留言沟通。
上一篇: lombok使用及常用注解
下一篇: 自制PHP框架之设计模式