kernel-devel

kernel-devel is necessary to build modules such as devices
On CentOS(rpm-based OS), install Linux Kernel-devel with consistency with kernel
By the way, kernel-devel seems to contain the minimum source necessary for building modules

[vagrant@localhost ~]$ rpm -qa | grep kernel
kernel-devel-2.6.32-754.2.1.el6.x86_64
kernel-2.6.32-754.3.5.el6.x86_64
kernel-firmware-2.6.32-754.3.5.el6.noarch
dracut-kernel-004-411.el6.noarch
kernel-headers-2.6.32-754.3.5.el6.x86_64
kernel-devel-2.6.32-754.3.5.el6.x86_64
kernel-2.6.32-754.2.1.el6.x86_64
kernel-2.6.32-642.el6.x86_64

kernel-devel, kernel-headers ともに入ってますね。

kernel-headers
A C language header file related to the kernel is packaged.
It is necessary for rebuilding the kernel and compiling system related programs.

[vagrant@localhost ~]$ rpm -qi kernel-headers
Name : kernel-headers Relocations: (not relocatable)
Version : 2.6.32 Vendor: CentOS
Release : 754.3.5.el6 Build Date: 2018年08月15日 06時04分13秒
Install Date: 2018年10月07日 19時48分45秒 Build Host: x86-01.bsys.centos.org
Group : Development/System Source RPM: kernel-2.6.32-754.3.5.el6.src.rpm
Size : 2776586 License: GPLv2
Signature : RSA/SHA1, 2018年08月15日 10時59分21秒, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem
URL : http://www.kernel.org/
Summary : Header files for the Linux kernel for use by glibc
Description :
Kernel-headers includes the C header files that specify the interface
between the Linux kernel and userspace libraries and programs. The
header files define structures and constants that are needed for
building most standard programs and are also needed for rebuilding the
glibc package.

ん? Linux kernelのことか?

[vagrant@localhost ~]$ rpm -ql kernel-headers | more
/usr/include/asm
/usr/include/asm-generic
/usr/include/asm-generic/auxvec.h
/usr/include/asm-generic/bitsperlong.h
/usr/include/asm-generic/errno-base.h
/usr/include/asm-generic/errno.h
/usr/include/asm-generic/fcntl.h
/usr/include/asm-generic/int-l64.h
/usr/include/asm-generic/int-ll64.h
/usr/include/asm-generic/ioctl.h
/usr/include/asm-generic/ioctls.h
/usr/include/asm-generic/ipcbuf.h
/usr/include/asm-generic/mman-common.h
/usr/include/asm-generic/mman.h
/usr/include/asm-generic/msgbuf.h
/usr/include/asm-generic/param.h
/usr/include/asm-generic/poll.h
/usr/include/asm-generic/posix_types.h
/usr/include/asm-generic/resource.h
/usr/include/asm-generic/sembuf.h
/usr/include/asm-generic/setup.h
/usr/include/asm-generic/shmbuf.h
/usr/include/asm-generic/shmparam.h

テキストエリア内の改行をmysqlに格納する

echo nl2br("これ\r\nは\r\nどう表示される");

<?php

$content = $_POST&#91;'content'&#93;;
if(!empty($content)){
		echo nl2br($content);
} else {
}
?>

<form method="post" action="/">
	<textarea name="content" rows="4" cols="40"></textarea>
	<input type="submit" value="送信">
</form>

なるほどー

あれ、まてよ。pdoでmysqlに入れてみます。

$content = $_POST['content'];
if(!empty($content)){
		$value = nl2br($content);
} else {
}

try {
$pdo = new PDO('mysql:host=localhost;dbname=test;charset=utf8','root','',
array(PDO::ATTR_EMULATE_PREPARES => false));
} catch (PDOException $e) {
 exit('データベース接続失敗。'.$e->getMessage());
}
$stmt = $pdo -> prepare("INSERT INTO news (content) VALUES (:content)");
$stmt->bindParam(':content', $value, PDO::PARAM_STR);
$stmt->execute();
echo "成功";


?>

<form method="post" action="/">
	<textarea name="content" rows="4" cols="40"></textarea>
	<input type="submit" value="送信">
