Startups:
Since 2014-10-05:
- http://www.quora.com/Lean-Startups
- http://www.quora.com/Startups
- http://simplestartup.quora.com/Startup-Cheat-Codes-7-awesome-cloud-based-tools-that-destroy-unnecessary-business-expenses-wasted-time-and-frustrat
- http://academicearth.org/business/
- https://github.com/makaimc/howdoistartup.github.io (from: http://www.fullstackpython.com/ -> follow Matt)
- http://www.tangowithdjango.com/book/index.html
- Ruby on Rails (web framework): What is the best way to learn Ruby on Rails? Bloc.io? theFirehoseProject?
- What is the best way to learn PHP?
- https://github.com/makaimc/easy-python
Asking Questions
- Stack exchange:
- Quora: Ruby vs Python | django | laravel | bootstrap | Web Development | Web Design | Web Applications
- Medium: laravel | django | bootstrap | design | ui | rails
2014-08-06: I learn markdown also here: https://help.github.com/articles/github-flavored-markdown
Writting style ref: https://github.com/johnantoni/beaglebone-black
Thanks all the clever people make the tools help me work remotely! High quality software, which is opensource, with well organized documentation, and supportive community! Thanks all, I love you. I've learnt much from you.
- Help to maintace the daily operation of hobototes (e.g. When we travel around the world, we need a small-enough computer for operation.).
- As a device to operate all-day-long with low power consumption. 😍 (verse the power a notebook needs)
- Runs the hobototes-data-centric apps on it. (To free my notebook from always-turning-on. Moving django project to it.)
- Runs as a host to share files. (BTSync, verse Dropbox)
- Needs no maintance once after setup. Once it's broken, it is brain-less to be rebuilt the software. (0-day recovery.) (verse PC, which the storage, power suppile, display unit are easy to be broken, and making heat. PC needs to be setup again once a hardawre is replaced. Time consuming.)
- Plug and play, rich community support. 😍
- The official Raspbian image with SSH, git, VNC, btsync, dropbox and other system-admin-related stuffs.
- Setup a dynamic dns. (Therefore, I can connect the web apps when I am not on the local network.)
- Make a backup of the SD card before going to the 2nd stage.
- Preparation for running Django. Upgrade [python] to version 3.4 when need.
- pip, virtualenv & virtualenvwrapper (I need to learn both of them.)
- Setup a web server (nginx), database (MySQL), Django, phpmyadmin
- Make a backup of the SD card before going to the 3rd stage.
- Write the apps for the business.
- hobototes-data-centric apps.
- Automate business calculation.
- Wordpress for article storage.
- Doing some automation, using crontab, e.g. automate the database backup.
- Doing some experiment, such as Rails4, node.js, in spare time. 😢
- Speed things up
- Overclock from 800Mhz to 900Mhz
- Wordpress: install & test caching plugins
- Django: caching, optimize queries, profiling with Firefox F12
- VNC server
- BTSync
- Django within virtual environment
py34-django
- Mopidy
login: pi, je09
python3.4 alias to py
, located in /opt/python3.4/bin/python3.4
py34-django
is the main develop environment for hobototes-data-centric apps
nginx is started when boot up, or by sudo service nginx start
The default nginx document root is /usr/share/nginx/www
. I've changed it to /www/var
.
`mysql -uroot -ppassword`
pip freeze
exports a list of package in my environment. pip -r requirement.txt
to recreate the package in a new environment.
2014-08-06:
In the 1st boot up:
sudo raspi-config # setup overclock here.
Expand the disk, set locale, turn on SSH, reboot.
sudo apt-get install update && apt-get install upgrade
dpkg
And now it's ready to be customisation. For fun! (或是被折磨)
2014-08-06: Initial the system.
2014-08-09: Initial the system with a few system admin tools setup. Preparing to be a python web server next time. Backup as an image. Learning.
2014-08-12: Install Python3.4 from source. Setup virtualenv & wirtualenvwrapper.
2014-09-13: Install Mopidy. (One of my friends asked me about CuBox, and it's my first time to heard it on 2014-09-10.)
2014-09-10: Thinking of speed things up. (Mainly caching on Wordpress & Django.)
2014-09-16: Doing of speed things up. (Overclock to 900Mhz, cache on Django.)
2019-07-05: Restart the pi after 3 years!:heart:
2019-07-08: Install Python 3.7.1 from source.:smiley:
2020-06-10: Upgrade Python3.8b (beta) to Python3.8.
tightvncserver, vim-gtk, git,
transmission, chromium, Mopidy
htop, nmap, tree, p7zip, mtr, nmon, screen
(No Dvorak keyboard layout setup is needed, as VNC transfer my key layout to the pi. 😃) (7z on linux is 7za, where the package is called p7zip # )
Reality is not prefect. I intend to get everything up, then make it better.
- [f] sublime -> use Vim, or code locally commit over Git
- utorrent -> TBC
- file sync between
- btsync
- [f] Dropbox (no auto sync)-> TBC
- development environment
- upgrade to python3.4
- virtualenv
- virtualenvwrapper
- Django
- test: Django runs with python3.3+
- test: MySQL as backend
- MySQL
- MariaDB (MariaDB.org)
- PHP5-fpm
- let php knows mysql
- phpmyadmin
- bind phpmyadmin to mysql
- upgrade git
- import existing data (Word -> wordpress)
- TBC: rails
- ruby 2.1.0+
- rbenv / rvm
- rails 4.1+
- internal hosting
- nginx
- let nginx serves PHP (capture comm in port 9000)
- test phpmyadmin
- wordpress 3.9
- url rewritten in nginx
- cache wordpress
- django
- cache django
- TBC: mail server
- FTP server: vsftpd
- nginx
- automation / add some jobs to cron
- TBC: hardening security
- on wordpress
- on nginx
- ARP protect
- setup as a home theater
- playing movie
- playing music over network
ifconfig
hostname -I
curl ifconfig.me (from: http://www.commandlinefu.com/commands/browse/sort-by-votes)
ref: http://www.raspberrypi.org/documentation/troubleshooting/hardware/networking/ip-address.md
who
w
arp -a
SSH is not enabled by default in Raspbian, so you will have to do it before you boot the card for the first time (for headless setup).# # Or enable it via raspi-config
(with keyboard).
After the installation, go to boot partition boot/
and place a file named ssh
(no extension).
touch ssh
raspi-config
# reserve a fixed ip for pi, e.g. 192.168.0.101, for always on connection
ssh [email protected]
ref: SSH using Linux or Mac OS - Raspberry Pi Documentation
sudo apt-get install screen
Here are some shortcut of screen:
ctrl-a c:创建一个新的 Shell
ctrl-a ctrl-a:在 Shell 间切换
ctrl-a n:切换到下一个 Shell
ctrl-a p:切换到上一个 Shell
ctrl-a 0...9:同样是切换各个 Shell
ctrl-a d:退出 Screen 会话
sudo apt-get install tightvncserver
tightvncserver
vncserver :1 -geometry 1920x1080 -depth 24
Creating default startup script /home/pi/.vnc/xstartup
Starting applications specified in /home/pi/.vnc/xstartup
Log file is /home/pi/.vnc/raspberrypi:1.log
On the clien side, vncviewer, 192.168.0.101:1
[NoIP for accessing Pi over internet. In fact, You no need to set up static IP at your Raspberry. Almost all home routers has option to bind MAC number of you network card with IP. If you do so, you'll get the same IP adress after every reboot.]
ref: http://www.raspberrypi.org/documentation/remote-access/vnc/README.md http://computers.tutsplus.com/tutorials/take-control-of-your-raspberry-pi-using-your-mac-pc-ipad-or-phone--mac-54603
By default, your Raspberry Pi automatically mounts some of the popular file systems such as FAT, NTFS, and HFS+ at the /media/pi/<HARD-DRIVE-LABEL>
location.
If you want to mount your storage device to another location, you should set up your storage device so that it always mounts to a specific location of your choice. You must mount it manually.
If your storage device uses an NTFS file system, you will have read-only access to it. If you want to write to the device, you can install the ntfs-3g driver:
sudo apt-get update
sudo apt-get install ntfs-3g
To format a disk as ext4 filesystem:
df -h # find your drive here, e.g. `sda1`
sudo umount /dev/sda1 # replace sda1 with your drive name !
sudo mkfs.ext4 /dev/sda1 -L BTSync # replace sda1 with your drive name !
Mount the drive:
sudo mount /dev/sda1 /mnt/usbdrive
Verify that the storage device is mounted successfully by listing the contents:
ls /mnt/usbdrive
Edit fstab
file to mount the drive on startup automatically. Add following to beginning of /etc/fstab
:
sudo vim /etc/fstab
/dev/sda1 /mnt/usbdrive ext4 defaults 0 0
Ref:
- External storage configuration - Raspberry Pi Documentation - How to Read/Write NTFS file system, auto mount at startup
- https://github.com/johnantoni/beaglebone-black/blob/master/setup/format-and-mount-usb.md
- http://blog.bittorrent.com/2014/08/05/sync-stories-dual-backup-with-a-beaglebone-black-and-virtual-private-server/
- http://magnatecha.com/automatically-mount-a-drive-when-linux-boots/
Git
& python
& python3
are already on the system.
sudo apt-get install vim-gtk (or vim-gnome)
gvim (vim can run over ssh)
Considering to use Vim instead of SublimeText because of:
- Vim can be run over SSH. 😃
- SublimeText has not release an ARM version. I can run the software without source...
Maybe, I can write code on my notebook, and then "sync" the code oven git, maybe, maybe git for deployment.
http://www.sublimetext.com/ http://code.tutsplus.com/articles/from-ftp-to-git-a-deployment-story--net-25982
cd ~/BTSync
./btsync (or ./btsync --config ./sync.conf)
On the local,
127.0.0.1:8888
However, it is more pratical to login to it over network (192.168.0.101:8888) as I can paste the sync token. :)
You may want to set btsync to start when you boot your Raspberry Pi. To do that we will place a script in /etc/init.d/ and then register it with update-rc.d.
sudo nano /etc/init.d/btsync
Paste the following code in the script:
#! /bin/sh
# /etc/init.d/btsync
#
# Carry out specific functions when asked to by the system
case "$1" in
start)
/home/pi/.btsync/btsync
;;
stop)
killall btsync
;;
*)
echo "Usage: /etc/init.d/btsync {start|stop}"
exit 1
;;
esac
exit 0
Then change the permissions, test, and register it to run at boot:
sudo chmod 755 /etc/init.d/btsync
sudo /etc/init.d/btsync start # test that the script starts
sudo /etc/init.d/btsync stop # test that the script stops
sudo update-rc.d btsync defaults
Or, I can make it to be configured to auto-run after system start up:
sudo nano /etc/apt/sources.list.d/btsync.list
past following lines:
deb http://debian.yeasoft.net/btsync wheezy main contrib non-free
deb-src http://debian.yeasoft.net/btsync wheezy main contrib non-free
Control + x to close/save the file.
sudo apt-get update
sudo apt-get install btsync
Config: Default Sync instance? Yes
ref:
ref in general:
- http://blog.bittorrent.com/2013/08/20/sync-hacks-how-to-sync-without-data-loss-using-btsync-raspberry-pi/ <-- this one is useful. Place a script in
/etc/init.d/
and then register it withupdate-rc.d
. - http://blog.bittorrent.com/2014/08/05/sync-stories-dual-backup-with-a-beaglebone-black-and-virtual-private-server/ shows using BTSync with BeagleBone in a founded business.
- http://blog.bittorrent.com/2013/05/23/how-i-created-my-own-personal-cloud-using-bittorrent-sync-owncloud-and-raspberry-pi/
- http://reustle.io/blog/btsync-pi
- http://www.instructables.com/id/Redundant-cloud-storage-with-a-friend-and-a-Raspbe/?ALLSTEPS
- http://www.cyberciti.biz/open-source/30-cool-best-open-source-softwares-of-2013/
Dropbox doesn't provide an ARM package on Linux nor source code. Therefore, I need to find a 3rd-party solution on pi.
Google: raspberry dropbox
There are 2 solutions: Bash dropbox uploader or Drop2PI. I pick Bash dropbox uploader (it's the uploader's author site ) as it is the most popular (a.k.a community support).
git clone https://github.com/andreafabrizi/Dropbox-Uploader/
$chmod +x dropbox_uploader.sh
$./dropbox_uploader.sh
After the apps created, paste the following url to browser to activate the apps.
https://www2.dropbox.com/1/oauth/authorize?oauth_token=dOdcCJGpKpKjHDkz
Check the security page to revoke the secret token in future.
To automate the jobs of it, rather then typing commands again and again, use cron job. The setup refer to the project on Github.
ref:
- http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=21617
- https://github.com/andreafabrizi/Dropbox-Uploader
- http://raspi.tv/2013/how-to-use-dropbox-with-raspberry-pi
Both of them help me interactive Dropbox in cli but not automate the sync. I shall find a better solution later.
- Google: auto sync with dropbox raspberry
oxmplayer fx.mp3
ref: http://omxplayer.sconde.net/
As simple as possible, I ssh into Pi and then play music with oxmplayer.
see also: 将树莓派打造成音乐播放服务器
Turn Raspberry Pi into an audiophile audio source. Audiophile-quality music playback. Firstly this idea is Kin's question: cubox CAS source -> Google: cubox CAS source
Power supply -> Raspberry -> DAC -> Speaker
Need to use 線性電源 liner power supply (otherwise, 聲硬、音場窄、非常數碼欠自然): 高低伸延有良好改善、音場沒有之前咁平面同窄、增強了三維空間感、動態低頻既表現亦提升了不少
-
Google: Raspberry music player -> http://www.pimusicbox.com/ is a Headless audio player based on Mopidy (no need for a monitor), streaming music from Spotify, SoundCloud, Google Music, Podcasts (with iTunes, gPodder directories), MP3/OGG/FLAC/AAC, Webradio (with TuneIn, Dirble directories), Subsonic, Soma FM. - See more at: http://www.pimusicbox.com/#sthash.3z0vOWIV.dpuf
-
Google: Raspberry CAS source -> headfi.org
-
Google: cubox CAS source -> http://obeediy.blogspot.hk/search/label/CAS
-
Make your Raspberry Pi a Hi-Fi player (from Google: Raspberry music player )
http://www.runeaudio.com/about has a good depict on whan an linux distro on Pi does as a CAS
new ideas:
- MPD (music player daemon)? (Google: post76 mpd, Google: post76 mpd 集中營)
- i2s (firstly seen in Raspberry Pi i2s DAC: why this sounds so good - Volumio)
CAS OS:
- RuneAudio
- volumio (is a porting of RaspyFi)
- RaspyFi, which is aimed to notorious Voyage-mpd distro. See the post on headfi.org for comments. (from Google: Raspberry CAS source)
- http://www.head-fi.org/t/699130/volumio-the-free-hi-fi-linux-distribution
- Pi MusicBox
- Archphile (from: Google: volumio root) (or from: Google: audiophile linux)
- piCorePlayer (from: Raspberry Pi + RuneAudioで音楽を鳴らしてみる )
- MuBox
- http://www.libelium.com/ -> Meshlium
OS for 64bit x86 PC:
- Audiophile Linux v3, Arch Linux based, need to be installed on hdd
- Daphile , Debian based, run from USB flash drive as an image. The sound is the best amoung the 3.
- Voyage-linux is made by a HKer. Runs an ordinary desktop linux. The sound is not as good as Audiophile Linux nor Daphile
All of them turn Raspberry Pi into a headless music player, plus turning CuBox, UDOO, Beaglebone Black too.
RuneAudio and Volumio is soso similar, sharing a similar UI. So, what's the difference and the relationship between them?
- Google: runeaudio and volumio
- Google: runeaudio vs volumio
- http://www.hydrogenaud.io/forums/
- Baidu: runeaudio -> 树莓派组建无线播放器 — 树莓派也玩hifi
- Baidu: audiophile linux -> Audiophile Linux
- Baidu: audiophile raspberry
- Google: raspberry music player -> The image is around 227MB in (compressed) size; 950MB uncompressed Web Client for Mopidy Music Server and the Pi MusicBox
- Google: raspberry music server -> http://lifehacker.com/how-to-turn-a-raspberry-pi-into-a-private-streaming-mus-1583221462
- Google: raspberry audio image -> Model B+ Audio Experiences
- Google: raspberry audio image -> Raspberry Pi: Mopidy on a credit card
- http://www.raspberrypi.org/tag/music/
- Baidu: raspyfi
- Google: audiophile Windows -> Fidelizer
- http://www.head-fi.org/f/ -> search
- http://www.diyaudio.com/forums/ -> search
- Google: audiophile sound card linux
- Google: intel-based audiophile
- Google: 64bit x86 audiophile
- Google: Audiophile Windows 7
- HiFiBerry is a DAC for Raspberry Pi
- Google: runeaudio root -> I wanna find a way to ssh to it. Google tell me more about this project in someones' mind.
- Google: volumio root -> runeaudio root? again, in volumio
- Hydrogenaudio Forums - Audio Hardware > Audio quality on SBCs like RPi, Built-in analog out on single-board computers any good?
- Google: runeaudio root
- Google: cubox os
- http://www.solid-run.com/archive/mw/
- from: Google: mubox mopidy
- Google: cubox mpd
2014-10-08: I learnt these when I set up MuBox, then later Mopidy, on CuBox of my friend.
`lsmod`
show the status of modules in the Linux Kernel. From: Google: cubox mubox -> http://testing.post76.com:7180/x2/forum.php?mod=viewthread&tid=164254
`lsusb`
list USB devices. From: RuneAudio Forum - No output on SPDIF with external USB card
`aplay -l`
to list the device
`aplay -L`
to list the device, and combine use with speaker-test
`amixer`
a console sound mixer
`speaker-test`
-
speaker-test
- from: Google: xmos x20 usb audio linux driver -> RuneAudio Forum - No output on SPDIF with external USB card
aplay-L speaker-test -Ddefault:ALSA -c 2
Music Player:
Power supply -> Raspberry (-> steaming ) -> the device on hand -> Speaker
- http://andrewkelley.me/post/quest-build-ultimate-music-player.html, from: 将树莓派打造成音乐播放服务器
- http://www.crazy-audio.com/projects/raspberry-pi-for-audio-distribution/
music server :
- http://groovebasin.com/
- MPD (music player daemon)
- The ultimate MPD guide (from: Google: mpd decode error)
Google: raspberry music server -> Mopidy is the 1st link, Pi MusicBox second. Google: raspberry audio image -> Raspberry Pi: Mopidy on a credit card
Mopidy is an extensible music server written in Python. It can be installed on Pi, Debian, Ubuntu, Arch Linux, Mac OS.
Mopidy plays music from local disk, Spotify, SoundCloud, Google Play Music, and more. You edit the playlist from any phone, tablet, or computer using a range of MPD and web clients.
Load the IPv6 kernel module now:
sudo modprobe ipv6
Add ipv6 to /etc/modules to ensure the IPv6 kernel module is loaded on boot:
echo ipv6 | sudo tee -a /etc/modules
Since I have a HDMI cable connected, but want the sound on the analog sound connector, I have to run:
sudo amixer cset numid=3 1
to force it to use analog output. 1 means analog, 0 means auto, and is the default, while 2 means HDMI. You can test sound output independent of Mopidy by running:
aplay /usr/share/sounds/alsa/Front_Center.wav
If you hear a voice saying “Front Center”, then your sound is working.
Add the archive’s GPG key:
sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/mopidy.list
Install Mopidy and all dependencies:
sudo apt-get update
sudo apt-get install mopidy
Finally, you need to set a couple of config values, and then you’re ready to run Mopidy.
When a new release of Mopidy is out, and you can’t wait for you system to figure it out for itself, run the following to upgrade right away:
sudo apt-get update
sudo apt-get dist-upgrade
Need to config Mopidy. Some modules should be turn on, such as http
, local
in order to use it over network.
A config file is created automatically when the 1st run of Mopidy. Therefore, I run it by issue a mopidy
command, then I edit the generated configure file:
vi ~/.config/mopidy/mopidy.conf
Change the hostname to the location of the pi (Mine is 192.168.0.101
), and as I put music in ~/Music
:
[http]
enabled = true
hostname = 192.168.0.101 # or :: for listen to all
port = 6680
static_dir =
zeroconf = Mopidy HTTP server on $hostname
[local]
enabled = true
library = json
media_dir = ~/Music
data_dir = ~/Music/mopidy/local
playlists_dir = ~/Music/mopidy/local/playlists
scan_timeout = 1000
scan_flush_threshold = 1000
excluded_file_extensions =
.directory
.html
.jpeg
.jpg
.log
.nfo
.png
.txt
Each time I change the music files in the ~/Music
folder (add, delete, etc), I need to let Mopidy know it:
mopidy local scan # see `mopidy --help`
To start Mopidy, simply open a terminal and run:
mopidy
For a complete reference to the Mopidy commands and their command line options, see mopidy command.
When Mopidy says MPD server running at 127.0.0.1:6600 it’s ready to accept connections by any MPD client. Check out our non-exhaustive MPD clients list to find recommended clients.
To stop Mopidy, press CTRL+C
in the terminal where you started Mopidy.
Mopidy will also shut down properly if you send it the TERM signal, e.g. by using pkill
:
pkill mopidy
- HTTP clients
- Web Client for Mopidy Music Server and the Pi MusicBox
- Moped - Web Client for Mopidy (from: http://docs.mopidy.com/en/latest/ext/web/)
- Mopify
- MPD
- http://www.ympd.org/
See also https://www.kickstarter.com/projects/fon/gramofon-modern-cloud-jukebox, which is shown on the homepage of http://www.mopidy.com/
Run the following commands to check if you music device is set to mute:
amixer
(Note: you may use command amixer -c 1
if you have USB DAC, where -c 1
specifies 2nd sound device. Use command cat /proc/asound/cards
or aplay -l
to list all sound devices detected)
If you see the Playback is set to [off], the music output is muted. You can use alsamixer
tools to unmute (by press ‘M’ key to toggle mute/unmute for each control). Or you can simply run the following commands:
(Note: may need to pass -c 1
after amixer command to specify 2nd sound device, e.g. USB DAC):
# amixer scontrols|sed -e 's/^Simple mixer control//'|while read line;do amixer sset "$line" unmute;done
Simple mixer control 'XMOS Clock Selector',0
Capabilities: pvolume pswitch penum
Playback channels: Front Left - Front Right
Limits: Playback 0 - 127
Mono:
Front Left: Playback 127 [100%] [0.00dB] [on]
Front Right: Playback 127 [100%] [0.00dB] [on]
Simple mixer control 'XMOS Clock Selector',1
Capabilities: pvolume pvolume-joined pswitch pswitch-joined penum
Playback channels: Mono
Limits: Playback 0 - 127
Mono: Playback 127 [100%] [0.00dB] [on]
ref:
- Read The Hitchhiker’s Guide to Python! first, and Python Packaging User Guide second. (from: How to get Django )
- Learn Python the Hard Way (Google: virtualenv project structure) provides a rich set of reading materials too.
- The Hitchhiker’s Guide to Python! is also from https://github.com/kennethreitz/python-guide
- Python Packaging User Guide is also from https://github.com/pypa/sampleproject
- http://pydanny.com/experiences-with-django-python3.html
sudo apt-get install python-pip
pip3
sudo apt-get install python3-pip
First at all. See the Django 1.7's requirement, as I mainly develop the hobototes-data-centric apps on Django 1.7. (It works with Python 2.7, 3.2, 3.3)
Since the Python3 ships with Pi is version3.2, it is better to upgrade it to version 3.3 before installing Django 1.7 (currently 1.7-rc2). I have to upgrade it from source code, and put it into a new place rather than over-write the python shipped with Pi officially (To avoid system conflict.) Once it was successed, I could install Django1.7+ with virtualenv, doing test. Once the test was success, I could install MySQL and Nginx too.
A notes I bear in mind:
System updates break everything Installing apt packages can overwrite pip-installed things Version conflicts Distribution upgrades are unpredictable chaos. Seriously. I've lost hair to these.
Update 2014-10-03:
I've just joined Reddit, and searched "Django" and found it:
- http://www.reddit.com/r/django/comments/exfwh/django_devs_whats_your_development_environment/
- http://www.reddit.com/r/django/comments/vhy4d/what_are_your_favorite_django_apps/
- http://www.reddit.com/r/django/comments/1rfgse/what_django_extensions_do_you_use_most_often/
Google: django with python 3
- http://askubuntu.com/questions/401132/how-can-i-install-django-for-python-3-x
- http://stackoverflow.com/questions/20251562/how-to-install-django-for-python-3-3 facing the same problem of mine
- https://docs.djangoproject.com/en/dev/topics/python3/
Seems I have to complie 3.3 (or 3.4) from source. Therefore, Google: how to install python 3.3
- http://askubuntu.com/questions/244544/how-do-i-install-python-3-3 shows how the others compile it from source (Google: install python3 on linux)
Google: how to install python 3.4
OK, head to Python.org and get the latest python.
wget https://www.python.org/ftp/python/3.4.1/Python-3.4.1.tar.xz
xz -d Python-3.4.1.tar.xz
tar -xf Python-3.4.1.tar
cd Python-3.4.1
./configure
make
make test
sudo make install
The build process consists in the usual, but...
Warning: make install can overwrite or masquerade the python3 binary. make altinstall is therefore recommended instead of make install since it only installs exec_prefix/bin/pythonversion.
[#](https://docs.python.org/3.4/using/unix.html#building-python)
OK, not make install
but make altinstall
, plus --prefix
--prefix argument to the configure script. (run ./configure --help
to find out the options) #
OK. For example, I do not have any Python installations on my system and I want to install 3 versions: 2.7, 3.3 and 3.4. I want to make 2.7 the primary installation (as python) and all the others as secondary (as python3.3 and python3.4) installations. I would install the primary with:
sudo make install
and install both the other versions with:
sudo make altinstall
The produced programs would be python (2.7), python3.3 (3.3) and python3.4 (3.4).
OK, accroding to http://askubuntu.com/questions/244544/how-do-i-install-python-3-3,
Assump different Python versions from 2.4 to 3.2 living happily in /opt.
I need C compiler and other stuff to compile Python
sudo apt-get install build-essential
(Update: If errors come with mkvirtualenv --python=/opt/python3.4/bin/python3.4 test
when creating the environment, this is my fault not compiling python completely. Try sudo apt-get install build-essential python-dev
too and build again.)
SQLite libs need to be installed in order for Python to have SQLite support.
sudo apt-get install libsqlite3-dev
sudo apt-get install sqlite3 # for the command-line client
sudo apt-get install bzip2 libbz2-dev
cd Python-3.3.0
./configure --prefix=/opt/python3.3
make && sudo make install
Test if it worked:
/opt/python3.3/bin/python3
import sqlite3 # if sqlite3 package is installed on system
Some nice touches to install a py command by creating a symlink:
mkdir ~/bin
ln -s /opt/python3.3/bin/python3.3 ~/bin/py
Alternatively, you can install a bash alias named py instead:
echo 'alias py="/opt/python3.3/bin/python3.3"' >> .bashrc
Or, my simple solution is the use of altinstall
, accroding to the 3.4 README:
cd Python-3.3.0
./configure
make && sudo make altinstall
(It takes about 15 mins. Hogging 100% CPU.)
Test if it worked:
python3.4
**prefer** :heart:
I've tested both the methods above. I prefer the 1st one. No messy in /usr/local
.
(2017-02-09 update: for a missing zlib
module in python : install zlib-1g-dev
on system
sudo apt-get install zlib-1g-dev
And then recomplie python3 by issuing ./confiure
, make
, make install
.
To test if it is successfully complie, execute python3, and then
import zlib
)
(Google: python missing zlib -> http://stackoverflow.com/questions/17899291/should-i-re-install-python-again-for-zlib-module)
I try to upgrade Python to Python 3.7.1, which is the latest stable version before version 3.8.
Google: raspberry pi python update -> Installing Python 3.6 on Raspbian. it's almost same as what I did with Python 3.4.
- Install the required build-tools (some might already be installed on your system).
$ sudo apt-get update
$ sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev
If one of the packages cannot be found, try a newer version number (e.g. libdb5.4-dev instead of libdb5.3-dev).
- Download and install Python 3.7.1. When downloading the source code, select the most recent release of Python 3.6, available on the official site. Adjust the file names accordingly.
$ wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
$ tar xf Python-3.7.1.tar.xz
$ cd Python-3.7.1
$ ./configure
$ make
$ sudo make altinstall
- Optionally: Delete the source code and uninstall the previously installed packages. When uninstalling the packages, make sure you only remove those that were not previously installed on your system. Also, remember to adjust version numbers if necesarry.
$ sudo rm -r Python-3.7.1
$ rm Python-3.7.1.tar.xz
$ sudo apt-get --purge remove build-essential tk-dev
$ sudo apt-get --purge remove libncurses5-dev libncursesw5-dev libreadline6-dev
$ sudo apt-get --purge remove libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev
$ sudo apt-get --purge remove libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev
$ sudo apt-get autoremove
$ sudo apt-get clean
This guide is pretty much taken from the following tutorial: https://liudr.wordpress.com/2016/02/04/install-python-on-raspberry-pi-or-debian/ and https://gist.github.com/BMeu/af107b1f3d7cf1a2507c9c6429367a3b
//End of 2019-07-08.
体验linux,双系统了解下 - 知乎 -> 告别win10,拥抱linux - 小歪的博客 -> linux下安装python3.6 - 小歪的博客
//End of 2020-09-16.
I try to upgrade Python3.8b to Python3.8.
Google: ubuntu update python3.8 from beta
I can fire it up in 3 lines of command but I will tell how to do it in steps too.
$ sudo apt update && sudo apt remove python3.8 && sudo apt autoremove
$ which python3.8 # It should show nothing.
$ sudo apt install python3.8
- Remove the Python3.8b
$ sudo apt update
$ sudo apt remove python3.8
- Check if Python3.8b exists.
$ which python3.8
- Remove system configure files of Python3.8b
$ sudo apt purge python3.8* # not `sudo apt purge python*`
$ sudo apt autoremove
$ sudo apt update
- Check if Python3.8b exists and it should already gone.
$ which python3.8
- Install Python3.8
$ sudo apt install python3.8
// End of 2020-06-10.
Update:
Problem: If I fail, how can I remove python3.4?
Google: how to remove python3.4
Since I install it from source, apt-install has no idea that it exists.
The easiest way (as most makefiles don't have an uninstall target) is to run
make install
again in my 3.3 source directory and capture what it sticks where and then remove them. ("make uninstall" usually don't work.)
The cheaper way would be to
rm /usr/local/bin/python3
and probably anything else in /usr/local/bin/py* including symlinks to various parts of the suite.
Google: raspberry pi virtualenv
Virtualenv gets you some common Python tools (distribute for packaging, pip for easy installation/removal of packages & virtualenv for nice isolated environments)
# sudo apt-get install python-dev
# curl -O http://python-distribute.org/distribute_setup.py
# python distribute_setup.py
# curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
# python get-pip.py # @see Setup pip: sudo apt-get install python-pip
sudo pip install virtualenv
Then, we can create an isolate environment: (assume I wanna the environment "ENV" to be placed at home)
cd ~
virtualenv ENV
cd ENV
source bin/activate
ref:
- http://raspberry.io/wiki/how-to-get-python-on-your-raspberrypi/
- http://flask.pocoo.org/docs/installation/#virtualenv tell me why use virtualenv to isolate the development enviornment from system
- http://dormousehole.readthedocs.org/en/latest 这是 Flask 0.10 版文档的中文翻译 (from: Baidu: flask)
- http://www.raspberrypi.org/forums/viewtopic.php?t=7208&p=403771
- https://virtualenv.pypa.io/en/latest/
-p path/to/python/version
I could use a single virtualenv for both python version, just use the -p path/to/python/version
or --python=path/to/version
flag to specify which version to use for the creation of the virtual environment.
ref:
Google: virtualenv disable
deactivate
ref:
- https://www.hackerschool.com/blog/14-there-is-no-magic-virtualenv-edition
- http://docs.python-guide.org/en/latest/dev/virtualenvs/
- https://virtualenv.pypa.io/en/latest/
virtualenvwrapper is a set of extensions to Ian Bicking's virtualenv tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies.
pip install virtualenvwrapper
export WORKON_HOME=~/Envs
mkdir -p $WORKON_HOME
source /usr/local/bin/virtualenvwrapper.sh
mkvirtualenv env1
In order to make the virtualenvwrapper's environment available afterward, I should write the export
and source
exactly showning above in my ~/.bashrc
.
Some useful commands:
lsvirtualenv
lssitepackages
cdvirtualenv
cdsitepackages
Switch between environments:
workon env2
To deactivate is still the same:
deactivate
To delete:
rmvirtualenv env1
ref:
- http://virtualenvwrapper.readthedocs.org/en/latest/
- http://docs.python-guide.org/en/latest/dev/virtualenvs/
pip install django == 1.7
However, the version 1.7 is still in beta and not available in pip as a released package. Therefore, I need to manually setup with source code.
Use virtualenv & virtualenvwrapper to make a clean room first.
which python3.4
No package be shown? coz my python3.4 is called py
mkvirtualenv --python=/usr/bin/python3 py3-django
**Prefer**
mkvirtualenv --python=/opt/python3.4/bin/python3.4 py34-django
(or virtualenv only: cd ~ virtualenv py3_django cd py3_django source bin/activate
pip install django # change it to the version you want
cd ~/site
)
There are 3 ways to install Django, according to How to install Django.
cd Downloads
wget https://github.com/django/django/zipball/master # get the latest development version
tar xzvf Django-1.7.tar.gz
cd Django1.7
sudo python setup.py install
(or
pip install https://www.djangoproject.com/download/1.7c2/tarball/
**Prefer**
❤️
If I installed Django using pip or easy_install previously, installing with pip
or easy_install
again will automatically take care of the old version, so you don’t need to do it myself.
)
(or
git clone git://github.com/django/django.git django-trunk
sudo pip install -e django-trunk/
)
Test it:
cd ~ && mkdir sites
django-admin.py --version
django-admin.py startproject hobototes-data-centric
cd hobototes-data-centric
python manage.py runserver
Now, go to itstall MySQL. 😃
(Update: django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
This is caused by no mysql to python driver in my virtual environment.
Google: django virtualenv no module named mysqldb
need to install mysql-python
if use mysql as backend, either 1 of the 5, suggested by the Stack Overflow community:
sudo apt-get install python-mysqldb
sudo apt-get install libmysqlclient-dev
sudo apt-get install python-dev
pip install mysql-python # but `no module named 'Configparser'`, and the `ConfigParser` does not support python3
easy_install mysql-python
💔 None of them works because I use Python3, not python 2.
Then, I Google: pip install mysql-python no module named 'Configparser'
🙏
pip install mysqlclient
in my python3.4 virtualenv after
sudo apt-get install python-dev libmysqlclient-dev
which is obviously specific to ubuntu/debian, but I just wanted to share my success :) #
🙏
Last resort: simply, create a new virtualenv wyth system site-packages included by using the --system-site-package
switch #
Update 2:
If all about fails, I might try PythonAnywhere :
pip install --user https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-1.1.6.tar.gz
Then, update your settings.py to use the oracle django backend, "mysql.connector.django":
DATABASES = {
'default': {
'ENGINE': 'mysql.connector.django',
...
Update3:
To install mysqldb under virtualenv, you need to be able to compile the mysql module, which means you need all the general compliation tools, the python header libraries and the mysql client ones (Under ubuntu/debian these are packages build-essential, python-dev & libmysqlclient16-dev ), at this point pip install MySQL-python should work, and from there you should be able to use mysql within django.
ref too:
2016-02-15 update:
Firstly, the community edition is MariaDB.org, not MariaDB.com (for enterprise).
As of the version of repository is MariaDB 5.5.47, not the 10, I have to install it myself rather than issue simply:
sudo apt-get install mariadb-server
MariaDB APT and YUM Repository Configuration Generator
- Add MariaDB Repositories
Here are the commands to run to install MariaDB on your Mint system:
sudo apt-get install software-properties-common sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db sudo add-apt-repository 'deb http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu trusty main'
- Update System Repository Index
Once the key is imported and the repository added you can install MariaDB with:
sudo apt-get update
-
Install MariaDB
sudo apt-get install mariadb-server
See Installing MariaDB .deb Files for more information and for instructions on installing MariaDB Galera Cluster.
You can also create a custom MariaDB sources.list file. To do so, after importing the signing key as outlined above, copy and paste the following into a file under /etc/apt/sources.list.d/(we suggest naming the file MariaDB.list or something similar), or add it to the bottom of your /etc/apt/sources.list file.
# MariaDB 10.1 repository list - created 2016-02-15 09:03 UTC
# http://mariadb.org/mariadb/repositories/
deb http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu trusty main
deb-src http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu trusty main
If the above does not work, (sudo apt-get install mariadb-server --dry-run
shows that the version will be installed is 5.5.47) it should be the host does not update. So, I retry it with an USA host (e.g. "DigitalOcean - New York, US".) And then it is going to install a version 10.1 now.
- Start MariaDB Service
# For SysVinit Systems
$ sudo service mysql start
# For systemd Systems #
$ sudo systemctl start mysql.service
- How to access MariaDB
# mysql -u root -p
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.11-MariaDB-1~jessie mariadb.org binary distribution
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
- How to Upgrade MariaDB
Use the below command to Upgrade MariaDB service for new release
$ sudo apt-get install --only-upgrade mariadb-server
Also read about phpMyAdmin Installation and configuration which will help you to manage the MariaDB database on Web without headache.
Some more reference:
- https://mariadb.org/mariadb-10-1-11-now-available/ -> MariaDB APT and YUM Repository Configuration Generator
- Google: how to install mariadb 10.1 on linuxmint 17.3 -> Install MariaDB 10.1.11 & Upgrade on Ubuntu, Debian & Mint
http://computers.tutsplus.com/tutorials/how-to-install-ruby-on-rails-on-raspberry-pi--cms-21421
** Need Nginx to serve PhpMyAdmin and Django and Wordpress. All of them need MySQL-server too.**
Tutorial in For your Pi! provides the instruction on setting up Nginx. http://raspberrypihelp.net/tutorials/24-raspberry-pi-webserver Nginx, MySQL, PHP5-fpm, PHPMyAdmin <- All-in-one, this one useful ** I only follow this tutorial to install Nginx, MySQL, PHP5-fpm, PHPMyAdmin ** till the middle of it.
Installing Nginx With PHP5 (And PHP-FPM) And MySQL Support (LEMP) On Ubuntu 12.04 LTS generally speak how to install nginx with PHP4 (PHP-FPM) and MySQL on Ubuntu 12.04, from Google: php5-fpm, when I wanna know what is that, after reading pi's official document.
Running (almost) anything on Nginx with uWSGI - metz.log tells me what is uWSGI, a technology in python equivalent to PHP-FPM in php. From Google: php-fpm in python
Do port forwarding to route the incoming traffic to Pi.
Google: 啟用DDNS D-link
- http://changyang319.com/archives/624
- http://changyang319.pixnet.net/blog/post/32287773
- http://pitown.blogspot.hk/2013/11/routing-web-traffic-to-raspberry-pi.html (from: http://magnatecha.com/things-i-do-with-my-raspberry-pi/)
- http://portforward.com/ (from: http://www.tightvnc.com/faq.php)
sudo apt-get install nginx
Test it:
sudo service nginx start
or
/etc/init.d/nginx start
The nginx configuration is in /etc/nginx/nginx.conf
which we open now:
Nginx use a modular configuration files. /etc/nginx/nginx.conf
is the main configuration of Nginx, I've never touch it. Instead, I edit:
sudo vi /etc/nginx/sites-available/default
Therefore, my custom setting will not be over-written when upgrade the nginx. 😄
The configuration is easy to understand (you can learn more about it here: http://wiki.nginx.org/NginxFullExample and here: http://wiki.nginx.org/NginxFullExample2)
Test it:
http://127.0.0.1
(Add a line of <? echo phpinfo();
in /usr/share/nginx/www/index.php
, to see if it serves php, later in the server setup.)
Plus, prepare folders to hold the web documents:
sudo chown -R pi:pi /var/www
sudo chmod -R 755 /var/www
mkdir /var/www/example.com
ref:
- http://www.raspberrypi.org/documentation/remote-access/web-server/README.md
- http://www.raspberrypi.org/documentation/remote-access/web-server/nginx.md
- http://www.howtoforge.com/installing-nginx-with-php5-and-php-fpm-and-mysql-support-lemp-on-ubuntu-12.04-lts
- http://blog.mattwoodward.com/2013/01/setting-up-django-on-raspberry-pi.html
- Install Nginx on raspbian and replace Apache
- Raspbian France: Installer Nginx Raspbian, et accélérez votre serveur web Raspberry
sudo apt-get install phpmyadmin
in the config screen, skin both apache and lighttpd, as I use Ngnix myself.
dbconfig-common
info about config phpmyadmin: /usr/share/doc/phpmyadmin
,
dbconfig-common: writing config to /etc/dbconfig-common/phpmyadmin.conf
Google: raspberry nginx phpmyadmin
(also: Google: raspberry nginx)
I put them below as the ranking:
- http://magnatecha.com/set-up-phpmyadmin-with-nginx/. make nginx listens to port 81 and where phpmyadmin is localed in
/usr/share/phpmyadmin
- http://raspberrypihelp.net/tutorials/24-raspberry-pi-webserver again.
- http://xmodulo.com/2014/04/lightweight-web-server-raspberry-pi.html demos on nginx and lighttpd: create a sybolmic link
sudo ln -s /usr/share/phpmyadmin /var/www/phpmyadmin
to the document root and make no change on the server config - http://www.howtoforge.com/running-phpmyadmin-on-nginx-lemp-on-debian-squeeze-ubuntu-11.04
- http://www.raspipress.com/2014/06/tutorial-install-wordpress-on-a-raspberry-pi-using-nginx/ has a 3 part series on installing PHP & nginx on raspberry
From #1:
server {
listen 81;
server_name localhost;
root /usr/share/phpmyadmin;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^/(.+)$ /index.php?url=$1 last;
break;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
I put the code into the http
section, and head to http://192.168.0.101:81
... it works!
From #2:
sudo chown -R pi:pi /var/www
sudo chmod -R 755 /var/www
mkdir /var/www/example.com
This is the most useful part, and the configure is a bit complicated, which I skip.
From #3:
After Nginx up:
server {
listen 80;
server_name $domain_name;
root /var/www;
index index.html index.htm;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}
After installing php5-fpm
and php-apc
:
server {
listen 80;
server_name $domain_name;
root /var/www;
index index.html index.htm;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location ~\.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
try_files $uri =404;
include fastcgi_params;
}
}
Therefore, I decide to put PHPMyAdmin on port 81, and other pages in /var/www
on port 8001.
server {
listen 81;
server_name localhost;
root /usr/share/phpmyadmin;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^/(.+)$ /index.php?url=$1 last;
break;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
server {
listen 8001;
server_name localhost;
root /var/www/;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^/(.+)$ /index.php?url=$1 last;
break;
}
location ~ .php$ {
autoindex on;
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
Test the config before reload the server: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
sudo service nginx configtest
additional ref: @see the supplymentory
sudo apt-get install mysql-server
set a root password.
Test:
mysql -uroot -ppassword
/usr/libexec/mysqld --verbose --help 1>/dev/null
We can make PHP5 work in nginx through PHP-FPM (PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites) which we install as follows:
apt-get install php5-fpm
PHP-FPM is a daemon process (with the init script /etc/init.d/php5-fpm) that runs a FastCGI server on port 9000.
ref:
http://www.raspberrypi.org/documentation/usage/wordpress/README.md
Since Nginx can be configured to read web apps in any directory (e.g. It communites with PHP via port 9000, with PHP5-fpm), I consider to place Wordpress in /var/www/ , following the convention made by Apache.
I've try to visit the wordpress site outside my local network. It works! However, the style & image are broken.
I should fire up the database, and edit home_url
to the domain which the outsider see, from 192.168.0.101:8008
to the DDNS I own. It works now! (Wordpress marks my ip as 192.168.0.101
since I setup it on 192.168.0.101
.)
I've try to upload an image in a post, an error occurs: permission error
. This's a problem on linux folder permission. 777
is the last resort coz it make the folder "open to all people"; 755
seems DOES NOT WORK unluckily in this situation.
Best practice is to keep permissions as tight as possible. Using 777 for testing is legitimate IMO, but there should be no need to leave permissions that loose in production. Hmm, what should I set it to?
Google: correct chmod setting for wordpress on linux
- http://premium.wpmudev.org/forums/topic/correct-chmod-settings-for-install-and-run-of-wordpress
- http://stackoverflow.com/questions/18352682/correct-file-permissions-for-wordpress
- http://codex.wordpress.org/Changing_File_Permissions
Google: wordpress cannot upload image folder permission
This error happens when PHP (WordPress) can't write to the file. This is caused by not having write permissions (the username or group that PHP (WordPress) is running under doesn't have permission to write to the file)
Some server environments require you to use 777 permissions for PHP to have write access. This is not secure in a shared hosting environment.
Hmm, then it is better to find out ** who ** need the permission to write the file. 😄
Assign 766 recursive permissions to wp-contents folder which will resolve the case... #
I know, but giving read & write
permisson is not secure, though.
IMO it would be better to keep the permissions as 755 and give ownership to the webserver account (www-data). It probably doesn't make significant difference in the grand scheme of things but best practice is to keep permissions as tight as possible. Using 777 for testing is legitimate IMO, but there should be no need to leave permissions that loose in production. Root owned directories with 777 should have the same impact on WordPress as those dirs having 755 and owned by www-data. (FYI the 3 numbers refer to owner, group, others - 7 means read/write/execute; 5 means read/execute).
So personally I would do this:
chown -R www-data:www-data /var/www/wordpress/wp-content/uploads chmod -R 755 /var/www/wordpress/wp-content/uploads
I like that! But I've never heard www-data
. Who is that?
The "user" running your webserver (sometimes _www, sometimes www-data, sometimes "nobody") lacks the permissions to edit these files. You can either change them to be owned by that user or change them to 777. To find out what your web server user is, assuming you're running apache, run ps aux | grep httpd in the command line and in the leftmost column, see what user it's showing! #
OK, so...I've to a test myself. This is a problem combine of "who is the owner" of the uploaded image & what is "the least permission", so I've to check it out...
cd /var/www && ls -l
The owner:group is pi:pi
, with 777
(p.s.I've set to 777
4hr before.). Then I try to change them to 755
:
chmod -R 777 wordpress
Oops...
chmod: 正在更改 ‘wordpress/wp-content/uploads’ 的權限: 此項操作並不被允許
chmod: 正在更改 ‘wordpress/wp-content/uploads/2014’ 的權限: 此項操作並不被允許
chmod: 正在更改 ‘wordpress/wp-content/uploads/2014/08’ 的權限: 此項操作並不被允許
chmod: 正在更改 ‘wordpress/wp-content/uploads/2014/08/cover1-500x270.jpg’ 的權限: 此項操作並不被允許
I cannot make a change, coz I am not the owner of them! (Remember that I've upload an image 4hr before successfully, afterward I'd change the whole wordpress/
to 777 with sudo chmod +R 777 wordpress
. That is, I open the wp-content/
folder to all the public, and then ** someone ** put the image into it.) Now, I am going to see who is he!
cd wordpress/wp-content && ls -l
-rwxrwxrwx 1 pi pi 28 1月 9 2012 index.php
drwxrwxrwx 3 pi pi 4096 8月 16 01:55 plugins
drwxrwxrwx 5 pi pi 4096 8月 15 12:05 themes
drwxrwxrwx 3 www-data www-data 4096 8月 15 19:09 uploads
Aha! The folder & image in uploads
is created by Wordpress. It is owned by www-data:www-data
. This is what Jeremy claimed.
連安裝個 wordpress 也很長知識。原來有種 owner 叫 www-data。開 777 就沒安全保護;設成 755就無法上傳圖片,因為 owner 不是我本人。所以我要先找出誰會是 owner,再把 folder 設定成屬於他的,才設成 他的 755。
chown -R www-data:www-data /var/www/wordpress/wp-content/uploads
chmod -R 755 /var/www/wordpress/wp-content/uploads
I fix it!
Google: enable permalink in wordpress nginx
http://codex.wordpress.org/Nginx http://nginxlibrary.com/wordpress-permalinks/
2014-08-30: I need a FTP server on Pi too, because I want to install Wordpress plugins in an easy way.
-
Google: raspberry pi ftp server
-
Google: ubuntu ftp server
sudo apt-get install vsftpd
Then change the ownership of /var/www
(I've already this when setting up Nginx.):
sudo chown -R pi /var/www
Configure the server:
sudo nano /etc/vsftpd.conf
Search through the file and change the following lines:
anonymous_enable=YES Change To anonymous_enable=NO
#local_enable=YES Change To local_enable=YES
#write_enable=YES Change To write_enable=YES
Also, add a line to the bottom of the file:
force_dot_files=YES
after edit the configuration, restart the service:
sudo /etc/init.d/vsftpd restart
The host is 127.0.0.1
, where the anonymous FTP user name and password are ftp:ftp
#. The user name and password is the existing user, such as pi
:
127.0.0.1
pi
je09
- https://help.ubuntu.com/10.04/serverguide/ftp-server.html
- http://computers.tutsplus.com/tutorials/how-to-use-a-raspberry-pi-as-a-local-web-server--cms-19943
- http://www.instructables.com/id/Raspberry-Pi-Web-Server/step9/Install-an-FTP-server/
- http://b.nj007.com/post/403.html
###Backup
Backup: Just like you can load saving data while playing RPG game.
sudo dd bs=4M if=/dev/sdb of=raspbian.img (or dcfldd)
dd if=/path/to/image of=/dev/sdb
ref: Google: raspberry backup
or combian use of bzip to compress the image!
dd if=/dev/sdx | gzip > /path/to/image.gz
gzip -dc /path/to/image.gz | dd of=/dev/sdx
or dump the SD card, and pipe it with ssh:
dd bs=1M if=/dev/mmcblk0 | ssh user@host 'dd of=/remote/path/to/sdcard.img'
with compression:
dd bs=1M if=/dev/mmcblk0 | ssh user@host 'gzip -9 > /remote/path/to/sdcard.img.gz'
** Prefer ** My actual command:
df -h
umount /dev/sdc1
umount /dev/sdc2
sudo dcfldd bs=4M if=/dev/sdc | bzip2 -8 > '/media/Windows7_OS/Raspberry Pi System Backup (2014-08-xx)/Raspberry Pi - system.img-201408xx.bz2'
ref:
- http://www.raspberrypi.org/forums/viewtopic.php?p=118519
- http://pitown.blogspot.hk/2013/11/backing-up-raspberry-pis-operating.html (from: * http://magnatecha.com/things-i-do-with-my-raspberry-pi/)
Google: linux backup to dropbox
As I've decided to write code on my nb (not write over ssh) and then deploy it to pi, I decide to use Git & Github to deploy and backup my code. (Consider once my nb is dead, I still have 2 copies of my code.)
- http://www.commandlinefu.com/commands/tagged/749/mysqldump
- https://github.com/johnantoni/AutoMySQLBackup
Then BTSync to the @backup
directory of my project folder.
Google: how to restore mysqldump
- http://www.thegeekstuff.com/2008/09/backup-and-restore-mysql-database-using-mysqldump/
- http://xmodulo.com/2012/10/how-to-backup-mysql-server.html
ref:
- http://codex.wordpress.org/Hardening_WordPress#File_permissions (Google: how to set chmod with wordpress on linux -> http://premium.wpmudev.org/forums/topic/correct-chmod-settings-for-install-and-run-of-wordpress) is a good direction on web apps security.
- 如何保证Linux服务器的安全
- 通过Backtrack Linux 来加强你的安全防御
Google: raspberry mail server
See how Debian says about Raspberry Pi (from: http://www.geekfan.net/10419/)
Internet of Things Remote Sensing
Google: how to read .gz doc in linux on the fly
As I facing a problem reading the .gz doc in /usr/share/doc/nginx
, when I config ngnix today.
mount -t tmpfs tmpfs /mnt -o size=1024m
Mount a temporary ram partition
Makes a partition in ram which is useful if you need a temporary working space as read/write access is fast.
Be aware that anything saved in this partition will be gone after your computer is turned off.
- http://www.commandlinefu.com/commands/view/224/mount-a-temporary-ram-partition (http://www.commandlinefu.com/commands/browse/sort-by-votes)
- http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html
- http://wiki.nginx.org/Pitfalls
- http://wiki.nginx.org/QuickStart
- http://wiki.nginx.org/Configuration
To turn off the display using the Linux command line, open a terminal and enter:
xset dpms force standby
I also like to lock my screen before hand (in GNOME):
gnome-screensaver-command -l && xset dpms force standby
ref:
- https://django-book.readthedocs.org/en/latest/# (from: http://www.meetup.com/Taipei-py/messages/boards/thread/34933702)
- https://github.com/rosarior/awesome-django
- https://github.com/makaimc/awesome-django
- https://github.com/vinta/awesome-python
- Codecademy -- 透過闖關遊戲方式學習 Python, HTML/CSS, JavaScript ( from Django Girls TW )
- Writing your first Django app -- Django 1.7 官方學習指南
- Getting Started With Django -- 影片課程
- The Django Book -- 雖然 Django 版本不是最新,但相當適合初學者的一本書
- Two Scoops of Django: Best Practices for Django -- 非常推薦,Taipei.py 隔週二聚會指定書籍
- Django Packages -- Django 相關套件彙整平台,提供搜尋和評比
- [Python Snippets [ (https://djangosnippets.org/snippets/261/), from Google: django email contact
- RealPython
- https://code.djangoproject.com/wiki/DjangoResources (from: Google: django ui framework)
- http://learnpythonthehardway.org/
- https://developers.google.com/edu/python/
- https://www.coursera.org/course/interactivepython
- http://www.fullstackpython.com/
- http://www.fullstackpython.com/best-python-resources.html
- 語言技術:Python Gossip
- Open Sourcing a Python Project the Right Way - Jeff Knupp
- djangoGirls on GitBook
- http://codecondo.com/web-scraping-python/
- Reddit: django
- Medium - Laravel 4 Tutorials
- from: Google: laravel tutorials. See also "wordpress", "django" in medium.com
- https://github.com/makaimc/awesome-django
- http://www.databaseanswers.org/data_models/index.htm (from: http://www.quora.com/What-is-the-fastest-way-to-learn-Django)
- http://www.quora.com/I-really-really-want-to-learn-to-code-However-upon-taking-classes-and-practicing-in-C-I-realized-that-I-hate-the-whole-process-of-programming-debugging-constant-unclear-ambiguous-errors-confusing-logic-What-can-I-do-to-get-over-this
- http://www.quora.com/Are-there-any-good-Django-video-tutorials
- Google: django testing | TDD
- https://docs.djangoproject.com/en/dev/topics/testing/
- https://github.com/makaimc/awesome-django
- http://effectivedjango.com/testing.html
- http://www.tdd-django-tutorial.com/
- http://learnpythonthehardway.org/book/ex47.html
- https://realpython.com/blog/python/testing-in-django-part-1-best-practices-and-examples/
- https://realpython.com/blog/python/testing-in-django-part-2-model-mommy-vs-django-testing-fixtures/
- Google: django tutorial | django guide | django cast | django girls | django girls tutorial
- Quora: how to learn django
- Medium: django
- Tut+
- http://arunrocks.com/recreating-the-building-a-blog-in-django-screencast/
- https://www.youtube.com/watch?v=7rgph8en0Jc
- https://github.com/django/djangoproject.com/tree/master/blog
- http://www.tangowithdjango.com/book/index.html
- https://django-book.readthedocs.org/en/latest/# (from: http://www.meetup.com/Taipei-py/messages/boards/thread/34933702)
- http://www.barrymorrison.com/2012/10/zero-to-django-in-4-months-what-ive-learned-part-1/
- http://djangobook.py3k.cn/2.0/
Google: should I use south in django 1.7
- https://realpython.com/blog/python/django-migrations-a-primer/
- http://treyhunner.com/2014/03/migrating-to-django-1-dot-7/
to reset the migration, run zero
with migrate
./manage.py migrate <app name> zero
Google: django fixture | django initial database
- https://docs.djangoproject.com/en/dev/howto/initial-data/
- https://code.djangoproject.com/wiki/Fixtures
Data can be dumpped or loaded as XML, JSON or YAML (PyYaml is need):
pip install pyyaml
./manage.py dumpdata --format=yaml
See also: https://github.com/alex/django-fixture-generator
inner function
- http://woodpecker.org.cn/
- Two Scoops of Django
- http://lightbird.net/dbe/
Managing state and transitions, aka workflow.
- https://github.com/kmmbvnr/django-viewflow
- https://www.djangopackages.com/packages/p/django-viewflow/
- https://gist.github.com/Nagyman/9502133 says workflow is a FSM (aka Finite State Machine).
- https://www.ruby-toolbox.com/categories/state_machines
Django Template
Google: django admin 2 https://github.com/pydanny/django-admin2 (from: https://code.djangoproject.com/wiki/AdminNext)
Google: django admin demo
Google: django admin theme
- https://www.djangopackages.com/grids/g/admin-styling/
- http://grappelliproject.com/
- https://github.com/sehmaschine/django-grappelli
Google: django bootstrap
Google: django Boilerplate
Deploy Django with uWSGI & Nginx
Plotting Graph
2014-09-17: My django apps respond slowly. The user experence is bad.
I use Firefox 34 F12
to test the page loading time. On my development notebook , /admin/product/topic/28
, which relates to 19 product sources (and the 1600+ related sources), consumes 5.2s~5.6s to render. The most expensive part is the html files. It takes 1535.22KB, and the files totally are 1676.17KB (1 html, 8 js, 3 css, 6 images). Comparing to the other pages, which the most expensive part is the js files.
There are ways to speed it up:
- overclock the Pi
- optimize the code
- optimize the database
- caching (cache the view/page, or cache the ORM/database object)
Tools for benchmark website performance: http://webwait.com/ED
Tools for profiling django see Django Documentation: profiling | performance |optimization
For 1:
sudo raspi-config # The overclock the Pi
For 2:
Reduce the times of queries, or group many queries into one. (Queries in Django is lazy (from: Database access optimization ) )
Redesign the relation between models help a lot. But the labourhood is not worthy.
For 3:
@see Replace MySQL with MariaDB. Or to reduce the SQL queries. Or to ensure there is index on table. Compicated relations do hurt.
For 4:
Github: django cache -> johnny-cache -> http://memcached.org/ Google: django cache -> Django Documentation - Django’s cache framework
The workflow is firstly setup the cache, and then use caching to cache the entire site:
setup memcache | LocMemCache -> change MiddelWare setting -> testing (profiling)
I wanna use memcache for Django, as once I set it up, I can use it with WordPress too. 😄
Firstly, I've to install memcache on Pi:
-
Google: ubuntu memcached
- How To Install and Use Memcache on Ubuntu 14.04 (2014-05-01 published)
-
Google: memcached django
sudo apt-get install memcached
sudo service memcached status
After installing Memcached itself, you'll need to install a memcached binding (aka memcache clients. There are several python memcached bindings available; the two most common are python-memcached and pylibmc. # #
-
Google: ubuntu mancaced python
- Installing memcached for a django project
- how to install libmemcached for django framework in ubuntu 10.04
pip install python-memcached # or sudo apt-get install python-memcache
I've got an error message in browser. Since python-memcached
does not support python3, I have to install python3-memcached
. (Google: memcached python3)
pip install python3-memcached
Memcache works now. However, niether Django's built-in Local-memory caching nor memcached caches the query objects in the admin section, I am going to find another way to solve my problem.
After memcache runs successfully, the page loading time of /admin/product/topic/28/
does not change much: from 5.5s to 5.0+s
-> Google: does django cache admin
As the memcached does not cache admin query (e.g. admin/product/topic/28/
, which takes 5.52s to render. After turn memcache on, it still take 5.4s to load that page in the 2nd+ load), I have to find another solution. (As well as johnny-cache does not support python3.)
http://www.tutorialspoint.com/redis/index.htm DjangoPackages: caching
django-cacheops seems good. It support Python 3, Django 1.7, and It uses redis as backend for ORM cache and redis or filesystem for simple time-invalidated one. I am going to install redis server on my machine:
sudo apt-get install redis-server # as apt-get itstall redis returns no package...
sudo service redis-service
(The redis-server installed is v2.4, not the latest v2.8.3. The requirement of django-cacheops is v2.6+. Therefore, I am going to install it from source. 😄
Ref to http://redis.io/topics/quickstart,
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
At this point you can try if your build works correctly by typing make test
, but this is an optional step. Then make install
if everything ok.
make install
This takes about 15 mins on Pi.
Or, if make install
does not work, go to ./utils
and the run the install_server.sh
(ref: the README
of the downloaded redis-stable
directory):
cd utils
./install_service.sh
(2014-09-26 update: I've found a way to install the latest redis automaticlly.
How to install the latest version of redis on Ubuntu?
Google: redis install wordpress -> Toby's Rambling - How to install the latest version of redis on Ubuntu:
$ sudo apt-get install -y python-software-properties
$ sudo add-apt-repository -y ppa:rwky/redis
$ sudo apt-get update
$ sudo apt-get install -y redis-server
Line 1 – So we want to add a new repository that contains the latest version of Redis, the easiest way to do this requires add-apt-repository, which most likely isn’t installed on your machine, so the first thing we want to do is install python-software-properties, this gives us access to add-apt-repository.
Line 2- Next we want to set up this new repository.
Line 3 – Now we want to update apt so it sees any changes we have made.
Line 4 – Finally we want to install redis-server, now the latest version will be installed.
If you are wondering the -y flag just saves me having to manually OK things I was going to OK anyways, this is really handy if you are running these steps as part of a provisioning step (which I was) )
Let's use redis in Django. Firstly, I turn the 3 caching middleware off, and the CACHES = {}
block off too, in the setting.py
:
# 'django.middleware.cache.UpdateCacheMiddleware',
# 'django.middleware.common.CommonMiddleware',
# 'django.middleware.cache.FetchFromCacheMiddleware',
pip install django-cacheops
Add cacheops
to your INSTALLED_APPS
before any apps that use it.
Setup redis connection and enable caching for desired models:
CACHEOPS_REDIS = {
'host': 'localhost', # redis-server is on same machine
'port': 6379, # default redis port
'db': 1, # SELECT non-default redis database
# using separate redis db or redis instance
# is highly recommended
'socket_timeout': 3,
}
CACHEOPS = {
# Automatically cache any User.objects.get() calls for 15 minutes
# This includes request.user or post.author access,
# where Post.author is a foreign key to auth.User
'auth.user': ('get', 60*15),
# Automatically cache all gets, queryset fetches and counts
# to other django.contrib.auth models for an hour
'auth.*': ('all', 60*60),
# Enable manual caching on all news models with default timeout of an hour
# Use News.objects.cache().get(...)
# or Tags.objects.filter(...).order_by(...).cache()
# to cache particular ORM request.
# Invalidation is still automatic
'news.*': ('just_enable', 60*60),
# Automatically cache count requests for all other models for 15 min
'*.*': ('count', 60*15),
}
Additionally, you can tell cacheops to degrade gracefully on redis fail with:
CACHEOPS_DEGRADE_ON_FAILURE = True
There is also a possibility to make all cacheops methods and decorators no-op, e.g. for testing:
CACHEOPS_FAKE = True
Finally, I let cacheops to cache all the things, including admin, queries:
'*.*': ('all', 60*15),
Now, the page loading of /admin/product/topic/28/
is 3.73s, decreased from 5.5s. The improvement is great!
Persistent connection helps! (aka connection pool)
CONN_MAX_AGE = None
Django Documentation: Database -> setting: CONN_MAX_AGE
Turn on persistent connection helps to save 0.5s (with no caching on). Page load is from 5.5s to 5.08s.
(see also the connection pools in django-redis: http://niwibe.github.io/django-redis/)
N+1 queries hurts.
When I turn off the related field related
in the Source model, the page load time of /admin/product/topic/28/
drops much! The page loading drops from 5.5s to 0.69s!
Ref:
- Google: Rails cache, django cache
- Caching with Rails: An overview
- Ruby on Rails 實戰聖經使用 Rails 4.1 及 Ruby 2.1 - 快取
- Django Documentation - Django’s cache framework
- The Django Book - Chapter 15: Caching
- Django Documentation: [cache | profiling | performance | optimization]
http://haydenjames.io/best-wordpress-cache-plugin-wp-ffpc/ (Google: raspberry mariadb -> http://haydenjames.io/download-lemp-raspberry-pi-nginx-mariadb-mysql-php/)
If memcache is supporting PHP, there should be a memcache
section in <? echo phpinfo();
.
Google: redis install wordpress
2014-09-10:
My django apps respond slowly. I turn on htop & nmon to see what's happen then. There are 6 or more mysqld processes running at the same time! OMG! That's the reason why the Pi respond slowly as it has 1 core. Now, I am thinking of replacing MySQL. (2014-09-17 update: I should use profiling tools to check the performance of it, rather than 'feel' it. :P)
Google: raspberry mariadb
- http://haydenjames.io/download-lemp-raspberry-pi-nginx-mariadb-mysql-php/
- http://www.homecomputerlab.com/nginx-php-mariadb-wordpress-on-archlinux-on-a-raspberry-pi
- http://raspbian-france.fr/installer-mariadb-raspbian/
- http://blog.pi3g.com/2014/07/easy-mariadb-installation/
There is no MariaDB package on Pi's repositiory. I have to compile by myself. Luckily, pi3g makes one: Easy MariaDB installation | pi3g Blog
However, I am not eazy to go with new MariaDB before try to tune the performance of the existing MySQL firstly. HayDen james writes an interesting article MySQL Query Cache Size and Performance and I am trying to figure it out now.
- Git 版本控制系統
- 好麻煩部落格: Git 教學
- How To Use Source Control Effectively
- 软件版本控制介绍
- 15分钟学会使用Git和远程代码库
- 让你的Git水平更上一层楼的10个小贴士
- https://www.atlassian.com/git/
- 沉浸式学 Git
- http://githowto.com/tagging_versions
- https://help.github.com/articles/github-flow-in-the-browser
- http://ihower.tw/git/
- http://blog.eddie.com.tw/slides/
- http://blog.gogojimmy.net/2012/02/29/git-scenario/
- http://gogojimmy.net/2012/01/17/how-to-use-git-1-git-basic/
- https://github.com/johnantoni/git-notes
- https://github.com/mhagger/git-imerge
- 专为设计师而写的GitHub快速入门教程
- Git教程 - 廖雪峰的官方网站
- http://it-ebooks.info/tag/git/
- http://computers.tutsplus.com/articles/chris-coyier-on-life-work-and-eighteen-years-as-a-mac-user--mac-3566
- http://code.tutsplus.com/articles/what-are-you-using--net-32373?utm_source=Tuts+&utm_medium=website&utm_campaign=relatedtutorials&utm_content=sidebar&WT.mc_id=Tuts+_website_relatedtutorials_sidebar
- http://computers.tutsplus.com/articles/piers-ridyard-on-the-development-and-success-of-the-nifty-minidrive--mac-54952
- http://demo.tc/Post/702
- http://blog.jobbole.com/25808/
- Git & Excel
The alias I use:
git config --global alias.c 'commit -m'
git config --global alias.co 'checkout'
git config --global alias.cob 'checkout -b'
git config --global alias.br 'branch'
git config --global alias.m 'merge'
git config --global alias.a 'add .'
git config --global alias.s 'status'
git config --global alias.dbr 'branch -d'
git config --global alias.l 'log'
git config --global alias.lol 'log --oneline'
git config --global alias.lg 'log --graph'
git config --global alias.lago 'log --all --graph --oneline'
http://igit.linuxtoy.org/aliases.html shows more.
git log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
git config --global alias.hist 'log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short'
I put the hist alias too. The correct version is in Git immerse
Or, I write them into the .gitconfig
in $HOME
:
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
type = cat-file -t
dump = cat-file -p
Now, I have a local branch product
on my notebook, and I have push it to github. I get only the master
branch on my Pi whatever I git pull
or I delete the whole project folder and then git clone
it from github again.
Now, how can I get the latest updated branch product
on my Pi?
from: Git How to: Remote Branch , Google: git get all the branch from remote
Git branch - How to clone remote branch with Git? shows some hints:
First, clone a remote Git repository and cd into it:
$ git clone git://example.com/myproject
$ cd myproject
Next, look at the local branches in your repository:
$ git branch
* master
But there are other branches hiding in your repository! You can see these using the -a flag:
$ git branch -a
* master
remotes/origin/HEAD
remotes/origin/master
remotes/origin/v1.0-stable
remotes/origin/experimental
If you just want to take a quick peek at an upstream branch, you can check it out directly:
$ git checkout origin/experimental
But if you want to work on that branch, you'll need to create a local tracking branch:
$ git checkout -b experimental origin/experimental
and you will see
Branch experimental set up to track remote branch experimental from origin.
Switched to a new branch 'experimental'
- Lifehacker - Build an Entire Home Automation System with a Raspberry Pi and Arduino
- Try RQ: Redis Queue
- Try http://www.celeryproject.org
- from: Redis Queue
- http://blog.jobbole.com/50643/ 如何利用多核CPU来加速你的Linux命令
- http://blog.jobbole.com/75142/ 怎么制定一套合适的服务器命名方案
- Sublime Text
- Visual Studio Code on Raspbian
- PyCharm
- Intellij IDEA
Google: opensource crm award (idea from: http://www.sugarcrm.com/about/awards-recognition) Google: opensource cms award
- http://www.howtogeek.com/139433/how-to-turn-a-raspberry-pi-into-a-low-power-network-storage-device/
- http://www.geekfan.net/2767/
- http://www.geekfan.net/5003/
Do it on client side, as I seldom login to pi with keyboard and mouse but remote control it with ssh.
Google: linux install font
一般在 Debian 系列的 Linux 中,如果要安裝字型,可將字型檔放在 /usr/share/fonts 或 ~/.fonts 目錄中,然後執行:
fc-cache -fv
這樣就可以使用新安裝的字型了。#
Google: Source code pro
http://sourceforge.net/adobe/source-han-sans/ http://github.com/adobe-fonts/source-han-sans/ http://www.google.com/get/noto/#/family/noto-sans-hant
badblocks
command will detect all bad blocks (bad sectors) on our hard disk and save them in a text file so that we can use it with e2fsck
to configure Operating System (OS) to not store our data on these damaged sectors.
Step:1 Use fdisk command to identify your hard drive info
sudo fdisk -l
Step:2 Scan your hard drive for Bad Sectors or Bad Blocks
sudo badblocks -v /dev/sdb > /tmp/bad-blocks.txt
Just replace “/dev/sdb” with your own hard disk / partition. When we execute above command a text file “bad-blocks” will be created under /tmp , which will contains all bad blocks.
Step:3 Inform OS not to use bad blocks for storing data
Once the scanning is completed , if the bad sectors are reported , then use file “bad-blocks.txt” with e2fsck command and force OS not to use these bad blocks for storing data.
sudo e2fsck -l /tmp/bad-blocks.txt /dev/sdb
Note : Before running e2fsck command , you just make sure the drive is not mounted.
Google: linux check disk bad sectors
// Last update: 2019-07 // Markdown tidyup: 2018-08