Monthly filing: February 2018

Using Apache htaccess file to create password protected website privacy directory

In the production environment, there are many different website directory restriction scenarios, which may need to be used Apache htpasswd Tools. I will explain how to use them one by one.

Use first Apache htpasswd Command to create a password file, htpasswd The command usage of is as follows:

 -C # Create a password file. If the file already exists, it will overwrite and delete the original content; -N # Display the password directly without updating the password file; -M # Use MD5 encryption (default); -D # CRYPT encryption (default); -P # Password in plain text format; -S # Use SHA encryption; -B # In the command line, input the user and password together, but interactively, the password clear text can be seen when generating; -D # Delete the specified user;

Create and add a password file with user name: renwole and password: renwole:

 $ htpasswd -c .accpasswd renwole New password: Re-type new password: Adding password for user renwole

Note: Password created .accpasswd The file name can be customized.

Use cat to view the generated content:

 $ cat .accpasswd renwole:$apr1$4owQhqtn$ElCDIh0sfR. ZFzeaY9sDw0

Note: The generated password has been encrypted, so don't confuse it.

Add multiple accounts:

 $ htpasswd -b .accpasswd renwolecom password-renwolecom Adding password for user renwolecom

View multiple generated accounts and passwords:

 $ cat .accpasswd renwole:$apr1$4owQhqtn$ElCDIh0sfR. ZFzeaY9sDw0 renwolecom:$apr1$3zzGmKtR$jKKCbU2nVEQZFz9mtEXE./

Delete user:

 $ htpasswd -D .accpasswd renwolecom Deleting password for user renwolecom

To view the deleted password file:

 $ cat .accpasswd renwole:$apr1$4owQhqtn$ElCDIh0sfR. ZFzeaY9sDw0

Create password protection zone

With the password file, we can use .htaccess File creation protection area.

Save the following as .htaccess File, so that we can use the file to create a protected area.

 $ vim /apps/web/renwolecom/phpMyadmin/.htaccess AuthType Basic AuthName "restricted area" AuthUserFile /usr/local/apache/conf/.accpasswd require valid-user

Put the file in the directory to be protected. So I put it in the root directory of the website phpMyadmin Directory. When you access this directory, a pop-up verification window will appear. Enter the generated user name and password.

SQL Server 2008 R2 evaluation period expired installation serial number

The following serial numbers can be installed and used. The specific steps for evaluation expiration are as follows:

Configuration tool - installation center - installation - maintenance - version upgrade - fill in the serial number.

Valid for 99.9999 personal tests.

Data center version 32-bit: PTTFM-X467G-P7RH2-3Q6CG-4DMYB
Data center version 64 bit: DDT3B-8W62X-P9JD6-8MX7M-HWK38

CentOS Linux 7.7 1908 x86 64 ISO official original image download

 For x86_64 architecture:
 CentOS-7-x86_64-DVD-1908.iso 11-Sep-2019 18:51      4G CentOS-7-x86_64-DVD-1908.torrent 17-Sep-2019 12:39     87K CentOS-7-x86_64-Everything-1908.iso 09-Sep-2019 19:09     10G CentOS-7-x86_64-Everything-1908.torrent 17-Sep-2019 12:38    103K CentOS-7-x86_64-LiveGNOME-1908.iso 16-Sep-2019 18:57      1G CentOS-7-x86_64-LiveGNOME-1908.torrent 17-Sep-2019 12:39     29K CentOS-7-x86_64-LiveKDE-1908.iso 16-Sep-2019 19:27      2G CentOS-7-x86_64-LiveKDE-1908.torrent 17-Sep-2019 12:39     38K CentOS-7-x86_64-Minimal-1908.iso 11-Sep-2019 19:04    942M CentOS-7-x86_64-Minimal-1908.torrent 17-Sep-2019 12:39     37K CentOS-7-x86_64-NetInstall-1908.iso 06-Sep-2019 11:49    552M CentOS-7-x86_64-NetInstall-1908.torrent 17-Sep-2019 12:39     22K
 Version description: DVD: # Standard installation image, commonly used. Minimal: # Minimum installation image, with the least software. Everything: # Integrate all software based on the standard, and the image is the largest. NetInstall: # Network installation image. The package is small, but it can only be installed through networking.
 For more versions, see  Download CentOS ISO 》。

How to use Lsyncd to replicate and synchronize to remote servers in real time

What is Lsyncd?

Lsyncd official website//axkibe.github.io/

Lsyncd monitors the local tree event monitor interface (inotify or fsevents). It aggregates and groups events together for a few seconds, and then generates a process (or processes) to synchronize these changes. By default, rsync implements synchronization. Therefore, Lsyncd is a lightweight real-time image solution that is relatively easy to install, does not require a new file system or block device, and does not hinder the performance of the local file system.

Rsync+ssh It is an advanced operation configuration. It uses ssh to move files and directories directly on the target, rather than retransmitting the moving target on the line. Fine grained customization can be achieved through configuration files. Custom Action configs You can even write from scratch, from shell Script to Lua Language. This method is simple, powerful and flexible.

Lsyncd 2.2.2 Required on all source and target machines rsync >= 3.1

System environment:

RenwoleServer: 10.28.204.65 server
RenwoleClient: 10.28.204.66 client
OS:CentOS Linux release 7.4.1708 (Core) x64

