服务器内存小导致mysql服务停止解决方案+wordpress搭建
wordpress搭建
- 域名现在要实名
- 买了国外服务器后(可以使用默认的dns服务器,一般都能解析),然后修改
dns 解析设置,设置为服务器的ip 好像修改dns服务器要等几个小时才能成功dig yourdomain或者nslookup youdomain查看是否域名解析到ip是否成功
lnmp环境搭建
- 安装
nginx mariadb php-fpm… nginx配置文件修改(写入内容是抄的):vim /etc/nginx/conf.d/web.conf
server_name:自己的域名root:表示nginx站点根目录1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29#======================== WEB options ============================
server {
listen 80;
server_name yourdomain;
root /var/wordpress;
index index.php index.html;
charset utf-8;
#======================== Pseudo static ==========================
location / {
if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; }
if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; }
if (!-f $request_filename){ rewrite (.*) /index.php; }
}
#======================== PHP options ============================
location ~ \.php {
root /var/wordpress;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#======================== Error page =============================
error_page 400 403 404 /40x.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
- 配置
php服务vim /etc/php-fpm.d/www.conf
nginx用户使用php-fpm服务,权限设置1
2user = nginx
group = nginx
创建一个数据库给
wordpress使用mysqlcreate database xxx- 创建该数据库的账户密码
grant all privileges on wpdb.* to '账户1'@'localhost' identified by '密码1';
账户名:账户1,密码:密码1 - 看看已有的数据库
show databases;
开启所有服务
systemctl enable mariadbsystemctl start mariadb-
systemctl enable php-fpmsystemctl start php-fpm systemctl enable nginxsystemctl start nginx
下载
wordpress到/var/wordpress(站点根目录)
wget下载解压打包看别的blog- 修改
/var/wordpress的所属组和用户 chmod 755 -R /var/wordpresschown nginx:nginx -R wordpresswordpress的权限给nginx避免一些权限报错
- 域名访问来安装
wordpress
关于低配便宜辣鸡服务器,mariadb(mysql)服务自动终止原因
vim /var/log/mariadb/mariadb.log查看报错
1 | |
原因:
1 | |
默认是性能模式且不明显,sql启动时会分配它需要的RAM,默认会使用400MB,大服务器上这点不算什么.但是在小虚拟机上很重要好像我的Plugins(插件)服务也因为内存的原因不能用修改配置文件
添加:vim /etc/my.cnf,在[mysqld]项下.performance_schema = off
当运行环境正常和域名解析正确时,如果还是访问不了,说明服务器的防火墙关闭了80端口
- 关闭防火墙
- 开启
80端口1
2firewall-cmd --zone=public --add-port=80/tcp --permanent
systemctl restart firewalld
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!