腾讯云对大学生有1元云主机的优惠项目,就买了一个,开启了我的云端之旅。搭建博客是技术宅的入门必备技能。所以就从最简单的 wordpress 开始练手吧。整个过程顺利的话只需要十来分钟。
首先了解一下什么是LNMP:
LNMP = Linux + Nginx + MySQL+ PHP
如果对安装不太了解:
#yum install nginx #配置文件处于/etc/nginx
#systemctl start nginx #启动nginx
#systemctl enable nginx.service # 设置为开机启动
测试:123.206.57.252(你的公网IP) 打开公网 IP 可看到 nginx 的页面。
#rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
#yum repolist enabled | grep “mysql.-community.”
#yum -y install mysql-community-server #安装社区版,快可3分钟,慢或40分钟
#systemctl start mysqld # 启动mysql
#mysql_secure_installation # mysql安全安装,root密码初始为空,自己设置
#mysql -uroot -p
mysql>create database wordpress; #创建wordpress数据库
mysql>use wordpress;
mysql>quit #或者exit
#yum install php-fpm php-mysql
#systemctl start php-fpm # 启动php-fpm
#systemctl enable php-fpm # 设置开机启动
#mkdir /usr/www
#chown -R apache:apache /usr/www
winscp菜单-选项-编辑器-默认编码,选择 UTF-8
设置好ssh:高级-ssh-验证-密钥文件
密码是云主机的密码,修改密码要先关机
打开/etc/nginx下的nginx.conf,其中server部分修改如下:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name ffflipped.cn;
root /usr/www;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.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
#systemctl reload nginx
在/usr/www 目录中创建 index.php
测试:123.206.57.252 或者解析好的域名http://ffflipped.cn 可以看到 hello world !
下载并解压好wordpress安装包,用winscp将/wordpress
下的文件夹和文件全部上传到/usr/www/
目录下。
修改wp-config-sample.php
的 MySQL 数据库信息,里面 MySQL 主机就填 localhost,而不是公网IP之类的。
保存后访问 123.206.57.252 填写站点信息,接近成功了!
但是会发现写博时不能上传图片,后台不能安装插件和主题,这时候就是权限问题。
wp-config.php
文件最后加上下面这句:
define(‘FS_METHOD’, “direct”);
再去执行命令
#chmod 777 /usr/www -R #
这里的-R
是递归子目录、文件
#systemctl reload nginx
相关推荐
【腾讯云的1001种玩法】云服务器搭建Python环境 【腾讯云的1001种玩法】搭建属于自己的Minecraft服务器
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。