服务器内存小导致mysql服务停止解决方案+wordpress搭建

it2025-04-21  10

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站点根目录 #======================== 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服务,权限设置 user = nginx group = nginx 创建一个数据库给wordpress使用 mysqlcreate database xxx创建该数据库的账户密码 grant all privileges on wpdb.* to '账户1'@'localhost' identified by '密码1'; 账户名:账户1,密码:密码1看看已有的数据库 show databases; 开启所有服务 systemctl enable mariadb systemctl start mariadbsystemctl enable php-fpm systemctl start php-fpmsystemctl enable nginx systemctl 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查看报错 140521 08:26:40 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 140521 08:26:41 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended mysqld: Out of memory (Needed 128917504 bytes)之类的报错 Fatal error: cannot allocate memory for the buffer pool 无法在内存中分配内存.服务器内存小.

原因:

Well, the issue here is Performance Schema, and not making it obvious. When starting up, it allocates all the RAM it needs. By default, it will use around 400MB of RAM, which isn’t noticible with a database server with 64GB of RAM, but it is quite significant for a small virtual machine. 默认是性能模式且不明显,sql启动时会分配它需要的RAM,默认会使用400MB,大服务器上这点不算什么.但是在小虚拟机上很重要好像我的Plugins(插件)服务也因为内存的原因不能用

修改配置文件vim /etc/my.cnf,在[mysqld]项下.

添加:performance_schema = off

当运行环境正常和域名解析正确时,如果还是访问不了,说明服务器的防火墙关闭了80端口

关闭防火墙开启80端口 firewall-cmd --zone=public --add-port=80/tcp --permanent systemctl restart firewalld
最新回复(0)