星期五, 3月 29, 2019

sudo , wifi connect command



  • To see list of saved connections, use (<SavedWiFiConn>)
    nmcli c
    
  • To see list of available WiFi hotspots (<WiFiSSID>)
    nmcli d wifi list

sudo nmcli d wifi connect iSSA_ASUS_50_2.4G password 54098542 iface wlan0

Reference:


www-data        ALL=(ALL) NOPASSWD: /usr/bin/amixer

PHP system call system/exec/shell_exec difference and sudo

PHP system call system/exec/shell_exec difference

  • system()
    • $last_line = system('ls', $return_var);
    • system() 會將輸出內容直接印出, 所以若於網頁, 會將所有回傳內容都顯示於頁面上.
    • $last_line: 只能取得最後一行的內容
    • $return_var: 取得系統狀態回傳碼
  • exec()
    • exec('ls', $output, $return_var);
    • $output: 回傳內容都會存於此變數中(儲存成陣列), 不會直接秀在頁面上.
    • $return_var: 取得系統狀態回傳碼
  • shell_exec()
    • $output = shell_exec('ls');
    • $output: 回傳內容都會存於此變數中(儲存成純文字內容), 不會直接秀在頁面上.

www-data        ALL=(ALL) NOPASSWD: /usr/bin/amixer


Reference:

nginx dependent file


        sudo apt-get install nginx nginx-common nginx-core fcgiwrap php7.0 apache2-utils
        sudo systemctl restart php7.0-fpm nginx
        #systemctl status nginx.service

.htpasswd add script


        sudo htpasswd -cb /etc/nginx/cam.htpasswd root pass

星期四, 3月 28, 2019

PHP7

Nginx

The following NEW packages will be installed: 1,346 kB
  nginx nginx-common nginx-core
Suggested packages:
  fcgiwrap nginx-doc



/etc/nginx/nginx.conf



service nginx restart

restart service:
sudo systemctl restart php7.0-fpm nginx
debug: 
  • systemctl status nginx.service
  • journalctl -xe

/etc/nginx/sites-available/example.com
--------------------
server {
    listen 80;
    listen [::]:80;

    server_name example.com;

    root   /var/www/html/example.com/public_html;
    index  index.html index.php;

    location / {
        try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            include fastcgi_params;
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
            fastcgi_param SCRIPT_FILENAME /var/www/html/example.com/public_html$fastcgi_script_name;
    }
}


--------------------
https://www.linode.com/docs/web-servers/nginx/install-and-configure-nginx-and-php-fastcgi-on-ubuntu-16-04/


PHP7

 config file


  • 13.2 MB
  • /etc/php/7.0/fpm/php.ini
  • /etc/php/7.0/cli/php.ini
  • /etc/php/7.0/mods-available/
  • /usr/bin/php
  • /usr/bin/phar
  • /usr/bin/phar.phar

dependency





The following additional packages will be installed:
  php-common php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-json php7.0-opcache php7.0-readline

<form class="form-horizontal" action="送至.php" method="post" role="form">
表單元件
</form>

表單中加入「表單欄位」:
<form class="form-horizontal" action="index.php" method="post" role="form">
  <div class="form-group">
    <label class="col-md-4 control-label" for="name">帳號:</label>
    <div class="col-md-8">
      <input type="text" name="name" id="name" placeholder="請輸入帳號" class="form-control">
    </div>
  </div>
  <div class="form-group">
    <label class="col-md-4 control-label" for="passwd">密碼:</label>
    <div class="col-md-8">
      <input type="password" name="passwd" id="passwd" placeholder="請輸入密碼" class="form-control">
    </div>
  </div>
  <div class="text-center">
    <input type="hidden" name="op" value="login">
    <button type="submit" name="button" class="btn btn-primary">登入</button>
  </div>
</form>