邢栋博客

邢栋博客,Action博客,记录工作和生活中的点点滴滴

centos7 执行启动邮件服务报错-systemctl start postfix


错误信息如下

Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details.


解决办法

修改 /etc/postfix/main.cf的设置

inet_protocols = ipv4
inet_interfaces = all
最完美 ThinkPHP(tp) 的 Nginx 配置文件

===系统===
LSB Version:    :....(太长了)
Distributor ID: CentOS
Description:    CentOS Linux release 8.2.2004 (Core) 
Release:        8.2.2004
Codename:       Core


===使用官网给的没有生效===

location / { // …..省略部分代码
   if (!-e $request_filename) {
    rewrite  ^(.*)$  /index.php?s=/$1  last;
    }
}

===于是===

server {
    listen       80;
    server_name  mydomain.com;
    access_log /data/logs/access_nginx.log combined;
    root /data/www/test_sdk/public;
    index  index.html index.htm index.php;    
    location / {
        try_files $uri @rewrite;
    }
    
    location /nginx_status {
      stub_status on;
      access_log off;
      allow 127.0.0.1;
      deny all;
    }

    location @rewrite {
        set $static 0;
        if  ($uri ~ \.(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css\.map|min\.map)$) {
            set $static 1;
        }
        if ($static = 0) {
            rewrite ^/index.php(.*)$ /index.php?s=/$1 last;
        }
    }
    location ~ \.php/ {
       if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { }
       #fastcgi_pass remote_php_ip:9000;
       fastcgi_pass unix:/dev/shm/php-cgi.sock;
       include fastcgi_params;
       fastcgi_param SCRIPT_NAME     $1;
       fastcgi_param PATH_INFO       $2;
       fastcgi_param SCRIPT_FILENAME $document_root$1;
    }
    location ~ \.php$ {
        #fastcgi_pass remote_php_ip:9000;
        fastcgi_pass unix:/dev/shm/php-cgi.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
      expires 30d;
      access_log off;
    }
    location ~ .*\.(js|css)?$ {
      expires 7d;
      access_log off;
    }
    location ~ ^/(\.user.ini|\.ht|\.git|\.svn|\.project|LICENSE|README.md) {
      deny all;
    }
}



===参考链接===

https://www.kancloud.cn/manual/thinkphp6_0/1037488

https://www.seasidecrab.com/tp/487.html

http://www.thinkphp.cn/topic/34380.html


centos下openresty+lua入门实践
===安装openresty===

1、安装依赖开发库
yum install pcre-devel openssl-devel gcc curl postgresql-devel

2、下载 + 编译 + 安装


我刚开始先下载的1.19.3.1版本,但是在编译时增加nginx_upstream_check_module模块,一直报错,错误信息如下
./configure: error: the ngx_http_upstream_check_module addon error. 按照 https://github.com/yaoweibin/nginx_upstream_check_module这里的步骤执行还是失败,于是就更换了低版本 1.15.8.2

==下载openresty+解压==
cd ~
wget https://openresty.org/download/openresty-1.15.8.2.tar.gz
tar -zxvf openresty-1.15.8.2.tar.gz

==下载nginx_upstream_check_module模块==
git clone https://github.com/yaoweibin/nginx_upstream_check_module.git
cp -R nginx_upstream_check_module ~/openresty-1.15.8.2/bundle/

==下载ngx_cache_purge模块==
git clone https://github.com/FRiCKLE/ngx_cache_purge.git
cp -R ngx_cache_purge ~/openresty-1.15.8.2/bundle/

==准备工作完成开始编译==
cd openresty-1.15.8.2
./configure --prefix=/opt/openresty \
      --with-pcre  \
      --with-luajit \
      --with-http_realip_module  \
      --with-http_iconv_module \
      --with-http_postgres_module \
      --add-module=./bundle/ngx_cache_purge \
      --add-module=./bundle/nginx_upstream_check_module
make && make install

