2017年3月5日 星期日

Ubuntu 16.04 MariaDB外部連線

修改/etc/mysql/mariadb.conf.d/50-server.cnf內容,找到下列這行設定,並將其註解掉,如下:
#bind-address           = 127.0.0.1

存檔後可以先看看目前Mariadb的服務監聽狀態:
$ netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN

一般將服務的設定檔變更後,只要重新啟動服務,應該就可以直接套用新的設定,但重新啟動了Mariadb,發現服務的監聽依然綁定在127.0.0.1:3306........只好使出殺手鐧~reboot......果然!在機器重新啟動後Mariadb的服務監聽不再是127.0.0.1:3306了!
$ netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN

2017年2月6日 星期一

Ubuntu 16.04 vsftp 設定

安裝:
sudo apt update
sudo apt-get install vsftpd

設定檔/etc/vsftpd.conf修改:
listen=YES
#listen_ipv6=YES #listen和listen_ipv6只能啟動一個,listen_ipv6支援ipv6與v4

# Allow anonymous FTP? (Disabled by default).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=002

# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# If enabled, vsftpd will display directory listings with the time
# in  your  local  time  zone.  The default is to display GMT. The
# times returned by the MDTM FTP command are also affected by this
# option.
use_localtime=YES

#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
# Activate logging of uploads/downloads.
xferlog_enable=YES
# You may override where the log file goes if you like. The default is shown
# below.
xferlog_file=/var/log/vsftpd.log

# You may restrict local users to their home directories.  See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
chroot_local_user=YES
allow_writeable_chroot=YES
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd.chroot_list

# Customization
#
# Some of vsftpd's settings don't fit the filesystem layout by
# default.
#
# This option should be the name of a directory which is empty.  Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd/empty
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd
#
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO

# Uncomment this to indicate that vsftpd use a utf8 filesystem.
utf8_filesystem=YES

Ubuntu 16.04 Mysql 5.7 max connections設定值大於214

修改/etc/mysql/mysql.conf.d/mysqld.cnf,設定需要的連線數:
max_connections=1000


再修改/lib/systemd/system/mysql.service,增加以下設定值:
LimitNOFILE=8192


接著執行以下指令:
systemctl daemon-reload
systemctl restart mysql.service


驗證:
進mysql後執行
show variables like "max_connections";
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 1000  |
+-----------------+-------+
1 row in set (0.01 sec)

2017年2月3日 星期五

Ubuntu 16.04 Mariadb phpmyadmin 安裝、登入

在Ubuntu 16.04安裝Mariadb 10+phpmyadmin;
先安裝Mariadb,apache2,php:
sudo apt update
sudo apt upgrade
sudo apt install mariadb-server mariadb-client apache2 php7.0 libapache2-mod-php7.0 
Mariadb預設值卻不能登入phpmyadmin(mariadb預設空白密碼與預設禁止root登入phpmyadmin),在安裝完Mariadb後可進行以下修改:
變更Mariadb root密碼:
$ sudo mysqladmin -u root password

變更允許Mariadb root登入phpmyadmin
$ sudo mysql -u root -p mysql
update user set plugin='' where user='root';
flush privileges;
exit;

在安裝Mysql+phpmyadmin幾乎沒啥問題,但一把Mysql改成Maria總是一堆錯誤!phpmyadmin安裝時會在資料庫系統上產生一個phpmyadmin的資料庫與使用者帳號,但配合Maria時卻總是會失敗!懶得查詢phpmyadmin的安裝設定,直接取巧的先在Mariadb上手動新增phpmyadmin帳號(密碼:123456)與phpmyadmin資料庫,並給予phpmyadmin對phpmyadmin資料庫完整的權限:
$ sudo mysql -u root -p 
create database phpmyadmin;
grant all on phpmyadmin.* to 'phpmyadmin'@'localhost' identified by '123456' with grant option;
接著再安裝phpmyadmin,應該可以順利安裝完成!
sudo apt install phpmyadmin








2016年10月8日 星期六

2016年10月6日 星期四

Ubuntu 16.04 apache2+php

sudo apt update
sudo apt install apache2 php libapache2-mod-php

一般來說安裝應該只需要下apache2與php,但這個版本不知是啥問題,libapache2-mod-php
這個套件若沒指定安裝,php會無法執行.......