腾讯云安装wordpress环境
Posted 书生学Python
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了腾讯云安装wordpress环境相关的知识,希望对你有一定的参考价值。
腾讯云安装wordpress环境
准备 LNMP 环境或者Apache
LNMP
LNMP是 Linux、nginx、mysql 和 php 的缩写,是 WordPress 博客系统依赖的基础运行环境。我们先来准备 LNMP 环境
安装 Nginx
使用 yum 安装 Nginx:
yum install nginx -y
修改完成后,启动 Nginx:
nginx
将 Nginx 设置为开机自动启动:
chkconfig nginx on
Apache
查看httpd包是否可用:
# yum list | grep httpd
安装Apache
# yum install httpd -y
配置ServerName
# vi /etc/httpd/conf/httpd.conf
如果没有域名,则:ServerName localhost:80
启动httpd并且设置为开机启动
systemctl start httpd.service
systemctl enable httpd.service
chkconfig httpd on
如果启动失败,可能端口被占用,下边是查看端口被占用和kill进程的命令:
[root@VM_112_104_centos html]# lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 23604 root 6u IPv4 54105 0t0 TCP *:http (LISTEN)
nginx 23604 root 7u IPv6 54106 0t0 TCP *:http (LISTEN)
nginx 31869 nginx 6u IPv4 54105 0t0 TCP *:http (LISTEN)
nginx 31869 nginx 7u IPv6 54106 0t0 TCP *:http (LISTEN)
[root@VM_112_104_centos html]# kill -QUIT 23604
[root@VM_112_104_centos html]# kill -QUIT 31869
-bash: kill: (31869) - No such process
[root@VM_112_104_centos html]# lsof -i :80
安装目录介绍
Apache默认将网站的根目录指向/var/www/html 目录
默认的主配置文件是/etc/httpd/conf/httpd.conf
配置存储在的/etc/httpd/conf.d/目录
安装 MySQL
CentOS 7.0中,已经使用MariaDB替代了MySQL数据库.
[root@VM_112_104_centos ~]# yum -y install mariadb mariadb-server
[root@VM_112_104_centos ~]# systemctl start mariadb.service #启动MariaDB
[root@VM_112_104_centos ~]# systemctl stop mariadb.service #停止MariaDB
[root@VM_112_104_centos ~]# systemctl restart mariadb.service #重启MariaDB
[root@VM_112_104_centos ~]# systemctl enable mariadb.service #设置开机启动
[root@VM_112_104_centos ~]# cp /usr/share/mysql/my-huge.cnf /etc/my.cnf #拷贝配置文件(注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)
[root@VM_112_104_centos ~]# mysql_secure_installation #给root设置密码
回车,根据提示输入Y
输入2次密码,回车
根据提示一路输入Y
最后出现:Thanks for using MySQL!
MariaDB密码设置完成,重新启动 MariaDB
[root@VM_112_104_centos ~]# systemctl restart mariadb.service
允许mysql远程访问
mysql默认是不允许远程访问的.
[root@VM_112_104_centos bak]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use scholar;
Database changed
MariaDB [scholar]> grant all privileges on *.* to 'root'@'%' identified by '1234545';
Query OK, 0 rows affected (0.00 sec)
MariaDB [scholar]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [scholar]>
如果有防火墙,需要做如下配置(此配置来自腾讯云文档):
#开放3306
firewall-cmd --permanent --add-port=3306/tcp
systemctl restart firewalld.service
#查看端口是否开放
firewall-cmd --query-port=3306/tcp
#list
firewall-cmd --list-all
安装PHP
yum install php-fpm php-mysql -y
安装之后,启动 PHP-FPM 进程:
service php-fpm start
启动之后,可以使用下面的命令查看 PHP-FPM 进程监听哪个端口
[root@VM_112_104_centos ~]# netstat -nlpt | grep php-fpm
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 27679/php-fpm: mast
把 PHP-FPM 也设置成开机自动启动:
[root@VM_112_104_centos ~]# chkconfig php-fpm on
Note: Forwarding request to 'systemctl enable php-fpm.service'.
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
安装并配置 WordPress
yum install wordpress -y
Copy WordPress文件到/var/www/html,修改文件夹权限:
chown -R apache:apache /var/www/html/
chmod -R 755 /var/www/html/
mkdir -p /var/www/html/wp-content/uploads
chown -R :apache /var/www/html/wp-content/uploads
修改配置文件:
cd /var/www/html
cp wp-config-sample.php wp-config.php
vi wp-config.php
// * 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’);
重启相关服务(以apache为例):
systemctl restart httpd.service
systemctl restart mariadb.service
还有一种安装wordpress的方法:
# wget https://cn.wordpress.org/wordpress-4.5.2-zh_CN.tar.gz
# tar zxvf wordpress-4.5.2-zh_CN.tar.gz
# mv /srv/www/qcloud.zning.net/html/wordpress/* /srv/www/qcloud.zning.net/html
然后访问:
http://IP
就可以安装完毕!
以上是关于腾讯云安装wordpress环境的主要内容,如果未能解决你的问题,请参考以下文章
如何在腾讯云winserver主机上用wordpress搭建个人博客