2017年1月5日 星期四

[ EZGO 13 ] MariaDB 10.1.21

官方網站:https://mariadb.com/
檔案來源:http://www.linuxfromscratch.org/blfs/view/svn/server/mariadb.html

$ sudo groupadd -g 51 mysql

$ sudo useradd -c "MySQL Server" -d /RAID/local/srv/MySQL -g mysql -s /bin/false -u 51 mysql

$ sed -i "s@data/test@\${INSTALL_MYSQLTESTDIR}@g" sql/CMakeLists.txt

Option
  • 如果沒有 cmake 執行 $ sudo apt install cmake 
  • 如果沒有 /usr/bin/c++ 執行 sudo apt install g++
  • Curses library not found 執行 $ sudo apt install libncurses5-dev
  • Could NOT find LibXml2 執行 sudo apt install libxml2-dev
  • Could NOT find JNI
    修改 /usr/share/
    cmake-3.5/Modules/FindJNI.cmake
    增加:
JAVA_APPEND_LIBRARY_DIRECTORIES(
/usr/lib/jvm/java-8-oracle/jre/lib/{libarch}
)
list(
/usr/lib/jvm/java-8-oracle/include
)
      • Bison executable not found in PATH 執行 $ sudo apt install bison
      $ cmake \
              -DCMAKE_BUILD_TYPE=Release \
              -DCMAKE_CXX_COMPILER=/usr/bin/g++ \
              -DCMAKE_INSTALL_PREFIX=/RAID/local/srv/MySQL \
              -DDEFAULT_CHARSET=utf8 \
              -DDEFAULT_COLLATION=utf8_general_ci \
              -DEXTRA_CHARSETS=all \
              -DENABLED_LOCAL_INFILE=1 \
              -DINSTALL_DOCDIR=share/doc/mysql \
              -DINSTALL_DOCREADMEDIR=share/doc/mysql \
              -DINSTALL_MANDIR=share/man \
              -DINSTALL_MYSQLSHAREDIR=share/mysql \
              -DINSTALL_MYSQLTESTDIR=share/mysql/test \
              -DINSTALL_PLUGINDIR=lib/mysql/plugin \
              -DINSTALL_SBINDIR=sbin \
              -DINSTALL_SCRIPTDIR=bin \
              -DINSTALL_SQLBENCHDIR=share/mysql/bench \
              -DINSTALL_SUPPORTFILESDIR=share/mysql \
              -DMYSQL_DATADIR=/RAID/DB \
              -DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock \
              -DWITH_EXTRA_CHARSETS=complex \
              -DWITH_EMBEDDED_SERVER=ON \
              -DTOKUDB_OK=0
      PS:
      • 如果有 /usr/bin/c++ 用 -DCMAKE_CXX_COMPILER=/usr/bin/c++ 
      • 如果有 /usr/bin/g++ 用 -DCMAKE_CXX_COMPILER=/usr/bin/g++
      $ make

      $ sudo make install

      $ install -v -dm 755 /RAID/local/conf

      $ cat > /RAID/local/conf/my.cnf << "EOF"

      # Begin /RAID/local/conf/my.cnf

      # The following options will be passed to all MySQL clients
      [client]
      #password = your_password
      port = 3306
      socket = /run/mysqld/mysqld.sock
      default-character-set=utf8

      # The MySQL server
      [mysqld]
      port = 3306
      socket = /run/mysqld/mysqld.sock
      datadir = /RAID/DB
      character-set-server=utf8
      collation-server=utf8_general_ci
      skip-external-locking
      key_buffer_size = 16M
      max_allowed_packet = 1M
      sort_buffer_size = 512K
      net_buffer_length = 16K
      myisam_sort_buffer_size = 8M

      # Don't listen on a TCP/IP port at all.
      skip-networking

      # required unique id between 1 and 2^32 - 1
      server-id = 1

      # Uncomment the following if you are using BDB tables
      #bdb_cache_size = 4M
      #bdb_max_lock = 10000

      # Uncomment the following if you are using InnoDB tables
      #innodb_data_home_dir = /RAID/local/srv/MySQL
      #innodb_data_file_path = ibdata1:10M:autoextend
      #innodb_log_group_home_dir = /RAID/local/srv/MySQL
      # You can set .._buffer_pool_size up to 50 - 80 %
      # of RAM but beware of setting memory usage too high
      #innodb_buffer_pool_size = 16M
      #innodb_additional_mem_pool_size = 2M
      # Set .._log_file_size to 25 % of buffer pool size
      #innodb_log_file_size = 5M
      #innodb_log_buffer_size = 8M
      #innodb_flush_log_at_trx_commit = 1
      #innodb_lock_wait_timeout = 50

      [mysqldump]
      quick
      max_allowed_packet = 16M

      [mysql]
      no-auto-rehash
      # Remove the next comment character if you are not familiar with SQL
      #safe-updates

      [isamchk]
      key_buffer_size = 20M
      sort_buffer_size = 20M
      read_buffer = 2M
      write_buffer = 2M

      [myisamchk]
      key_buffer_size = 20M
      sort_buffer_size = 20M
      read_buffer = 2M
      write_buffer = 2M

      [mysqlhotcopy]
      interactive-timeout

      # End /RAID/local/conf/my.cnf
      EOF

      安裝資料庫
      $ sudo /RAID/local/srv/MySQL/bin/mysql_install_db --basedir=/RAID/local/srv/MySQL --defaults-file=/RAID/local/conf/my.cnf --datadir=/RAID/DB --user=mysql

      $ sudo chown -R mysql:mysql /RAID/DB

      $ sudo install -v -m755 -o mysql -g mysql -d /run/mysqld

      啟動資料庫服務
      $ sudo /RAID/local/srv/MySQL/bin/mysqld_safe --defaults-file=/RAID/local/conf/my.cnf --datadir=/RAID/DB --user=mysql 2>&1 >/dev/null &

      設定資料庫管理員密碼
      $ sudo /RAID/local/srv/MySQL/bin/mysqladmin -u root password

      停止資料庫服務
      $ sudo /RAID/local/srv/MySQL/bin/mysqladmin -p shutdown

      /RAID/local/srv/MySQL/bin/mysql -u root -pPassword
      mysql > GRANT ALL PRIVILEGES ON Database.* TO user@192.168.1.% IDENTIFIED BY 'password' WITH GRANT OPTION;
      mysql > FLUSH PRIVILEGES;

      [ EZGO13 ] Apache 2.4.25 + PHP 7.1.6

      官方網站:http://httpd.apache.org
      檔案來源:http://httpd.apache.org/download.cgi#apache24
      $ ./config \
      -fPIC \--prefix=/RAID/local/lib/OpenSSL \
      --openssldir=/RAID/local/lib/OpenSSL
      $ make
      $ sudo make install
      /RAID/local/lib/OpenSSL/bin/openssl version

      ODBC:
      ./configure \
      --prefix=/RAID/local/lib/unixODBC \
      --exec-prefix=/RAID/local/lib/unixODBC
      make
      sudo make install
      To check the ODBC version and configuration.
      /RAID/local/lib/unixODBC/bin/odbcinst -j
      unixODBC 2.3.4
      DRIVERS............: /RAID/local/lib/unixODBC/etc/odbcinst.ini
      SYSTEM DATA SOURCES: /RAID/local/lib/unixODBC/etc/odbc.ini
      FILE DATA SOURCES..: /RAID/local/lib/unixODBC/etc/ODBCDataSources
      USER DATA SOURCES..: /home/neo/.odbc.ini
      SQLULEN Size.......: 8
      SQLLEN Size........: 8
      SQLSETPOSIROW Size.: 8
      參數設定: 
      sudo nano /RAID/local/lib/unixODBC/etc/odbcinst.ini
      [FreeTDS]
      Description=v0.91 with protocol v8.0
      Driver=/RAID/local/lib/unixODBC/lib/libtdsodbc.so
      UsageCount=1
      sudo nano /RAID/local/lib/unixODBC/etc/odbc.ini
      [SQLServer]
      Driver=FreeTDS
      Description=SQL
      Trace=No
      Server=
      192.168.1.21
      Port=1433
      TDS_Version=8.0
      Database=DW
      PS
      odbcinst -q -d # View loaded drivers.
      odbcinst -q -s # View DSN entry
      tsql -LH 22.33.55.44 # To list MSSQL server instant name,version etc.,
      osql -S DSN -U Username -P ‘Password’ # list the configuration files loaded to connect ODBC 
      ./configure \
      --prefix=/RAID/local/lib/FreeTDS \
      --exec-prefix=/RAID/local/lib/FreeTDS \
      --with-tdsver=auto \
      --with-unixodbc=/RAID/local/lib/unixODBC \
      --with-gnu-ld \
      --enable-msdblib
      make
      sudo make install
      sudo nano /etc/ld.so.conf
      /RAID/local/lib/FreeTDS/lib
      sudo ldconfig
      sudo nano /RAID/local/lib/FreeTDS/etc/freetds.conf
      [MSsql]
      host = 
      192.168.1.21
      # instance = SQLEXPRESS
      # instance = MSSQLSERVER
      port = 1433
      client charset = UTF-8
      tds version = 8.0
      text size = 20971520
      Note: the freetds.conf file you use should have "text size = 20971520" as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see FreeTDS.
      sudo touch /RAID/local/lib/FreeTDS/include/tds_sysdep_public.h
      sudo touch /RAID/local/lib/FreeTDS/lib/libsybdb.a
      連線測試
      sudo /RAID/local/lib/FreeTDS/bin/tsql -S MSsql -U sa
      Note: 
      TDSVER=8.0
      tsql -H [伺服器名稱  xxxx.database.windows.net ] -p 1433 –D [資料庫名稱 ] -U [使用者帳號 -P [使用者密碼 ]

      Apache Portable Runtime
      http://apr.apache.org/download.cgi
      $ ./configure \
      --prefix=/RAID/local/lib/APR \
      --exec-prefix=/RAID/local/lib/APR
      $ make
      $ make install
      $ ./configure \
      --prefix=/RAID/local/lib/APR-iconv \
      --exec-prefix=/RAID/local/lib/APR-iconv \
      --with-apr=/RAID/local/lib/APR
      make
      $ make install
      $ ./configure \
      --prefix=/RAID/local/lib/APR-util \
      --exec-prefix=/RAID/local/lib/APR-util \
      --with-apr=/RAID/local/lib/APR \
      --with-apr-iconv=RAID/local/lib/APR-iconv \
      --with-crypto=/RAID/local/lib/OpenSSL \
      --with-freetds=/RAID/local/lib/FreeTDS \
      --with-mysql=/RAID/local/srv/MySQL \
      --with-openssl=/RAID/local/lib/OpenSSL
      make
      $ make install
      sudo nano /etc/ld.so.conf
      /RAID/local/lib/APR-util/lib
      PERL 5 regular expression pattern matching
      $ ./configure \
      --prefix=/RAID/local/lib/PCRE \
      --exec-prefix=/RAID/local/lib/PCRE \
      --enable-utf8
      make
      $ make install
      A Massively Spiffy Yet Delicately Unobtrusive Compression Library
      ./configure \
      --prefix=/RAID/local/lib/zlib \
      --eprefix=/RAID/local/lib/zlib
      make
      $ make install
      • Apache
      $ ./configure \
      --prefix=/RAID/local/srv/Apache \
      --exec-prefix=/RAID/local/srv/Apache \
      --enable-ssl \
      --enable-so \
      --enable-deflate \
      --enable-modules=mod_unixd \
      --enable-modules=mod_access_compat \
      --with-apr=/RAID/local/lib/APR \
      --with-apr-util=/RAID/local/lib/APR-util \
      --with-pcre=/RAID/local/lib/PCRE \
      --with-ssl=/RAID/local/lib/OpenSSL
      $ nano /RAID/local/Apache/conf/httpd.conf
      ServerRoot "/RAID/local/srv/Apache"
      ServerAdmin email@gmail.com
      ServerName 127.0.0.1:80
      DocumentRoot "/RAID/local/www"
      ErrorDocument 404 /404_Apple.html
      AddDefaultCharset utf-8
      <Directory "/RAID/local/www">
      ScriptAlias /cgi-bin/ "/RAID/local/www/cgi-bin/"
      <Directory "/RAID/local/www/cgi-bin">
      AddType application/x-httpd-php .php
      <IfModule dir_module>
          DirectoryIndex index.html index.htm index.php
      </IfModule>
      ErrorLog "|/RAID/local/srv/Apache/bin/rotatelogs -l /RAID/Log/Apache-error-%Y-%m-%d.log 86400"
      CustomLog "|/RAID/local/srv/Apache/bin/rotatelogs -l /RAID/Log/Apache-access-%Y-%m-%d.log 86400" common
      LoadModule rewrite_module modules/mod_rewrite.so
      LoadModule php7_module modules/libphp7.so 
      • apachectl - Apache HTTP Server Control Interface
      $ sudo /RAID/local/srv/Apache/bin/apachectl configtest
      $ sudo /RAID/local/srv/Apache/bin/apachectl start
      $ sudo /RAID/local/srv/Apache/bin/apachectl restart
      $ sudo /RAID/local/srv/Apache/bin/apachectl stop

      官方網站:http://php.net
      檔案來源:http://php.net/downloads.php
      • $ sudo apt install libjpeg-dev
      • sudo apt install libpng++-dev
      • sudo apt install libxpm-dev
      • sudo apt install libxft-dev
      • sudo apt install libmcrypt-dev
      • sudo apt install libssh2-1-dev
      • sudo apt install libgmp-dev
      • sudo apt install libtool-bin
      • sudo apt install re2c
      • sudo apt install autoconf
      ./configure \
      --prefix=/RAID/local/lib/cURL \
      --exec-prefix=/RAID/local/lib/cURL \
      --with-libssh2
      make
      $ make install
      $ ./configure \
      --prefix=/RAID/local/srv/PHP \
      --exec-prefix=/RAID/local/srv/PHP \
      --with-config-file-path=/RAID/local/conf \
      --with-pdo-mysql=/RAID/local/srv/MySQL \
      --with-mysqli=mysqlnd \
      --with-pdo-dblib=/RAID/local/lib/FreeTDS \
      --with-pdo-mysql=/RAID/local/srv/MySQL \
      --with-pdo-odbc=unixODBC,/RAID/local/lib/unixODBC \
      --with-apxs2=/RAID/local/srv/Apache/bin/apxs \
      --with-curl=/RAID/local/lib/cURL \
      --with-openssl \
      --with-pear \
      --with-mcrypt \
      --with-zlib \--with-jpeg-dir \
      --with-png-dir \
      --with-xpm-dir \
      --with-freetype-dir \
      --with-gd \
      --with-gmp \

      --enable-bcmath \
      --enable-intl \
      --enable-fpm \
      --enable-ftp \
      --enable-zip \
      --enable-mbstring \
      --enable-mysqlnd \
      --enable-re2c-cgoto \
      --enable-sockets \
      --enable-soap \
      --enable-debug \

      --enable-gd-native-ttf \
      --enable-gd-jis-conv
      make
      $ make install
      $ cp php.ini-production /RAID/local/conf/php.ini
      $ sudo /RAID/local/srv/Apache/bin/apachectl stop
      $ sudo /RAID/local/srv/Apache/bin/apachectl start
      $ wget http://pear.php.net/go-pear.phar
      $ sudo /RAID/local/srv/PHP/bin/php go-pear.phar
      $ /RAID/local/srv/PHP/bin/pear version

      [ EZGO13 ] ProFTP 1.3.6rc4

      官方網站:http://www.proftpd.org
      檔案來源:http://ftp.heanet.ie/mirrors/ftp.proftpd.org/distrib/source/proftpd-1.3.6rc4.tar.gz

      $ sudo apt-get install libwrap0-dev

      $ ./configure \
      --prefix=/RAID/local/srv/ProFTP \
      --exec-prefix=/RAID/local/srv/ProFTP \
      --enable-shadow \
      --enable-autoshadow \
      --enable-openssl \
      --with-modules=mod_ratio:mod_readme:mod_wrap \
      --with-openssl-cmdline=/RAID/local/lib/OpenSSL/bin

      $ make

      $ sudo make install

      $ nano /RAID/local/conf/proftpd.conf
      PersistentPasswd on
      ServerAdmin email@gmail.com

      關閉 Ident 和使用者網域反查
      IdentLookups off
      UseReverseDNS off

      使用本地時間
      SetEnv TZ :/etc/localtime
      TimesGMT off

      設定支援下載續傳、上傳續傳、支援 FXP
      AllowStoreRestart on
      AllowRetrieveRestart on
      AllowForeignAddress on

      顯示站台歡迎訊息
      DeferWelcome on

      允許被設定成不得由遠端登入的帳號 (invalid shell) 能 FTP 進來
      RequireValidShell off

      設定使用者登入和登出會看到的訊息檔
      DisplayLogin /RAID/local/conf/proftpd_welcome.msg
      DisplayQuit /RAID/local/conf/proftpd_logout.msg

      指定站台系統 Log 位置
      SystemLog /RAID/Log/ProFTP_proftpd.log

      ScoreboardFile /var/run/proftpd.scoreboard

      PidFile /var/run/proftpd.pid

      定義 Log 格式,紀錄登入 (login.log) 和傳檔 (transfer.log) 的細節
      # TransferLog /RAID/Log/xferlog
      LogFormat myxfer "%{%Y-%m-%d %H:%M:%S}t [%u] \"%m %f\" (%bB/%TS)"
      LogFormat myauth "%{%Y-%m-%d %H:%M:%S}t [%u] \"%r\": %S (%a)"
      ExtendedLog /RAID/Log/ProFTP_login.log auth myauth
      ExtendedLog /RAID/Log/ProFTP_transfer.log read,write myxfer


      • 歡迎訊息(會顯示登入位址、伺服器時間、硬碟可用空間、目前路徑和連線數量)
      $ nano /RAID/local/conf/proftpd_welcome.msg
      Welcome %U from %R to %L site !
      Current Time: %T
      Available Capacity: %F KB
      Current Directory: %C
      Current/Max Allow Connection: %N/%M
      • 登出的訊息檔(會顯示連線完,總共上傳和下載的檔案和容量)
      $ nano /RAID/local/conf/proftpd_logout.msg
      Upload: %{total_bytes_in} bytes, %i files
      Download: %{total_bytes_out} bytes, %o files
      Bye Bye, %U from %R !
      • 啟動 ProFTP
      $ sudo /RAID/local/srv/ProFTP/sbin/proftpd -c /RAID/local/conf/proftpd.conf &



      OpenSSL 1.1.0c

      官方網站:https://www.openssl.org/
      檔案來源:https://www.openssl.org/source/

      2017年1月4日 星期三

      [ Ubuntu ] ssh Server


      • 安裝
      $ sudo apt-get install openssh-server
      • 組態檔設定
      $ sudo nano /etc/ssh/sshd_config
      # 把允許 Root 登入的參數改掉
      PermitRootLogin no
      • 啟動
      $ sudo /etc/init.d/ssh restart
      • 開機自動啟動
      $ sudo update-rc.d ssh defaults