You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 16LTS Apache环境下为Alias配置SSL的技术求助

Setting Up SSL for Your Apache Site on Ubuntu 16.04 LTS

Hey there! Let's walk through setting up SSL for your Apache site step by step—since you're new to Linux, I'll keep things straightforward and skip overly confusing jargon.

  • First, make sure Apache's SSL module is enabled (this is required to handle HTTPS traffic). Run this command in your terminal:
    sudo a2enmod ssl
    
    You'll get a confirmation message if it works; if it's already enabled, no worries at all!

Option 1: Create a Self-Signed SSL Certificate (Testing/Internal Use)

Self-signed certs are free and easy for testing purposes, but browsers will show a security warning (they aren't verified by a trusted third-party authority).

  • Generate the certificate and private key in one go:
    sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt
    
    You'll be asked for details like country and state—most can be left blank, but be sure to fill in the Common Name with your server's IP address or domain name.
  • Create a strong Diffie-Hellman group to boost connection security:
    sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
    
    This might take a minute or two—just let it run in the background!

Option 2: Get a Trusted Free Certificate (Let's Encrypt, Public Sites)

If your server is accessible from the internet, Let's Encrypt provides free, trusted certificates that won't trigger browser security warnings.

  • Update your package list and install Certbot (the official Let's Encrypt client for Apache):
    sudo apt-get update
    sudo apt-get install certbot python-certbot-apache
    
  • Run Certbot to auto-generate and install the certificate:
    sudo certbot --apache
    
    Follow the on-screen prompts: enter your email address, agree to the terms of service, and select the domain you want to secure. Certbot will even update your Apache configuration files automatically!

Configure the SSL Virtual Host (For Self-Signed Certs)

If you went with the self-signed certificate option, you need to set up the SSL virtual host file manually:

  • Copy the default SSL config as a starting point:
    sudo cp /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-available/your-site-ssl.conf
    
  • Open the file with a beginner-friendly text editor like nano:
    sudo nano /etc/apache2/sites-available/your-site-ssl.conf
    
  • Double-check the certificate and key paths (they should already be set, but it's good to confirm):
    SSLCertificateFile      /etc/ssl/certs/apache-selfsigned.crt
    SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
    
  • Critical step: Add your Alias and directory permissions inside the <VirtualHost _default_:443> block (match what you have in your HTTP config):
    Alias /pccis_sample /usr/share/prizm/Samples/php
    
    <Directory /usr/share/prizm/Samples/php>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>
    
  • Save and close nano: press Ctrl+O, hit Enter to confirm, then Ctrl+X to exit.

Enable the SSL Site & Test Your Configuration

  • Enable your new SSL virtual host:
    sudo a2ensite your-site-ssl.conf
    
  • Test for configuration errors (always do this before restarting Apache!):
    sudo apache2ctl configtest
    
    If you see Syntax OK, you're ready to go. If not, double-check your config file for typos or missing lines.
  • Restart Apache to apply all changes:
    sudo systemctl restart apache2
    

Verify It Works

Open your browser and navigate to https://your-server-ip-or-domain/pccis_sample. For self-signed certs, you'll need to accept the browser's security warning (this is normal for testing environments). You should see your sample files just like you did over HTTP, but now with a secure HTTPS connection.


内容的提问来源于stack exchange,提问作者ChrisG

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:32:20