2017年3月23日 星期四

ubuntu enable firewall and add rules

1.開啟最高權限模式
   sudo su
2. 啟動firewall
      ufw enable

3.新增允許ssh 規則
     ufw allow ssh

4.新增允許網站80 port 規則
       ufw allow  in 80
5.新增允許網站443 port (ssl)規則
   ufw allow in 443


6.新增允許網站vsftp port 規則

   ufw allow 20/tcp
   ufw allow 21/tcp
   ufw allow 990/tcp
   ufw allow 4000:5000/tcp



ubuntu 16.04 install apache2 php7 & mariadb

1.切換最高權限
   sudo su
2.安裝mariadb server & client
   apt-get -y install mariadb-server mariadb-client
3.資料庫安全設置
   mysql_secure_installation


  Enter current password for root (enter for none): <-- press enter
  Change root password? [Y/n] <-- y
  New password: <-- Enter the new MariaDB root password here
  Re-enter new password: <-- Repeat the password
  Remove anonymous users? [Y/n] <-- y
  Disallow root login remotely? [Y/n] <-- y
  Reload privilege tables now? [Y/n] <-- y

   mysql -u root -p  使用新密碼登入測試

4.安裝apache 2.4
     apt-get -y install apache2
5.安裝php 7.0
     apt-get -y install php7.0 libapache2-mod-php7.0

   systemctl restart apache2 重啟apache


   nano /var/www/html/info.php


<?php
phpinfo();
?>


   chown www-data:www-data /var/www/html/info.php


   瀏覽器打開 http://192.168.x.xx/info.php  (ip查詢 ifconfig)

   apt-cache search php7.0


  apt-get -y install php7.0-mysql php7.0-curl php7.0-gd php7.0-intl php-pear php-imagick php7.0-imap php7.0-mcrypt php-memcache  php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-mbstring php-gettext

  
6.新增url rewrite
    sudo a2enmod rewrite
systemctl restart apache2

   打開 http://192.168.x.xx/info.php 檢查是否有mod_rewrite
7.
   apt-get -y install php-apcu
  systemctl restart apache2
8.Enable the SSL website in apache
   a2enmod ssl
  a2ensite default-ssl
  systemctl restart apache2
9.Install phpMyAdmin
   apt-get -y install phpmyadmin

  Web server to configure automatically: <-- Select the option: apache2
Configure database for phpmyadmin with dbconfig-common? <-- Yes
MySQL application password for phpmyadmin: <-- Press enter, apt will create a random password automatically.
 如果http://192.168.x.xx/phpmyadmin/ 找不到

1.apache 2的環境設定檔內加

  <Directory />
AllowOverride All </Directory>

2.加路徑關聯
  sudo ln -s /usr/share/phpmyadmin /var/www/html/




















ubuntu install ssh and disable root login


1.更新page
   sudo apt-get update

2.install ssh
  sudo apt-get install ssh

3.修改設定
   sudo nano /etc/ssh/sshd_config

   permitrootlogin prohibit-password => permitrootlogin no 禁止root登入
   AllowUsers XXX   允許XXX帳號登入

4.重開機
  sudo reboot

ubuntu vm安裝完畢,安裝vmware tools

1.sudo mkdir /mnt/cdrom
2.sudo mount /dev/cdrom /mnt/cdrom or sudo mount /dev/sr0 /mnt/cdrom
3.ls /mnt/cdrom
4.tar xzvf /mnt/cdrom/VMwareTools-x.x.x-xxxx.tar.gz -C /tmp/
5.cd /tmp/vmware-tools-distrib/
6.sudo ./vmware-install.pl -d
7.sudo reboot


ubuntu reset default password

ubuntu 剛安裝完畢重設 root passwd

sudo passwd root

2016年11月15日 星期二

[Mysql] Mysql 5.7 1055 error

在Mysql 5.7 insert的時候遇到
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause 
and contains nonaggregated column 'information_schema.PROFILING.SEQ' 
which is not functionally dependent on columns in GROUP BY clause; this 
is incompatible with sql_mode=only_full_group_by



解決方式就是把only_full_group_by設為空值

SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

2015年12月13日 星期日

koding install CodeIgniter 3.0



切換目錄到安裝CI的目錄(WEB root或是sub folder)~
cd /var/www

下載CI (2.2 or 3.0)
wget https://github.com/bcit-ci/CodeIgniter/archive/3.0-stable.zip


解壓縮
unzip 3.0-stable.zip

把目錄改名成codeigniter
mv CodeIgniter-3.0-stable codeigniter



打開網址瀏覽
http://<Host>/codeigniter/