首先,向仍在与病毒抗争的白衣天使们致敬!

其次,向这一次的阿里巴巴道谢:戳此点击(每天8点)可免费领取一台云服务器

简单来说,先用支付宝扫码注册并登录后,用支付宝完成实名认证,再点击完成学生认证(学信网3秒即可),然后答题,

百度到达60分即可。

注意,个人习惯为CentOS版本的服务器,即操作系统为Linux,所以之后的所有都是由Linux下的命令行完成,简单的玩服务器的可选择 Windows Server,教程:请点击此出门

撸完了服务器,开始做基础修改:找到 云服务管理,在左手边的实例与镜像中找到实例,然后开始修改:

在这边的“更多”中修改实例状态、登录密码等。修改完后便可点击“远程连接”,用户名默认是“root”,登录密码便是你设置的。

登录完成后默认为root权限,通过这里学习安装前期手动搭建 LNMP 环境 。然后注意安装nginx时很简单,但是安装nginx后可能输入ip地址后无法显示,这是①防火墙这里的问题,具体解决方案:

fuser -k 80/tcp 

 参考此 来关闭80端口(即http端口)。然后关闭防火墙:

systemctl stop firewalld.service
systemctl disable firewalld.service

在输入

firewall-cmd –state

进行显示防火墙具体信息时,报错:

usage: see firewall-cmd man page

firewall-cmd: error: unrecognized arguments: –state

而将 iptables重新启动时又报错:

Redirecting to /bin/systemctl restart  iptables.service

解决方案:systemctl start iptables即可解决上述问题

而核心的问题仍未解决;

②阿里云自身规则配置:点此参考修改网络配置:在左边找到网络与安全下的“安全组”,点击“配置规则”进行修改:

即完成nginx配置。

修改配置文件后nginx出现错误:可以通过查看日志(nginx访问日志的默认路径:/var/log/nginx)来确定,比如:端口没开,添加规则,无用,通过 netstat -tunlp|grep 查看哪个端口被哪个程序占用

PHP-FPM安装:

在用yum install 安装完后,遇到:start php-fpm时显示:

Failed to start php-fpm.service: Unit not found.

参考解决:点此解决此问题,而找到路径的方法:

查找进程:ps -ef |grep + 进程名

查找进程名:find / -name php

确定路径为:/usr/lib/systemd/system/

当然,可能还是不太清楚,这时候:参考此

find / -name php* 用于查找php相关文件

若实在不清楚问题在哪,全部删除 yum remove php-common 再重新安装也行吧。

最后结果:输入ip后:

数据库设计:

  • 创建wordpress数据库

MariaDB [(none)]> CREATE DATABASE wordpress;

返回结果Query OK, 1 row affected (0.000 sec)

  • 设置用户名user,密码123456

MariaDB [(none)]> CREATE USER 'user'@'localhost' IDENTIFIED BY '123456';

返回结果Query OK, 0 rows affected (0.039 sec)

  • 赋予权限

MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress.* TO 'user'@'localhost' IDENTIFIED BY '123456';

返回结果Query OK, 0 rows affected (0.010 sec)

  • 重启使所有设置生效

MariaDB [(none)]> FLUSH PRIVILEGES;

返回结果Query OK, 0 rows affected (0.000 sec)

  • 退出

MariaDB [(none)]> \q

返回结果Bye

  • 设置root对应密码123456

MariaDB [(none)]> ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD('123456');

返回结果Query OK, 0 rows affected (0.001 sec)

  • 显示已有数据库

show databases;

  • 删除数据库

drop database wordpress;

然后就是重头戏:配置wordpress

在访问wordpress官网时又遇到了429 报错

解决办法:上传其他网站的资源:

cd /usr/share/nginx/html/
yum install -y unzip zip
wget https://zouaw.com/wp/wordpress-5.3-zh_CN.zip
unzip wordpress-5.3-zh_CN.zip

目的是安装zip的解压软件后到 nginx配置文件对应的目录下进行解压。

然后通过ip/wordpress进行访问

正常情况下会进入配置页面

安装完成后网站即可访问。

可能会遇到更新WordPress的问题:

参考1来获取最新的中文版,参考2来进行更新。

缺陷:访问自己的博客时需要ip+WordPress,强迫症难受,试图直接ip就可以访问网站

解决方案:修改vim /etc/nginx/nginx.conf (nginx的配置文件),修改根目录,即root,

注意:当遇到修改了配置文件中的路径和端口后,仍然会在原文件夹下查找,无法跳转到指定根目录

解决思路:第一步:修改防火墙允许你修改的端口,即开放该端口,第二步:ip+端口看看能不能访问

点击此参考教程。nginx是只有80端口才可以直接ip来访问的。

修改端口后是需要ip+端口才能访问,否则是报404的

具体的所有修改内容为下:

#修改用户为root
user  root;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    keepalive_timeout  65;
    #gzip  on;
###开始修改###
server {
 #端口号修改
 listen       80;
 #核心:路径修改
 root   /www/wordpress;
 server_name  localhost;
 #charset koi8-r;
 #access_log  /var/log/nginx/log/host.access.log  main;

 location / {
#不需要       root   /www/wordpress;
       index index.php index.html index.htm;
 }
 #error_page  404              /404.html;
 #redirect server error pages to the static page /50x.html
 error_page   500 502 503 504  /50x.html;
 location = /50x.html {
 root   /usr/share/nginx/html;
#不需要 root   /www/wordpress;
 }

 #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
# location ~ .php$ {
location ~ .*\.php {
   include        fastcgi_params;  
  #路径修改
   root   /www/wordpress;
   fastcgi_pass   127.0.0.1:9000;
   fastcgi_index  index.php;
   fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
#   include        fastcgi_params;
 }

        access_log  /www/access.log;

        error_log   /www/error.log;

}
    include /etc/nginx/conf.d/*.conf;
}

另外,找到一个好用的软件:xshell用于本地数据和服务器的数据交互——参考教程,通过安装 yum install  lrzsz 来进行数据上传和下载,注意下载前最好是先进入下载的文件对应的文件夹中,不然需要指定绝对路径才行。

最后,这是新弄好的博客,欢迎大家前来参观:姗杰网

GitHub 加速计划 / li / linux-dash
8
1
下载
A beautiful web dashboard for Linux
最近提交(Master分支:6 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