1. Installation of rsync

See:《 CentOS 7 Configure Rsync Data File Synchronization Server 》。

2. Install the extension dependency package

 $ yum install -y gcc gcc-c++ lua lua-devel cmake libxml2 libxml2-devel

3. Compile and install the source code lsyncd

 $ wget //github.com/axkibe/lsyncd/archive/release-2.2.2.tar.gz $ tar xvf release-2.2.2.tar.gz $ cd lsyncd-release-2.2.2 $ cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lsyncd $ make && make install $ ln -s /usr/local/lsyncd/bin/lsyncd /usr/bin/lsyncd

An error may be reported during installation:

-- Configuring incomplete, errors occurred!

install lua-devel OK.

4. Set SSH login without password

Because here rsyncssh To synchronize, you also need to configure the root account to ssh login without password. Please refer to:

How to set SSH login without password in Linux

5. Configure lsyncd

The following are three common configuration cases

1. Remote synchronization rsyncssh Mode configuration scheme:

 $ vim /etc/lsyncd.conf
 settings { Logfile="/var/log/lsyncd. log", -- log path StatusFile="/var/log/lsyncd. status", -- status file Pidfile="/var/run/lsyncd. pid", -- pid file path StatusInterval=1, -- the shortest time to write the status file Nodaemon=false, -- daemon running MaxProcesses=1, -- Maximum Processes MaxDelays=1, -- maximum delay } sync { Default.rsyncssh, -- default rsync+ssh, rsync version needs to be upgraded to more than 3 versions Source="/apps/www/renwoleblog/", -- source directory Delete=true, -- keep full synchronization host = " root@10.28.204.66 ",          Targetdir="/apps/www/renwoleblog/bak/", -- target directory exclude={                  ". txt" -- files to be excluded }, rsync = { Binary="/usr/bin/rsync", -- install rsync first Archive=true, -- archive Compress=false, -- compression Owner=true, -- owner Perms=true, -- permission whole_file = false }, ssh = { port = 22 } }

2. Local directory synchronization configuration scheme:

 sync { default.rsync, source = "/apps/www/renwoleblog/", target = "/apps/www/renwoleblog/bak/", }

3. Remote synchronization rsync daemon mode configuration scheme

 sync { default.rsync, source    = "/apps/www/renwoleblog/", target    = " renwole@10.28.204.65 ::renwolecom", delete="true", exclude = { ".bak*" }, delay = 30, init = false, rsync = { binary = "/usr/bin/rsync", archive = true, compress = true, verbose   = true, perms = true, password_file = "/etc/rsync.password", _extra    = {"--bwlimit=200"} } }

Key parameter description:

 --# Comment Settings # is global configuration Sync # Define synchronization parameters Rsync # Define synchronization file parameters Ssh # Define the server remote port

lsyncd Multiple profiles allowed sync They do not affect each other.

Note: If it is one to many, please refer to Local Synchronization and modify the target directory.

6. Create systemctl system unit file

To implement systemctl management, please create a configuration file and a script startup file. The command is as follows:

 $ vim /etc/sysconfig/lsyncd

Add the following:

 LSYNCD_OPTIONS="/etc/lsyncd.conf"

To create a startup file:

 $ vim /usr/lib/systemd/system/lsyncd.service

Add the following:

 [Unit] Description=Live Syncing (Mirror) Daemon After=network.target [Service] Type=simple EnvironmentFile=-/etc/sysconfig/lsyncd ExecStart=/usr/local/lsyncd/bin/lsyncd -nodaemon $LSYNCD_OPTIONS [Install] WantedBy=multi-user.target

7. Start lsyncd and add boot auto start

 $ systemctl start lsyncd $ systemctl enable lsyncd

Next, you can go to the source server /apps/www/renwoleblog/ Upload any file inside, and it will be synchronized to the client immediately after completion 10.28.204.66 /apps/www/renwoleblog/bak/ In the directory, you can also check whether the lsyncd log file analysis on the server is synchronized successfully. For example:

 [ root@RenwoleServer  ~] $ cat /var/log/lsyncd.log
 ... Fri Dec 22 01:19:22 2017 Normal: Calling rsync with filter-list of new/modified files/dirs / PCHunter_renwole.com.tar.gz / Fri Dec 22 01:19:24 2017 Normal: Finished (list): 0 Fri Dec 22 01:19:32 2017 Normal: Calling rsync with filter-list of new/modified files/dirs / PCHunter_renwole.com.tar.gz / Fri Dec 22 01:19:34 2017 Normal: Finished (list): 0 Fri Dec 22 01:19:34 2017 Normal: Calling rsync with filter-list of new/modified files/dirs / PCHunter_renwole.com.tar.gz / Fri Dec 22 01:19:36 2017 Normal: Finished (list): 0

Log content display PCHunter_renwole.com.rar The file was successfully synchronized.

in addition lsyncd Is based on inotify + rsync Compared with other synchronization software, the open-source synchronization software is more secure and reliable, and takes less resources, but the configuration is slightly cumbersome.
lsyncd It also supports what kind of command to execute when a specified event is monitored. Because synchronization is triggered by time delay and cumulative event hit times, it is better than inotify In addition, its synchronization speed depends entirely on the quality of your network.