博客

  • linux编译安装时常见错误解决办法

    原文链接:linux编译安装时常见错误解决办法 – 小V_chen – 博客园 (cnblogs.com)

    configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
    解决办法如下:
    yum -y install libxslt-devel

    configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
    解决办法如下:
    yum -y install net-snmp-devel

    configure: error: Please reinstall readline – I cannot find readline.h
    解决办法如下:
    yum -y install readline-devel

    configure: error: Cannot find pspell
    解决办法如下:
    yum -y install aspell-devel

    checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
    解决办法如下:
    yum -y install unixODBC-devel

    configure: error: Unable to detect ICU prefix or /usr/bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works.
    解决办法如下:
    yum -y install libicu-devel

    configure: error: utf8mime2text() has new signature, but U8TCANONICAL is missing. This should not happen. Check config.log for additional information.
    解决办法如下:
    yum -y install libc-client-devel

    configure: error: freetype.h not found.
    解决办法如下:
    yum -y install freetype-devel

    configure: error: xpm.h not found.
    解决办法如下:
    yum -y install libXpm-devel

    configure: error: png.h not found.
    解决办法如下:
    yum -y install libpng-devel

    configure: error: vpx_codec.h not found.
    解决办法如下:
    yum -y install libvpx-devel

    configure: error: Cannot find enchant
    解决办法如下:
    yum -y install enchant-devel

    configure: error: Please reinstall the libcurl distribution – easy.h should be in /include/curl/
    解决办法如下:
    yum -y install libcurl-devel

    configure: error: mcrypt.h not found. Please reinstall libmcrypt.
    解决办法如下:
    wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
    tar zxf libmcrypt-2.5.7.tar.gz
    cd libmcrypt-2.5.7
    ./configure
    make && make install

    Cannot find imap
    解决办法如下:
    ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so

    configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing.
    解决办法如下:
    yum -y install libc-client-devel

    Cannot find ldap.h
    解决办法如下:
    yum -y install openldap
    yum -y install openldap-devel

    configure: error: Cannot find ldap libraries in /usr/lib
    解决办法如下:
    cp -frp /usr/lib64/libldap* /usr/lib/

    configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
    解决办法如下:
    yum -y install postgresql-devel

    configure: error: Please reinstall the lib curl distribution
    解决办法如下:
    yum -y install curl-devel

    configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
    解决办法如下:
    yum -y install net-snmp-devel

    configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
    解决办法如下:
    yum -y install libxslt-devel

    checking for BZip2 support… yes checking for BZip2 in default path… not found configure: error: Please reinstall the BZip2 distribution
    解决办法如下:
    yum -y install bzip2-devel

    checking for cURL support… yes checking if we should use cURL for url streams… no checking for cURL in default path… not found configure: error: Please reinstall the libcurl distribution – easy.h should be in/include/curl/
    解决办法如下:
    yum -y install curl-devel

    checking for curl_multi_strerror in -lcurl… yes checking for QDBM support… no checking for GDBM support… no checking for NDBM support… no configure: error: DBA: Could not find necessary header file(s).
    解决办法如下:
    yum -y install db4-devel

    checking for fabsf… yes checking for floorf… yes configure: error: jpeglib.h not found.
    解决办法如下:
    yum -y install libjpeg-devel

    checking for fabsf… yes checking for floorf… yes checking for jpeg_read_header in -ljpeg… yes configure: error: png.h not found.
    解决办法如下:
    yum -y install libpng-devel

    checking for png_write_image in -lpng… yes If configure fails try –with-xpm-dir=

    configure: error: freetype.h not found.
    解决办法如下:
    Reconfigure your PHP with the following option. –with-xpm-dir=/usr

    checking for png_write_image in -lpng… yes configure: error: libXpm.(a|so) not found.
    解决办法如下:
    yum -y install libXpm-devel

    checking for bind_textdomain_codeset in -lc… yes checking for GNU MP support… yes configure: error: Unable to locate gmp.h
    解决办法如下:
    yum -y install gmp-devel

    checking for utf8_mime2text signature… new checking for U8T_DECOMPOSE… configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
    解决办法如下:
    yum -y install libc-client-devel

    checking for LDAP support… yes, shared checking for LDAP Cyrus SASL support… yes configure: error: Cannot find ldap.h
    解决办法如下:
    yum -y install openldap-devel

    checking for mysql_set_character_set in -lmysqlclient… yes checking for mysql_stmt_next_result in -lmysqlclient… no checking for Oracle Database OCI8 support… no checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
    解决办法如下:
    yum -y install unixODBC-devel

    checking for PostgreSQL support for PDO… yes, shared checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
    解决办法如下:
    yum -y install postgresql-devel

    checking for sqlite 3 support for PDO… yes, shared checking for PDO includes… (cached) /usr/local/src/php-5.3.7/ext checking for sqlite3 files in default path… not found configure: error: Please reinstall the sqlite3 distribution
    解决办法如下:
    yum -y install sqlite-devel

    checking for utsname.domainname… yes checking for PSPELL support… yes configure: error: Cannot find pspell
    解决办法如下:
    yum -y install aspell-devel

    checking whether to enable UCD SNMP hack… yes checking for default_store.h… no

    checking for kstat_read in -lkstat… no checking for snmp_parse_oid in -lsnmp… no checking for init_snmp in -lsnmp… no configure: error: SNMP sanity check failed. Please check config.log for more information.
    解决办法如下:
    yum -y install net-snmp-devel

    checking whether to enable XMLWriter support… yes, shared checking for xml2-config path… (cached) /usr/bin/xml2-config checking whether libxml build works… (cached) yes checking for XSL support… yes, shared configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
    解决办法如下:
    yum -y install libxslt-devel

    configure: error: xml2-config not found. Please check your libxml2 installation.
    解决办法如下:
    yum -y install libxml2-devel

    checking for PCRE headers location… configure: error: Could not find pcre.h in /usr
    解决办法如下:
    yum -y install pcre-devel

    configure: error: Cannot find MySQL header files under yes. Note that the MySQL client library is not bundled anymore!
    解决办法如下:
    yum -y install mysql-devel

    checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
    解决办法如下:
    yum -y install unixODBC-devel

    checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
    解决办法如下:
    yum -y install postgresql-devel

    configure: error: Cannot find pspell
    解决办法如下:
    yum -y install pspell-devel

    configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
    解决办法如下:
    yum -y install net-snmp-devel

    configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
    解决办法如下:
    yum -y install libxslt-devel

    configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
    解决办法如下:
    yum -y install net-snmp-devel

    configure: error: Please reinstall readline – I cannot find readline.h
    解决办法如下:
    yum -y install readline-devel

    configure: error: Cannot find pspell
    解决办法如下:
    yum -y install aspell-devel

    checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
    解决办法如下:
    yum -y install unixODBC-devel

    configure: error: Unable to detect ICU prefix or /usr/bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works.
    解决办法如下:
    yum -y install libicu-devel

    configure: error: utf8mime2text() has new signature, but U8TCANONICAL is missing. This should not happen. Check config.log for additional information.
    解决办法如下:
    yum -y install libc-client-devel

    configure: error: freetype.h not found.
    解决办法如下:
    yum -y install freetype-devel

    configure: error: xpm.h not found.
    解决办法如下:
    yum -y install libXpm-devel

    configure: error: png.h not found.
    解决办法如下:
    yum -y install libpng-devel

    configure: error: vpx_codec.h not found.
    解决办法如下:
    yum -y install libvpx-devel

    configure: error: Cannot find enchant
    解决办法如下:
    yum -y install enchant-devel

    configure: error: Please reinstall the libcurl distribution – easy.h should be in /include/curl/
    解决办法如下:
    yum -y install libcurl-devel

    configure: error: mcrypt.h not found. Please reinstall libmcrypt.
    解决办法如下:
    wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
    tar zxf libmcrypt-2.5.7.tar.gz
    cd libmcrypt-2.5.7
    ./configure
    make && make install

    Cannot find imap
    解决办法如下:
    ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so

    configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing.
    解决办法如下:
    yum -y install libc-client-devel

    Cannot find ldap.h
    解决办法如下:
    yum -y install openldap
    yum -y install openldap-devel

    configure: error: Cannot find ldap libraries in /usr/lib
    解决办法如下:
    cp -frp /usr/lib64/libldap* /usr/lib/

    configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
    解决办法如下:
    yum -y install postgresql-devel

    configure: error: Please reinstall the lib curl distribution
    解决办法如下:
    yum -y install curl-devel

    configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
    解决办法如下:
    yum -y install net-snmp-devel

    configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
    解决办法如下:
    yum -y install libxslt-devel

    checking for BZip2 support… yes checking for BZip2 in default path… not found configure: error: Please reinstall the BZip2 distribution
    解决办法如下:
    yum -y install bzip2-devel

    checking for cURL support… yes checking if we should use cURL for url streams… no checking for cURL in default path… not found configure: error: Please reinstall the libcurl distribution – easy.h should be in/include/curl/
    解决办法如下:
    yum -y install curl-devel

    checking for curl_multi_strerror in -lcurl… yes checking for QDBM support… no checking for GDBM support… no checking for NDBM support… no configure: error: DBA: Could not find necessary header file(s).
    解决办法如下:
    yum -y install db4-devel

    checking for fabsf… yes checking for floorf… yes configure: error: jpeglib.h not found.
    解决办法如下:
    yum -y install libjpeg-devel

    checking for fabsf… yes checking for floorf… yes checking for jpeg_read_header in -ljpeg… yes configure: error: png.h not found.
    解决办法如下:
    yum -y install libpng-devel

    checking for png_write_image in -lpng… yes If configure fails try –with-xpm-dir=

    configure: error: freetype.h not found.
    解决办法如下:
    Reconfigure your PHP with the following option. –with-xpm-dir=/usr

    checking for png_write_image in -lpng… yes configure: error: libXpm.(a|so) not found.
    解决办法如下:
    yum -y install libXpm-devel

    checking for bind_textdomain_codeset in -lc… yes checking for GNU MP support… yes configure: error: Unable to locate gmp.h
    解决办法如下:
    yum -y install gmp-devel

    checking for utf8_mime2text signature… new checking for U8T_DECOMPOSE… configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
    解决办法如下:
    yum -y install libc-client-devel

    checking for LDAP support… yes, shared checking for LDAP Cyrus SASL support… yes configure: error: Cannot find ldap.h
    解决办法如下:
    yum -y install openldap-devel

    checking for mysql_set_character_set in -lmysqlclient… yes checking for mysql_stmt_next_result in -lmysqlclient… no checking for Oracle Database OCI8 support… no checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
    解决办法如下:
    yum -y install unixODBC-devel

    checking for PostgreSQL support for PDO… yes, shared checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
    解决办法如下:
    yum -y install postgresql-devel

    checking for sqlite 3 support for PDO… yes, shared checking for PDO includes… (cached) /usr/local/src/php-5.3.7/ext checking for sqlite3 files in default path… not found configure: error: Please reinstall the sqlite3 distribution
    解决办法如下:
    yum -y install sqlite-devel

    checking for utsname.domainname… yes checking for PSPELL support… yes configure: error: Cannot find pspell
    解决办法如下:
    yum -y install aspell-devel

    checking whether to enable UCD SNMP hack… yes checking for default_store.h… no

    checking for kstat_read in -lkstat… no checking for snmp_parse_oid in -lsnmp… no checking for init_snmp in -lsnmp… no configure: error: SNMP sanity check failed. Please check config.log for more information.
    解决办法如下:
    yum -y install net-snmp-devel

    checking whether to enable XMLWriter support… yes, shared checking for xml2-config path… (cached) /usr/bin/xml2-config checking whether libxml build works… (cached) yes checking for XSL support… yes, shared configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
    解决办法如下:
    yum -y install libxslt-devel

    configure: error: xml2-config not found. Please check your libxml2 installation.
    解决办法如下:
    yum -y install libxml2-devel

    checking for PCRE headers location… configure: error: Could not find pcre.h in /usr
    解决办法如下:
    yum -y install pcre-devel

    configure: error: Cannot find MySQL header files under yes. Note that the MySQL client library is not bundled anymore!
    解决办法如下:
    yum -y install mysql-devel

    checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
    解决办法如下:
    yum -y install unixODBC-devel

    checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
    解决办法如下:
    yum -y install postgresql-devel

    configure: error: Cannot find pspell
    解决办法如下:
    yum -y install pspell-devel

    configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
    解决办法如下:
    yum -y install net-snmp-devel

    configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
    解决办法如下:
    yum -y install libxslt-devel

  • CentOS7 编译安装php 5.6

    环境准备

    # yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel jemalloc jemalloc-devel
    # cd /usr/local/src
    # wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
    # tar zvxf php-5.6.30.tar.gz
    # cd php-5.6.30
    # groupadd www
    # useradd -g www -s /sbin/nologin www

    编译安装

    ##编译参数
    ./configure --prefix=/usr/local/php \
    --with-config-file-path=/usr/local/php/etc \
    --enable-inline-optimization --disable-debug \
    --disable-rpath --enable-shared --enable-opcache \
    --enable-fpm --with-fpm-user=www \
    --with-fpm-group=www \
    --with-mysql=mysqlnd \
    --with-mysqli=mysqlnd \
    --with-pdo-mysql=mysqlnd \
    --with-gettext \
    --enable-mbstring \
    --with-iconv \
    --with-mcrypt \
    --with-mhash \
    --with-openssl \
    --enable-bcmath \
    --enable-soap \
    --with-libxml-dir \
    --enable-pcntl \
    --enable-shmop \
    --enable-sysvmsg \
    --enable-sysvsem \
    --enable-sysvshm \
    --enable-sockets \
    --with-curl --with-zlib \
    --enable-zip \
    --with-bz2 \
    --with-readline
    # make && make install
     
    ##重新安装
    # make clean
    # make clean all
    # ./configure
    # make && make install
     
     
    ##参数解释
    """ 安装路径 """
    --prefix=/usr/local/php56 \
    """ php.ini 配置文件路径 """
    --with-config-file-path=/usr/local/php56/etc \
    """ 优化选项 """
    --enable-inline-optimization \
    --disable-debug \
    --disable-rpath \
    --enable-shared \
    """ 启用 opcache,默认为 ZendOptimizer+(ZendOpcache) """
    --enable-opcache \
    """ FPM """
    --enable-fpm \
    --with-fpm-user=www \
    --with-fpm-group=www \
    """ MySQL """
    --with-mysql=mysqlnd \
    --with-mysqli=mysqlnd \
    --with-pdo-mysql=mysqlnd \
    """ 国际化与字符编码支持 """
    --with-gettext \
    --enable-mbstring \
    --with-iconv \
    """ 加密扩展 """
    --with-mcrypt \
    --with-mhash \
    --with-openssl \
    """ 数学扩展 """
    --enable-bcmath \
    """ Web 服务,soap 依赖 libxml """
    --enable-soap \
    --with-libxml-dir \
    """ 进程,信号及内存 """
    --enable-pcntl \
    --enable-shmop \
    --enable-sysvmsg \
    --enable-sysvsem \
    --enable-sysvshm \
    """ socket & curl """
    --enable-sockets \
    --with-curl \
    """ 压缩与归档 """
    --with-zlib \
    --enable-zip \
    --with-bz2 \
    """ GNU Readline 命令行快捷键绑定 """
    --with-readline

    配置服务

    #配置文件
    # cp php.ini-development /usr/local/php/etc/php.ini
     
    #php-fpm 服务
    # cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
    # cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
    # chmod +x /etc/init.d/php-fpm
     
    # chkconfig --add php-fpm
    # chkconfig php-fpm on
    # service php-fpm start

    环境变量

    # vim /etc/profile
    PATH=$PATH:/usr/local/php/bin
    export PATH
    # source /etc/profile

    安装mcrypt扩展

    1、下载libmcrypt-2.5.8  (PHP支持库)

    http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

    2、下载mhash 0.9.9.9  (PHP支持库)

    http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/

    3、下载mcrypt-2.6.8   (PHP支持库)

    http://sourceforge.net/projects/mcrypt/files/

    4、安装libmcrypt

    cd /usr/local/src  #进入软件包存放目录
    
    tar zxvf libmcrypt-2.5.8.tar.gz  #解压
    
    cd libmcrypt-2.5.8  #进入安装目录
    
    ./configure  #配置
    
    make  #编译
    
    make install  #安装

    5、安装mhash

    cd /usr/local/src
    
    tar zxvf mhash-0.9.9.9.tar.gz
    
    cd mhash-0.9.9.9
    
    ./configure
    
    make
    
    make install

    6、安装mcrypt

    cd /usr/local/src
    
    tar zxvf mcrypt-2.6.8.tar.gz
    
    cd mcrypt-2.6.8
    
    ln -s   /usr/local/bin/libmcrypt_config   /usr/bin/libmcrypt_config  #添加软连接
    
    export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH  #添加环境变量
    
    ./configure
    
    make
    
    make install

    测试是否已安装成功

    在网站目录下新建一个info.php测试页面,写上下面代码,保存

    <?php

    phpinfo();

    ?>

    在浏览器中打开info.php会看到系统信息

  • CVE-2021-3156linux sudo漏洞修复

    下载最新修复补丁包sudo-1.9.5p2.tar.gz

    官网https://www.sudo.ws/dist/sudo-1.9.5p2.tar.gz,下载最新版本sudo软件tar包,并解压

    tar zxvf sudo-1.9.5p2.tar.gz
    

    进入解压目录,执行编译命令

    cd sudo-1.9.5p2
    ./configure --prefix=/usr --libexecdir=/usr/lib --with-secure-path --with-all-insults --with-env-editor --docdir=/usr/share/doc/sudo-1.9.5p2 --with-passprompt="[sudo] password for %p: " && make && make install && ln -sfv libsudo_util.so.0.0.0 /usr/lib/sudo/libsudo_util.so.0

    编译成功后,查看版本

    [root@sunkai-test sudo-1.9.5p2]# sudo --version
    Sudo version 1.9.5p2
    Configure options: --prefix=/usr --libexecdir=/usr/lib --with-secure-path --with-all-insults --with-env-editor --docdir=/usr/share/doc/sudo-1.9.5p2 --with-passprompt=[sudo] password for %p: 
    Sudoers policy plugin version 1.9.5p2
    Sudoers file grammar version 48
    ...
    ...
    Sudoers I/O plugin version 1.9.5p2
    Sudoers audit plugin version 1.9.5p2
    

    root下测试漏洞,不受影响

    [root@sunkai-test sudo-1.9.5p2]# sudoedit -s /
    usage: sudoedit [-AknS] [-C num] [-D directory] [-g group] [-h host] [-p prompt] [-R directory] [-T timeout] [-u user] file ...
  • Linux中KVM桥接网卡br0

    CentOS 6以上版本在使用KVM虚拟化的时,会需要配置到桥接网卡,下面简单的介绍一下桥接的方法:

    1、查看网卡的现有状态:

    TYPE=Ethernet
    PROXY_METHOD=none
    BROWSER_ONLY=no
    BOOTPROTO=dhcp
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    IPV6_ADDR_GEN_MODE=stable-privacy
    NAME=enp0s25
    UUID=f4656320-077f-4e68-ae2f-a697bddf2766
    DEVICE=enp0s25
    ONBOOT=yes
    

    2、Copy一份网卡为br0

    cp ifcfg-enp0s25 ifcfg-br0

    3、修改 enp0s25:最后增加BRIDGE=br0,如果是静态地址,只需要修改 BOOTPROTO=static即可

    
    
    TYPE=Ethernet
    PROXY_METHOD=none
    BROWSER_ONLY=no
    BOOTPROTO=dhcp
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    IPV6_ADDR_GEN_MODE=stable-privacy
    NAME=enp0s25
    UUID=f4656320-077f-4e68-ae2f-a697bddf2766
    DEVICE=enp0s25
    ONBOOT=yes
    BRIDGE=br0

    4、修改br0,重点是TYPE和DEVICE,DHCP还是STATIC根据实际情况配置

    TYPE=Bridge
    BOOTPROTO=dhcp
    DEVICE=br0
    ONBOOT=yes

    5、重启网卡服务,查看桥接情况

  • Windows下实现Nginx开机自启动

    1.右击“新建”->点击“文本文档”->双击打开”文本文档”复制粘贴一下内容:

    <!-- nginx-service.xml -->
    <service>
        <id>nginx</id>   
        <name>Nginx Service</name>   
        <description>High Performance Nginx Service</description>
        <env name="path" value="D:\Nginx-auto\nginx-1.14.0.57-A\"></env>
        <executable>nginx.exe</executable>
        <executable>nginx.exe -s stop</executable>
        <logpath>D:Nginx-auto\nginx-1.14.0.57-A\logs\</logpath>
        <log mode="roll-by-size">     
            <sizeThreshold>10240</sizeThreshold>     
            <keepFiles>8</keepFiles>   
        </log>
    </service>
    

    2.右击“新建”->点击“文本文档”->双击打开”文本文档”复制粘贴一下内容:

    <configuration>  
        <startup>    
            <supportedRuntime version="v2.0.50727" />    
            <supportedRuntime version="v4.0" />  
        </startup>  
        <runtime>    
            <generatePublisherEvidence enabled="false"/>   
        </runtime>
    </configuration>
    

    Ctrl + s保存->右击“文本文档”->重命名” nginx-service.xml”

    Ctrl + s保存->右击“文本文档”->重命名” nginx-service.exe.config”

    3.下载“WinSW.NETCore.x64.exe”->重命名“nginx-service.exe”:

    Win + R->cmd回车->nginx-service.exe install

    注:执行完后即可在“服务”列表看到Nginx Service服务 点击启动并设置自动即可。
    (设置开机自启的同时reload将无法使用,只能执行ln-stop.bat关闭服务)

    引用:Windows下实现Nginx开机自启动_Mr.Wang的博客-CSDN博客

  • Nginx设置成开机自动启动服务

    1、在/etc/init.d下创建文件nginx,文件的内容拷贝官网内容,主要修改下面两个参数的值

    nginx=”/usr/sbin/nginx” #修改成nginx执行程序的路径。
    NGINX_CONF_FILE=”/etc/nginx/nginx.conf” #修改成nginx.conf文件的路径。

    样例如下:

    #!/bin/sh
    #
    # nginx - this script starts and stops the nginx daemon
    #
    # chkconfig:   - 85 15
    # description:  NGINX is an HTTP(S) server, HTTP(S) reverse \
    #               proxy and IMAP/POP3 proxy server
    # processname: nginx
    # config:      /etc/nginx/nginx.conf
    # config:      /etc/sysconfig/nginx
    # pidfile:     /var/run/nginx.pid
     
    # Source function library.
    . /etc/rc.d/init.d/functions
     
    # Source networking configuration.
    . /etc/sysconfig/network
     
    # Check that networking is up.
    [ "$NETWORKING" = "no" ] && exit 0
     
    nginx="/usr/local/nginx/sbin/nginx"
    prog=$(basename $nginx)
     
    NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
     
    [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
     
    lockfile=/var/lock/subsys/nginx
     
    make_dirs() {
       # make required directories
       user=`$nginx -V 2>&1 | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
       if [ -n "$user" ]; then
          if [ -z "`grep $user /etc/passwd`" ]; then
             useradd -M -s /bin/nologin $user
          fi
          options=`$nginx -V 2>&1 | grep 'configure arguments:'`
          for opt in $options; do
              if [ `echo $opt | grep '.*-temp-path'` ]; then
                  value=`echo $opt | cut -d "=" -f 2`
                  if [ ! -d "$value" ]; then
                      # echo "creating" $value
                      mkdir -p $value && chown -R $user $value
                  fi
              fi
           done
        fi
    }
     
    start() {
        [ -x $nginx ] || exit 5
        [ -f $NGINX_CONF_FILE ] || exit 6
        make_dirs
        echo -n $"Starting $prog: "
        daemon $nginx -c $NGINX_CONF_FILE
        retval=$?
        echo
        [ $retval -eq 0 ] && touch $lockfile
        return $retval
    }
     
    stop() {
        echo -n $"Stopping $prog: "
        killproc $prog -QUIT
        retval=$?
        echo
        [ $retval -eq 0 ] && rm -f $lockfile
        return $retval
    }
     
    restart() {
        configtest || return $?
        stop
        sleep 1
        start
    }
     
    reload() {
        configtest || return $?
        echo -n $"Reloading $prog: "
        killproc $nginx -HUP
        RETVAL=$?
        echo
    }
     
    force_reload() {
        restart
    }
     
    configtest() {
      $nginx -t -c $NGINX_CONF_FILE
    }
     
    rh_status() {
        status $prog
    }
     
    rh_status_q() {
        rh_status >/dev/null 2>&1
    }
     
    case "$1" in
        start)
            rh_status_q && exit 0
            $1
            ;;
        stop)
            rh_status_q || exit 0
            $1
            ;;
        restart|configtest)
            $1
            ;;
        reload)
            rh_status_q || exit 7
            $1
            ;;
        force-reload)
            force_reload
            ;;
        status)
            rh_status
            ;;
        condrestart|try-restart)
            rh_status_q || exit 0
                ;;
        *)
            echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
            exit 2
    esac

    2、保存后设置文件的执行权限

    chmod a+x /etc/init.d/nginx

    3、将nginx服务加入chkconfig管理列表,加完这个之后,就可以使用service对nginx进行启动,重启等操作了。

    chkconfig --add /etc/init.d/nginx
    service nginx start
    service nginx stop
    service nginx restart
    service nginx status

    4、最后设置开机自动启动

    chkconfig nginx on

  • 运行python脚本后台执行

    在Linux中,可以使用nohup将脚本放置后台运行,如下:

    nohup python myscript.py params1 > nohup.out 2>&1 &

    但直接使用上面代码,无法在程序运行过程中查看Python中的print “computing” 输出结果,比如在每次循环中使用print语句等。原因是python的输出有缓冲,导致nohup.out不能够马上看到输出。

    解决方法:
    使用-u参数,使得python不启用缓冲

    修改命令如下:
    nohup python -u myscript.py params1 > nohup.out 2>&1 &

  • pip安装requests时报https/tls/ssl错误

    pip安装requests时报错,提示如下:

    pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
    Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available
    .",)) - skipping

    经过多次测试,发现是url的来源的问题,换成了国内的pip源就可以正常安装了,我使用的是:

    pip3 install requests -i http://pypi.douban.com/simple –trusted-host pypi.douban.com

    还可以使用以下地址

    1) http://mirrors.aliyun.com/pypi/simple/ 阿里云
    
    2) https://pypi.mirrors.ustc.edu.cn/simple/  中国科技大学
    
    3) http://pypi.douban.com/simple/  豆瓣
    
    4) https://pypi.tuna.tsinghua.edu.cn/simple/ 清华大学
    
    5) http://pypi.mirrors.ustc.edu.cn/simple/ 中国科学技术大学
  • openssl编译参数选项

    执行Configure是常见参数选项如下:

    安装参数:

    --openssldir=OPENSSLDIR
    安装目录,默认是 /usr/local/ssl 。
    --prefix=PREFIX
    设置 lib include bin 目录的前缀,默认为 OPENSSLDIR 目录。
    --install_prefix=DESTDIR
    设置安装时以此目录作为"根"目录,通常用于打包,默认为空。
    zlib
    zlib-dynamic
    no-zlib
    使用静态的zlib压缩库、使用动态的zlib压缩库、不使用zlib压缩功能。
    threads
    no-threads
    是否编译支持多线程的库。默认支持。
    shared
    no-shared
    是否生成动态连接库。
    asm
    no-asm
    是否在编译过程中使用汇编代码加快编译过程。
    enable-sse2
    no-sse2
    启用/禁用SSE2指令集加速。如果你的CPU支持SSE2指令集,就可以打开,否则就要关闭。
    gmp
    no-gmp
    启用/禁用GMP库
    rfc3779
    no-rfc3779
    启用/禁用实现X509v3证书的IP地址扩展
    krb5
    no-krb5
    启用/禁用 Kerberos 5 支持
    ssl
    no-ssl
    ssl2
    ssl3
    no-ssl2
    no-ssl3
    tls
    no-tls
    启用/禁用 SSL(包含了SSL2/SSL3) TLS 协议支持。
    dso
    no-dso
    启用/禁用调用其它动态链接库的功能。[提示]no-dso仅在no-shared的前提下可用。

    禁用选项

    no-md2,no-md4,no-mdc2,no-ripemd
    摘要算法
    no-des,no-rc2,no-rc4,no-rc5,no-idea,no-bf,no-cast,no-camellia
    对称加密算法
    no-ec,no-dsa,no-ecdsa,no-dh,no-ecdh
    不对称加密算法
    no-comp
    数据压缩算法
    no-store
    对象存储功能
  • Linux升级openssl1.1.1l

    1、下载openssl

    wget https://www.openssl.org/source/openssl-1.1.1l.tar.gz

    2、创建安装目录

    mkdir -p usr/local/openssl

    3、解压

    tar -zxvf  openssl-1.1.1l.tar.gz

    4、编译安装

    cd openssl-1.1.1l
    ./config --prefix=/usr/local/openssl no-zlib #不需要zlib
    make
    make install

    5、备份原配置

    mv /usr/bin/openssl /usr/bin/openssl.bak
    mv /usr/include/openssl/ /usr/include/openssl.bak

    6、新版配置

    ln -s /usr/local/openssl/include/openssl /usr/include/openssl
    ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/local/lib64/libssl.so
    ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
    

    7、修改系统配置,写入openssl库文件的搜索路径

    echo "/usr/local/openssl/lib" >> /etc/ld.so.conf

    8、使修改后的/etc/ld.so.conf生效

    ldconfig -v

    9、查看openssl版本

    [root@test ~]#openssl version
    OpenSSL 1.1.1l 24 Aug 2021