阿里云建站

在阿里云搭建WordPress个人博客网站
有很多人想要属于自己的博客,奈何用托管平台博客不爽,或者自己时间、技术有限
那么小白如何快速的搭建一个属于自己的博客呢?
今天就带来WordPress博客系统的搭建,帮助大家快速建站
先来简单的介绍一下WordPress:WordPress是使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL数据库的服务器上架设属于自己的网站
准备的资源:一台阿里云ECS服务器(系统Centos-6.8),WordPress-4.8.1-zh_CN压缩包,X-shell远程登录软件,Winscp远程传输软件
-
登陆服务器,修改主机名后,重启
vim /etc/sysconfig/network
init 6
-
yum安装WordPress所需环境
[root@yanwei wordpress]# yum -y install httpd mysql mysql-server php php-mysql php-gd php-xml Installed:
httpd.x86_64 0:2.2.15-60.el6.centos.5 mysql.x86_64 0:5.1.73-8.el6_8 mysql-server.x86_64 0:5.1.73-8.el6_8 php.x86_64 0:5.3.3-49.el6
php-gd.x86_64 0:5.3.3-49.el6 php-mysql.x86_64 0:5.3.3-49.el6 php-xml.x86_64 0:5.3.3-49.el6
......
Complete!
-
启动http,mysql
[root@yanwei wordpress]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 47.94.235.135 for ServerName
[ OK ]
[root@yanwei wordpress]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h yanwei password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
-
将http,mysql服务设置为开机启动
[root@yanwei wordpress]# chkconfig httpd on
[root@yanwei wordpress]# chkconfig mysqld on
-
对mysql进行初始化配置
[root@yanwei wordpress]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
默认没有密码
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
... skipping.
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
-
登录mysql,创建数据库wordpress
[root@yanwei wordpress]# mysql -u root -p 密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.1.73 Source distribution
mysql> create database wordpress;
Query OK, 1 row affected (0.00 sec)
-
解压wordpress-4.8.1
[root@yanwei wordpress]# tar xf wordpress-4.8.1-zh_CN.tar.gz
[root@yanwei wordpress]# ls
wordpress wordpress-4.8.1.tar.gz
[root@yanwei wordpress]# cd wordpress
[root@yanwei wordpress]# ls
index.php wp-activate.php wp-comments-post.php wp-cron.php wp-load.php wp-settings.php xmlrpc.php
license.txt wp-admin wp-config-sample.php wp-includes wp-login.php wp-signup.php
readme.html wp-blog-header.php wp-content wp-links-opml.php wp-mail.php wp-trackback.php
-
复制当前文件夹下所有的文件拷贝到 /var/www/html下
[root@yanwei wordpress]# cp -r wordpress/* /var/www/html/ 将wordpress下所有文件拷贝到 /var/www/html下
[root@yanwei wordpress]# cd /var/www/html/
[root@yanwei html]# ls
index.php wp-activate.php wp-comments-post.php wp-cron.php wp-load.php wp-settings.php xmlrpc.php
license.txt wp-admin wp-config-sample.php wp-includes wp-login.php wp-signup.php
readme.html wp-blog-header.php wp-content wp-links-opml.php wp-mail.php wp-trackback.php
-
拷贝配置文件
[root@yanwei html]# cp wp-config-sample.php wp-conig.php 复制配置文件
-
修改wp-config.php配置文件,保存退出
-
打开浏览器,输入公网地址,即可进入页面,填写信息完毕后,点击in
-
stall WordPress,进行安装
-
安装完成后,可看到仪表盘界面,WordPress博客就这么搭建起来了
vim /etc/sysconfig/network init 6
[root@yanwei wordpress]# yum -y install httpd mysql mysql-server php php-mysql php-gd php-xml Installed: httpd.x86_64 0:2.2.15-60.el6.centos.5 mysql.x86_64 0:5.1.73-8.el6_8 mysql-server.x86_64 0:5.1.73-8.el6_8 php.x86_64 0:5.3.3-49.el6 php-gd.x86_64 0:5.3.3-49.el6 php-mysql.x86_64 0:5.3.3-49.el6 php-xml.x86_64 0:5.3.3-49.el6 ...... Complete!
[root@yanwei wordpress]# service httpd start Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 47.94.235.135 for ServerName [ OK ] [root@yanwei wordpress]# service mysqld start Initializing MySQL database: Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h yanwei password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! [ OK ] Starting mysqld: [ OK ]
将http,mysql服务设置为开机启动
[root@yanwei wordpress]# chkconfig httpd on [root@yanwei wordpress]# chkconfig mysqld on
[root@yanwei wordpress]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) Enter current password for root (enter for none): ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 默认没有密码 Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] n ... skipping. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL!
[root@yanwei wordpress]# mysql -u root -p 密码 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 14 Server version: 5.1.73 Source distribution mysql> create database wordpress; Query OK, 1 row affected (0.00 sec)
[root@yanwei wordpress]# tar xf wordpress-4.8.1-zh_CN.tar.gz [root@yanwei wordpress]# ls wordpress wordpress-4.8.1.tar.gz [root@yanwei wordpress]# cd wordpress [root@yanwei wordpress]# ls index.php wp-activate.php wp-comments-post.php wp-cron.php wp-load.php wp-settings.php xmlrpc.php license.txt wp-admin wp-config-sample.php wp-includes wp-login.php wp-signup.php readme.html wp-blog-header.php wp-content wp-links-opml.php wp-mail.php wp-trackback.php
[root@yanwei wordpress]# cp -r wordpress/* /var/www/html/ 将wordpress下所有文件拷贝到 /var/www/html下 [root@yanwei wordpress]# cd /var/www/html/ [root@yanwei html]# ls index.php wp-activate.php wp-comments-post.php wp-cron.php wp-load.php wp-settings.php xmlrpc.php license.txt wp-admin wp-config-sample.php wp-includes wp-login.php wp-signup.php readme.html wp-blog-header.php wp-content wp-links-opml.php wp-mail.php wp-trackback.php
[root@yanwei html]# cp wp-config-sample.php wp-conig.php 复制配置文件



在安装WordPress的过程中,遇到的问题和解决方法:
WordPress更新和安装主题时,需要提供FTP账号登录验证,很是麻烦,解决办法如下:
修改wp-config.php文件,添加如下内容,保存退出,刷新页面,问题解决
define("FS_CHMOD_DIR", 0777);
define("FS_METHOD", "direct");
define("FS_CHMOD_FILE", 0777);
define("FS_CHMOD_DIR", 0777); define("FS_METHOD", "direct"); define("FS_CHMOD_FILE", 0777);