</form>
mysql> alter table news change content content varchar(100);
Query OK, 4 rows affected (0.24 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> describe news;
+---------+--------------+------+-----+---------+----------------+
| Field   | Type         | Null | Key | Default | Extra          |
+---------+--------------+------+-----+---------+----------------+
| id      | int(11)      | NO   | PRI | NULL    | auto_increment |
| content | varchar(100) | YES  |     | NULL    |                |
+---------+--------------+------+-----+---------+----------------+
2 rows in set (0.03 sec)

mysql> select * from news;
+----+----------------------------------+
| id | content                          |
+----+----------------------------------+
|  1 | テスト                           |
|  2 | 10byte以上を入                   |
                    |
                    |
|  5 | ほげほげ
ふぉおお | +----+----------------------------------+ 5 rows in set (0.00 sec)

なんだ、行けるじゃん。
textareaで改行した値をmysqlに格納することは可能。

service httpd restart

check the status of Apache
[vagrant@localhost ~]$ /etc/init.d/httpd status
httpd status unknown due to insufficient privileges.

restart apache
[vagrant@localhost ~]$ sudo service httpd restart
httpd を停止中: [ OK ]
httpd を起動中: httpd: Could not reliably determine the server’s fully qualified domain name, using localhost.localdomain for ServerName
[ OK ]

.htaccess

Web server configuration file for each directory that can be used in an environment where software such as Apache is used.
When this is installed in a specific directory, the contents described in “.htaccess” are applied to the directory in the installed directory and directory under it.

How to make .htaccess file
1. create and save a file named “.htaccess” with text editor.
2. describe what you want to control and configure with apache and save.
3. uploaded to the server and renamed to “.htaccess”

1. Basic authentication
It is a mechanism for forcing ID and password input with authentication in the directory etc.
If you want to play the site before publishing with users and Google bot.
If you want to publish it only to those who know the ipass.

AuthUserfile /fullpath/.htpasswd
AuthGroupfile /dev/null
AuthName "Please enter your ID and password"
AuthType Basic
require valid-user

2. 301 Redirect
It is the transfer method most used in SEO, which can inherit evaluation from old page to new page. It is called permanent relocation, and it is used for URL change and domain transfer.

RewriteEngine on
RewriteRule ^old.html$ http://sample.com/new.php [R=301,L]

3. URL normalization
It refers to unifying the URL to one. For example, in the following cases, Google recognizes each as a different URL, but generally the same page is displayed.

RewriteEngine on
RewirteCond %{THE_REQUEST} ^.*/index.html
RewirteRule ^(.*)index.html$ http://sample.com/$1 [R=301,L]

RewriteEngine on
RewirteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ http://sample.com/$1 [R=301,L]

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*)$ http://www.sample.com/$1 [R=301,L]

4. Abort of file list display
It is used to eliminate the security concern that the directory structure is exposed to the outside.
When there is an access ending with “/” like http://www.example.com, “index.html” that directory will be called instead.
However, if the index.html file can not be found, the file list in the directory shown.
Publishing the directory in this way will expose the structure of the website and there is certain risk from the security point of view. Therefore, by canceling the file list display in the directory, it is possible to prevent publication of the directory structure.

Options -Indexes

5. Access restriction from specific IP address and domain
You can restrict / deny access from a specific IP address or domain.
Alternatively, you can only allow access from a specific IP address or domain.

order allow,deny
allow from all
deny from sample.com
deny from 192.168.1.1

order deny,allo
deny from all
allow from sample.com
allow from 192.168.1.1

<files test-file.html>
	order deny,allow
	deny from all
	allow from sample.com
	allow from 192.168.1.1
</files>

sh

A shell is a program that interprets and executes commands. Work on linux system is done on the termimnal.
A program(shell) that interprets and executes commands to be entered for each terminal when loggin in to the linux system. It starts to work. There are several kind of shells, and users can select a shell to execute according to their preference.

mount -r /ev/cdrom /media/cdrom

mount is a command to do or mount work which embeds a disk device in the directory of Linux and makes it usable.
Today, the disk device ranges from CD, DVD, Blue-ray Disc, external hard disk, USB memory and so on. Disk devices are called file systems on Linux. All of them can be set to be usable with the mount command.

Basic of “mount”
The way to check the current mounting status is easy as follows.

mount
[vagrant@localhost tests]$ mount
/dev/mapper/VolGroup-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vagrant on /vagrant type vboxsf (uid=500,gid=500,rw)

The current mounting status is displayed. Information on where called a mount point is located, the type of the file system whether other read / write is possible, and the like are displayed.

-r option: read-only
The -r option is an option to mount read-only and the format is as follows.

$mount -r -t ${type} ${device} ${mount directory}

The command to mount the device /dev/cdrom read-only on the mount point/media/cd is as follows.

$ mount -r -t iso9660 /dev/cdrom /media/cd
mount -r /dev/cdrom /media/cdrom

VBoxManage storageattach CentOS-6.4-x86_64-minimal

Assign virtual DVD drive
Like the virtual hard disk, assign a virtual DVD drive. The installation media specifies Cent-6.4- x86 – minimal.iso.

$ VBoxManage storageattach CentOS-6.4-x86_64-minimal --storagectl SATA --port 2 --type dvddrive --medium I:/ISO/CentOS/CentOS-6.4-x86_64-minimal.iso
$ VBoxManage storageattach ${guest-os} \
  --storagectl IDE \
  --port 1 \
  --device 0 \
  --type dvddrive \
  --medium ${iso}

yum update kernel

[vagrant@localhost tests]$ uname -a
Linux localhost.localdomain 2.6.32-754.3.5.el6.x86_64 #1 SMP Tue Aug 14 20:46:41 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

VBoxManage controlvm “guest OS”

Operate specified guest OS

%VBoxManage controlvm "guest os" [ poweroff  | savestate | reset | pause | resume ]

The second argument in controlvm specifies the control option

Added port forwarding settings from the command line in VirtualBox

VBoxManage controlvm "guest OS" natpf1 "nginx,tcp,127.0.0.1,8080,,80"

In this sample, port forwarding 8080 of localhost to port 80.

VBoxManage controlvm "guest OS" natpf1 ssh,tcp,,22022,,22