A note on server construction.
Put the Ubuntu ISO file on a disk or put it on a USB. Then boot the server's BIOS and proceed with the install. As introduced in the link below, it's OK. Ubuntu installation procedure
--Ubuntu default root user password is not set. ――Recently, I rarely use root, but just in case.
sudo passwd root
Enter the following commands in order.
sudo apt update
sudo apt upgrade
sudo reboot
sudo timedatectl set-timezone Asia/Tokyo
sudo apt -y install language-pack-ja
sudo nano /etc/default/locale
# 「LANG=ja_JP.UTF-8 ”
sudo reboot
export LANG=C
• teraterm • WinSCP Download WinSCP Impression that teraterm is basically enough. WinSCP plays an active role in sending files from the server side to the host.
Drag and drop id_rsa.pub to teraterm. Designated and transmitted as "~ /" by SCP. Start the server by selecting "File"-> "New Connection". Enter the following command
mkdir -p ~/.ssh
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
rm ~/id_rsa.pub
sudo vim /etc/ssh/sshd_config
First, change "no" to "yes" in "HostbasedAuthentication.no" on the 48th line. HostbasedAuthentication no HostbasedAuthentication yes
Line 56 # PasswordAuthentication Take # of yes and change yes to no PasswordAuthentication yes PasswordAuthentication no
After saving the setting file, to reflect the setting contents
sudo systemctl restart ssh
Do not close the currently connected Tera Term window, which will be explained next. (Because you need to fix it if it doesn't work)
sudo apt update
sudo apt -y install samba
systemctl status smbd
systemctl status nmbd
Make sure it is active
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.org
sudo vim /etc/samba/smb.conf
/etc/samba/smb.conf
[global]
workgroup = SOTECHSHA
dos charset = CP932
unix charset = UTF8
[share]
comment = Ubuntu Server
path = /var/share
browsable = yes
writable = yes
create mask = 0777
directory mask = 0777
Execute the following command. adduser is a user who cannot log in for samba registration. It may be better to have a descriptive name when connecting.
sudo systemctl restart smbd
sudo systemctl restart nmbd
sudo mkdir /var/share
sudo chmod 777 /var/share
sudo adduser --disabled-login user1
User registration is OK with only full name and no input
sudo pdbedit -a user1
\\(Server host name)
or
\\(IP address)
You can connect by entering the "user name" and "password" from.
sudo apt update
sudo apt -y install apache2
ls /var/www/html
ls /etc/apache2
less /etc/apache2/apache2.conf
sudo a2enmod cgi
sudo systemctl restart apache2
cd /var/www/html
sudo vim cal.html
Edited to the following contents.
cal.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>input form</title>
</head>
<body>
<form action="cgi-bin/cal.sh" method="GET">
<h3>Please enter five numbers</h3>
<p>
Number 1: <input type="text" name="valuel" size="3"><br>
Number 2: <input type="text" name="value2" size="3"><br>
Number 3: <input type="text" name="value3" size="3"><br>
Number 4: <input type="text" name="value4" size="3"><br>
Number 5: <input type="text" name="value5" size="3">
</p>
<p>
<input type="submit" value="Send"><input type="reset" value="reset">
</p>
</form>
Create a file.
cd /usr/lib/cgi-bin
sudo vim cal.sh
Edit the contents.
cal.sh
#! /bin/bash
SUM=0
VALUE=$ (echo ${QUERY_STRING} | tr '=&' " ¥n" | awk '{print $2}')
for i in ${VALUE}
do
SUM=$((SUM + i))
done
cat << EOF
Content-type: text/html; charset=UTF-8
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8"> <title>Addition result</title>
</head>
<body>
<h3>If you add 5 numbers</h3>
<p>
${SUM}
</p>
</body>
</html>
EOF
Edit permissions
sudo chmod +x cal.sh
Access http: // Ubuntu Server IP address /cal.html
If I go further, I will add and edit. (As of October 01, 2020)
Recommended Posts