| #
apt-get install apache2 |
| # a2enconf [コンフィグレーション].conf |
| # a2disconf[コンフィグレーション].conf |
| # a2ensite [コンフィグレーション].conf |
| # a2dissite [コンフィグレーション].conf |
| # a2enmod [コンフィグレーション].conf |
| # a2dismod[コンフィグレーション].conf |
| #
systemctl reload apache2 |
| # AddDefaultCharset UTF-8 |
| # a2disconf charset.conf # a2enconf charset.conf |
ServerTokens Prod <--- Full をProdに変更。サーバーの情報(バージョン、OSなど)を表示しないように ServerSignature Off |
| #a2disconf security.conf #a2enconf security.conf |
| #
a2enmod cgi |
| <VirtualHost *:80>
<-----ポート番号指定 ServerName hoge.com ServerAlias hoge.com DocumentRoot /home/hoge/public_html/ <Directory /home/*/public_html> Options ExecCGI Indexes FollowSymLinks MultiViews Includes <ーーーー (CGI,SSIが動くようにExecCGI Includesを追加) AllowOverride None Order allow,deny allow from all ServerSignature Off <--- サーバー情報を表示しないようにする AddHandler cgi-script .cgi .pl <---- *.cgiとPerlのCGIを動かす AddType text/html .rhtml .shtml <---------- rubyのcgiや.shtmlも動かす </Directory> </VirtualHost> |
| apache2ctl configtest |
| #a2dissite
000-default.conf #a2ensite hoge.example.com.conf #systemctl reload apache2 |
| <Directory
"/home/*/public_html/"> Options +ExecCGI AddHandler cgi-script .cgi .pl .py .rb </Directory> |
| #a2enconf
cgi-enabled.conf #systemctl reload apache2 |
| #!/usr/bin/ruby -Ku #ヘッダー部 puts "Content-Type: text/html" puts #ここでひとつ改行コードを送る #body部 print <<"EOB" <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf8"> <title>Ruby!</title> </head> <body> <h3>Hello</h3> <p>これは、おためしサンプルです。</p> </body> </html> EOB |
| $ chmod 755 tameshi.cgi |
| #SSLRequireSSL AuthType Basic AuthName "ユーザー名とパスワードを入れて下さい" AuthUserFile /home/karappi/.htpasswd require valid-user |
| AllowOverride All |
| apt-get install certbot
python3-certbot-apache |
| # apache2ctl
configtest # Syntax OK |
| # ufw status Status: active To Action From -- ------ ---- 22 ALLOW Anywhere 80 ALLOW Anywhere 443 ALLOW Anywhere 22 (v6) ALLOW Anywhere (v6) 80 (v6) ALLOW Anywhere (v6) 443 (v6) ALLOW Anywhere (v6) # |
| # certbot --apache Saving debug log to /var/log/letsencrypt/letsencrypt.log Enter email address or hit Enter to skip. (Enter 'c' to cancel): hoge@hogehoge.co.jp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please read the Terms of Service at: https://letsencrypt.org/documents/LE-SA-v1.8-July-06-2026.pdf You must agree in order to register with the ACME server. Do you agree? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing, once your first certificate is successfully issued, to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y Account registered. Which names would you like to activate HTTPS for? We recommend selecting either all domains, or all domains in a VirtualHost/server block. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: karappi.mydns.jp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown (Enter 'c' to cancel): 1 Requesting a certificate for karappi.mydns.jp Successfully received certificate. Certificate is saved at: /etc/letsencrypt/live/karappi.mydns.jp/fullchain.pem Key is saved at: /etc/letsencrypt/live/karappi.mydns.jp/privkey.pem This certificate expires on 2026-11-21. These files will be updated when the certificate renews. Certbot has set up a scheduled task to automatically renew this certificate in the background. Deploying certificate Successfully deployed certificate for karappi.mydns.jp to /etc/apache2/sites-available/karappi.mydns.jp-le-ssl.conf Congratulations! You have successfully enabled HTTPS on https://karappi.mydns.jp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - If you like Certbot, please consider supporting our work by: * Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate * Donating to EFF: https://eff.org/donate-le - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # |
| # systemctl
status certbot.timer ● certbot.timer - Run certbot twice daily Loaded: loaded (/usr/lib/systemd/system/certbot.timer; enabled; preset: enabled) Active: active (waiting) since Sun 2026-08-23 16:26:56 JST; 53min ago Invocation: f061bea03eb745a7b31e202e496df012 Trigger: Mon 2026-08-24 06:22:52 JST; 13h left Triggers: ● certbot.service 8月 23 16:26:56 kogera systemd[1]: Started certbot.timer - Run certbot twice daily. # |
| # certbot
renew --dry-run |