--with*** 安装一些内置/集成的模块
--with-http_realip_module 取用户真实 ip 模块
-with-pcre Perl 兼容的达式模块
--with-luajit 集成 luajit 模块
--add-module 添加自定义的第三方模块,ngx_cache_purge用于清除指定url的缓存 nginx_upstream_check_module健康检查


3、配置lua环境

3.1 编辑 nginx.conf

vim /opt/openresty/nginx/conf/nginx.conf
在http部分加入以下代码
#lua模块路径,多个之间”;”分隔,其中”;;”表示默认搜索路径,默认到/opt/openresty/下找
lua_package_path "/opt/openresty/lualib/?.lua;;";  #lua 模块
lua_package_cpath "/opt/openresty/lualib/?.so;;";  #c模块
include lua.conf;#引入lua.conf
3.2 编辑lua.conf

vim lua.conf 写入以下代码
server {
    listen       8080;
    server_name  _;

    location /lua {
    default_type 'text/html';
        content_by_lua 'ngx.say("hello world")';
    }

   location /filelua {
        default_type 'text/html';
        lua_code_cache off;#关闭缓存,这样调试时每次修改lua代码不需要reload nginx
        content_by_lua_file conf/lua/test.lua;
   }
}


mkdir lua
cd lua
vim test.lua #写入以下代码
ngx.say("hello world,lua file");

然后重启nginx
/opt/openresty/nginx/sbin -t

/opt/openresty/nginx/sbin -c  /opt/openresty/nginx/conf/nginx.conf
或者
/opt/openresty/nginx/sbin -s reload


3.3 测试

curl 127.0.0.1:8080/lua   ##  hello world
curl 127.0.0.1:8080/filelua  ## hello world,lua file 
[docker-es]-None of the configured nodes are available

问题:

springboot连接我用docker启动的es服务时报错,None of the configured nodes are available


解决方案:

1、先通过http://localhost:9200/查看参数cluster_name 和 springboot里配置的参数cluster_name是否一致,如果不一致,要修改成一致

2、如果通过修改cluster_name参数仍然无法解决,这时候就要看下Spring Data Elasticsearch 依赖 和 Elasticsearch的版本对应关系了

Spring Data Elasticsearch 
Elasticsearch
3.2.x
6.7.2
3.1.x 
6.2.2
3.0.x 
5.5.0
2.1.x
2.4.0
2.0.x 
2.2.0
1.3.x 
1.5.2



SpingBoot修改启动文字图标


1、进入 src/main/resources 目录下,新建banner.txt 文件

2、进入字母转字符串,字母转字符串 ,制作一个你想要的,然后复制到banner.txt文件中即可,再次启动就可以看到了


WX20210420-212031.png

SpringBoot启动失败(Reason: Failed to determine a suitable driver class)


原因:启动时不需要数据源加载,但加载了数据源,数据源获取失败,异常报错,启动失败。


在启动类的@SpringBootApplication加上以下代码


@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class SpringbootEsApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootEsApplication.class, args);
    }

}


docker安装es的中文分词器ik插件


es-ik.png

===两种安装方式===

1、use elasticsearch-plugin to install

docker exec -it elasticsearch /bin/sh
cd bin/
elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.1.1/elasticsearch-analysis-ik-7.1.1.zip

#执行完毕后 
elasticsearch-plugin list #查看
elasticsearch-plugin remove analysis-ik #删除


2、download 插件
docker exec -it elasticsearch /bin/sh
cd plugins && mkdir ik
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.1.1/elasticsearch-analysis-ik-7.1.1.zip
unzip elasticsearch-analysis-ik-7.1.1.zip


======安装完成后重启服务======


====增加分词====

docker exec -it elasticsearch /bin/sh
cd config/analysis-ik/
echo '济南彭于晏' >> main.dic

======安装完成后重启服务======



=====参考链接=====
https://github.com/medcl/elasticsearch-analysis-ik
https://github.com/yeszao/dnmp




优惠券
最新微语