参考链接: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04
sudo apt-get install -y php5-cli apache2 php5-cgi php5-curl
sudo apt-get install -y libapache2-mod-php5
sudo a2enmod php5
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/ai.whycan.cn.conf
修改 /etc/apache2/sites-available/ai.whycan.cn.conf 文件内容:
<VirtualHost *:80>
ServerAdmin admin@whycan.cn
ServerName ai.whycan.cn
ServerAlias ai2.whycan.cn
DocumentRoot /var/www/ai.whycan.cn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite ai.whycan.cn.conf
service apache2 reload
离线
开启url重写:
sudo a2enmod rewrite
修改配置文件: /etc/apache2/sites-available/ai.whycan.cn.conf
<VirtualHost *:80>
ServerAdmin admin@whycan.cn
ServerName localhost
ServerAlias ai2.whycan.cn
DocumentRoot /var/www/ai.whycan.cn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combinedOptions +FollowSymLinks
RewriteEngine On
RewriteRule ^/index.html /tts_test1.php
</VirtualHost>
离线