Install
apt -y install apache2
確認
apachectl -V
systemctl status apache2
curl http:
停止と起動
systemctl stop apache2
systemctl start apache2
userdir を 有効化する
ls -l /etc/apache2/mods-enabled/
a2enmod userdir
ls -l /etc/apache2/mods-enabled/
systemctl restart apache2
一般ユーザで
cd
chmod 755 .
mkdir public_html
vi public_html/index.html
curl http:
CGI を有効化 (非一般ユーザ)
ls -l /etc/apache2/mods-enabled/
a2enmod cgid
ls -l /etc/apache2/mods-enabled/
systemctl restart apache2
設定を確認する
cat /etc/apache2/conf-enabled/serve-cgi-bin.conf
<IfModule mod_alias.c>
<IfModule mod_cgi.c>
Define ENABLE_USR_LIB_CGI_BIN
</IfModule>
<IfModule mod_cgid.c>
Define ENABLE_USR_LIB_CGI_BIN
</IfModule>
<IfDefine ENABLE_USR_LIB_CGI_BIN>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
</IfDefine>
</IfModule>
CGIのファイル置き場が "/usr/lib/cgi-bin/" であることを確認。
vi a.c
cat a.c
void main(){
printf("Content-type: text/html\n\n");
printf("Hello, CGI");
}
gcc a.c -o /usr/lib/cgi-bin/a.cgi
curl http:
CGI を有効化 (一般ユーザ)
cp /etc/apache2/mods-available/mime.conf /etc/apache2/mods-available/mime.conf.org
vi /etc/apache2/mods-available/mime.conf
diff /etc/apache2/mods-available/mime.conf.org /etc/apache2/mods-available/mime.conf
cp /etc/apache2/mods-available/userdir.conf /etc/apache2/mods-available/userdir.conf.org
vi /etc/apache2/mods-available/userdir.conf
diff /etc/apache2/mods-available/userdir.conf.org /etc/apache2/mods-available/userdir.conf
systemctl restart apache2
curl http:
#apache #apache2 #cgi #ubuntu