Debian 使用笔记

1. Install pear on Debian

A:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
$ wget http://pear.php.net/go-pear.phar
$ sudo php go-pear.phar

Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : /home/meiliang/pear
 2. Temporary directory for processing            : /tmp/pear/install
 3. Temporary directory for downloads             : /tmp/pear/install
 4. Binaries directory                            : /home/meiliang/pear/bin
 5. PHP code directory ($php_dir)                 : /home/meiliang/pear/share/pear
 6. Documentation directory                       : /home/meiliang/pear/docs
 7. Data directory                                : /home/meiliang/pear/data
 8. User-modifiable configuration files directory : /home/meiliang/pear/cfg
 9. Public Web Files directory                    : /home/meiliang/pear/www
10. System manual pages directory                 : /home/meiliang/pear/man
11. Tests directory                               : /home/meiliang/pear/tests
12. Name of configuration file                    : /home/meiliang/.pearrc

1-12, 'all' or Enter to continue: 1
(Use $prefix as a shortcut for '/home/meiliang/pear', etc.)
Installation base ($prefix) [/home/meiliang/pear] : /usr/local/bin/pear

$ vim .bashrc
# Append the /usr/local/bin/pear directory in the user's home directory onto the PATH environment variable
export PATH=$PATH:/usr/local/bin/pear/bin

// Reload bash configure file
$ source .bashrc

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/bin/pear/bin

// Check wether it works
$ pear version
PEAR Version: 1.10.1
PHP Version: 5.6.17-0+deb8u1
Zend Engine Version: 2.6.0
Running on: Linux Debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24) x86_64

2. Install PHP GD extension on Debian

A:

1
2
3
4
5
6
7
8
9
$ sudo aptitude install php5-gd

// How do I verify that php5-gd support loaded or not?
// Type the following command at a shell prompt:
$ php5 -m | grep -i gd

Sample outputs:

gd

Reference:Ubuntu Linux: Install or Add PHP-GD Support To Apache Web Server

3. Install PHP cURL extension on Debian

A:

1
$ sudo aptitude install php5-curl

Reference:How do I install PHP cURL on Linux Debian?

4. Install PHP mCrypt extension on Debian

A:

1
2
3
4
5
6
7
8
9
10
$ aptitude search mCrypt
p   libmcrypt-dev                                                                    - De-/Encryption Library development files
p   libmcrypt4                                                                       - De-/Encryption Library
p   libtomcrypt-dev                                                                  - static library, header files and documentation for libtomcrypt
p   libtomcrypt0                                                                     - public domain open source cryptographic toolkit
p   mcrypt                                                                           - Replacement for old unix crypt(1)
p   php5-mcrypt                                                                      - MCrypt module for php5

$ sudo aptitude install php5-mcrypt
$ sudo service apache2 restart

5. Default installation layouts for Apache HTTPD on Debian

A:

1
2
3
4
5
6
7
8
9
10
11
ServerRoot              ::      /etc/apache2
DocumentRoot            ::      /var/www
Apache Config Files     ::      /etc/apache2/apache2.conf
                        ::      /etc/apache2/ports.conf
Default VHost Config    ::      /etc/apache2/sites-available/default, /etc/apache2/sites-enabled/000-default
Module Locations        ::      /etc/apache2/mods-available, /etc/apache2/mods-enabled
ErrorLog                ::      /var/log/apache2/error.log
AccessLog               ::      /var/log/apache2/access.log
cgi-bin                 ::      /usr/lib/cgi-bin
binaries (apachectl)    ::      /usr/sbin
start/stop              ::      /etc/init.d/apache2 (start|stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean)

Notes:

  1. The Debian/Ubuntu layout is fully documented in /usr/share/doc/apache2/README.Debian
  2. Debian/Ubuntu use symlinks to configure vhosts and load modules. Configuration files are created in their respective sites-available and mods-available directories. To activate vhosts and modules, symlinks are created in the respective sites-enabled and mods-enabled directories to the config files in either sites-available and mods-available. Debian provides scripts to handle this process called ‘a2ensite’ and ‘a2enmod’ which activates vhosts and modules.
  3. The default vhost is defined in /etc/apache2/sites-available/default, and overrides the DocumentRoot set in the server context.

Reference:DistrosDefaultLayout

6. Can’t connect to PPTP VPN with ufw enabled on Debian 3.16.7-ckt11-1 with kernel 3.16.0-4-amd64

A: Allow Port 1723 on UFW

1
# ufw allow 1723

This is caused by a change for security reason in kernel 3.18 [1]. There are two ways to fix this.

  • First approach is adding this rule to the file /etc/ufw/before.rules before the line # drop INVALID packets … -A ufw-before-input -p 47 -j ACCEPT
  • Second approach is manually loading the nf_conntrack_pptp module. You can do this by running $sudo modprobe nf_conntrack_pptp

To load this module on every boot on Ubuntu, add it to the file /etc/modules.

Reference:Can’t connect to PPTP VPN with ufw enabled on Ubuntu 14.04 with kernel 3.18

How to setup pptp vpn on ubuntu 12.04

7.OpenVPN server configure correct, but client can’t brower web site block by GTW.

A:There is a crue the the log of VPN client issue client DNS be used. So I think this may be the problem. YES, client can brower all web site after remove all client DNS settings.

1
2
3
4
5
192.168.8.1
202.103.96.112
8.8.8.8
208.67.222.222
208.67.220.220

Reference: How To Set Up an OpenVPN Server on Debian 8
How To Set Up an OpenVPN Server on Ubuntu 14.04

8.How to stop rpcbind and rpc.statd on debian?

A:Both of these services are only needed if you plan on using NFS for file sharing. They are otherwise unneeded and are a potential security risk.

1
2
3
4
5
$sudo systemctl stop rpcbind.service
$sudo systemctl disable rpcbind.service

$sudo systemctl stop nfs-common.service
$sudo systemctl disable nfs-common.service

Reference:Is it safe to remove rpcbind?
rpc.statd running on system not using NFS

9.Welcome to emergency mode! After loggin in, type “journalctl -xb” to view system logs, “systemctl reboot” to reboot,“systemctl default” or ctrl+D to try again to boot into default mode.

A:在 digitalocean 上从 snapshot 创建一个 droplet, 登录后提示上述信息。journalctl -xb 查看系统日志发现提示的错误信息是:

1
2
3
Timed out waiting for device dev-disk-by...
Dependency failed for /boot.
Dependency failed for Local File Systems.

从错误信息来看,似乎是文件系统出错了,用 lsblk -f 查看下挂载的文件系统,发现并没有 /boot 分区,于是编辑 /etc/fstab,将未挂载的分区都注释掉,提示文件系统为只读,于是使用命令 mount -o remount,rw /dev/vda1 / 重新挂载根文件系统。/etc/fstab 也就可编辑了,之后 systemctl reboot 系统恢复了。

Reference:“Welcome to emergency mode!” Think it is a fsck problem