本文教大家如何在CentOS7服务器上安装Lamp + wordpress实现个人博客网站
一、服务器选择:
服务器选择有很多,阿里云、腾讯云、私人电脑均可以,国内云服务器比较麻烦,需要备案,所以这边,我选择海外的服务器Vultr,免备案,按小时收费,不用随时关,支持微信支付宝。
二、安装Apache
1、安装Apache
yum -y install httpd
2、启动Apache并设置开机自启动
systemctl start httpd.service
systemctl enable httpd.service
三、安装MySQL 5.7
1、安装数据库
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
2、启动数据库
systemctl start mysqld.service
3、获取数据库初始密码:
grep "password" /var/log/mysqld.log
4、使用初始密码登录数据库
mysql -uroot -p
5、重置密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
6、开启远程连接(此步骤可以不用做)
grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;
7、新建Wordpress数据库和用户
CREATE DATABASE wordpressdb;
CREATE USER wordpressuser@localhost IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON wordpressdb.* TO wordpressuser@localhost;
FLUSH PRIVILEGES;
exit
8、重启数据库
systemctl restart mysqld.service
四、安装PHP 7.2
1、卸载默认的php
yum -y remove php* php-common
2、安装PHP 7.2
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install -y php72w
yum install -y php72w php72w-opcache php72w-xml php72w-mcrypt php72w-gd php72w-devel php72w-mysql php72w-intl php72w-mbstring
systemctl start php-fpm.service
systemctl enable php-fpm.service
五、安装WordPress
1、下载wordpress
mkdir wp
cd wp
yum -y install wget unzip net-tools
wget http://wordpress.org/latest.zip
2、解压并将文件拷贝到/var/www/wordpress目录下
mkdir /var/www/wordpress
unzip -q latest.zip
cp -rf wordpress/* /var/www/wordpress/
3、设置文件夹权限
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
chmod -R 755 /var/www/wordpress/wp-content/uploads
4、修改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’);
5、配置Apache
vi /etc/httpd/conf.d/mywordpress.conf
打开文件后填入如下内容:
<VirtualHost *:80>
serverName localhost
DocumentRoot /var/www/wordpress
</VirtualHost>
6、重启相关服务
systemctl restart httpd.service
六、WordPress网站配置
好了,现在你的wordpress已经配置完毕,你可以通过域名来继续你的wordpress安装登录 htttp://x.x.x.x/访问你的博客(x.x.x.x为你的服务器公网IP),按照自己的喜好进行相关的设置。
最新评论