LoginSignup
10
10

More than 5 years have passed since last update.

macのapache2でsslとオレオレ証明書の設定

Posted at

オレオレ証明書作成

cd /private/etc/apache2

sudo sh -c "openssl genrsa 2048 > server.key"
sudo sh -c "openssl req -new -key server.key > server.csr"
sudo sh -c "openssl x509 -days 3650 -req -signkey server.key < server.csr > server.crt"

common name のみ設定する

httpd-ssl.conf有効化

/private/etc/apache2/httpd.conf

# Secure (SSL/TLS) connections
Include /private/etc/apache2/extra/httpd-ssl.conf

SSL の設定

以下はデフォルト変更してるのでちゃんとやるなら分離してください。

/private/etc/apache2/extra/httpd-ssl.conf
77行目あたりを修正
DocumentRoot "/LocalDir/public"
ServerName hogehoge.jp:443

また最終行あたりにディレクトリの設定も追加する

/private/etc/apache2/extra/httpd-ssl.conf
<Directory "/LocalDir/public">
    AllowOverride AuthConfig FileInfo Indexes Limit Options=All,MultiViews
    Options -MultiViews
    order deny,allow
    deny from All
    allow from localhost 127.0.0.1
</Directory>

apache再起動

sudo /usr/sbin/apachectl restart
10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10