本文教大家如何在CentOS7服务器上安装Lamp + wordpress实现个人博客网站功能
一、购买服务器
- 海外服务器的选择
海外服务器有个优势,就是免备案,这边推荐Vultr服务器,该服务器支持支付宝或微信支付,并且可以随时销毁更换实例,也就是说ip可以随便换,价格按小时扣,不用担心会多扣
Vultr服务器点击购买 - 国内服务器的选择
这边推荐阿里云或者腾讯云,安全可靠(需要备案,多等几天就是);
腾讯云服务器点击购买
阿里云服务器点击购买
国内服务器购买完成后,在控制台会收到服务器下信息,包括登陆账号密码。
二、安装nginx
- 安装Apache服务器
yum -y install httpd
- 启动httpd并设置开机自启动
systemctl start httpd.service
systemctl enable httpd.service
三、安装MariaDB
- 安装MariaDB并设置开机自启动
yum -y install mariadb-server mariadb
systemctl start mariadb.service
systemctl enable mariadb.service
- 设置MariaDB
mysql_secure_installation
具体有以下几个选项,可以根据各自情况进行配置(建议全部选Y)
Enter current password for root (enter for none):(输入原始root密码,若无则按enter)
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] (按Y设置root密码)
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
Remove anonymous users? [Y/n] (按Y移除匿名用户)
... Success!
Disallow root login remotely? [Y/n] (按Y禁止远程root登陆,一般root都设定为只允许本地登陆)
... skipping.
Remove test database and access to it? [Y/n] (按Y删除测试数据库)
Reload privilege tables now? [Y/n] (按Y重新载入)
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
四、安装PHP
- 安装PHP
yum install php -y
yum install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel -y
五、安装Wordpress
- 新建文件夹wp
mkdir wp
cd wp
yum -y install wget unzip net-tools
wget http://wordpress.org/latest.zip
- 创建wordpress安装目录
mkdir /var/www/wordpress
- 解压并将文件拷贝到/var/www/wordpress目录下
unzip -q latest.zip
cp -rf wordpress/* /var/www/wordpress/
六、配置Wordpress
- 登陆MariaDB为WordPress建立数据库及用户
mysql -u root -p
- 新建数据库wordpressdb,用户为wordpressuser,密码为123456
CREATE DATABASE wordpressdb;
CREATE USER wordpressuser@localhost IDENTIFIED BY '123456';
- 更改用户权限,保存并退出
GRANT ALL PRIVILEGES ON wordpressdb.* TO wordpressuser@localhost;
FLUSH PRIVILEGES;
exit
- 重启数据库
systemctl restart mariadb.service
- 修改文件夹权限
chown -R apache:apache /var/www/wordpress/
chmod -R 755 /var/www/wordpress/
mkdir -p /var/www/wordpress/wp-content/uploads
chown -R :apache /var/www/wordpress/wp-content/uploads
- 修改wordpress配置
cd /var/www/wordpress
cp wp-config-sample.php wp-config.php
vi wp-config.php
打开文件后,按i键或insert键进入编辑模式,将其修改为以下格式(其中wordpressdb为数据库名称,wordpressuser为数据库用户名,123456为数据库密码)
// * MySQL settings - You can get this info from your web host * //
/* The name of the database for WordPress /
define(‘DB_NAME’, ‘wordpressdb’);
/* mysql database username /
define(‘DB_USER’, ‘wordpressuser’);
/* MySQL database password /
define(‘DB_PASSWORD’, ‘123456’);
- 重启相关服务
systemctl restart httpd.service
systemctl restart mariadb.service
7、Wordperss个人配置
好了,现在你的wordpress已经配置完毕,你可以通过域名来继续你的wordpress安装登录 htttp://x.x.x.x/访问你的博客(x.x.x.x为你的服务器公网IP),按照自己的喜好进行相关的设置。