一个搞前端交互的,总会遇到这样那样的,不需要写代码去解决的问题,怎么搞?
答:只能去大海里捞,问题很明确但答案不一定靠谱,因为回答的人不用去考虑你是否会给自己系统搞崩溃。
那么我只能把自己经过验证的答案整出来,问题细化,做个记录,同时帮助还在摸索该问题的人。
第一步:
1 cd /etc/apache2/sites-available/
第二步:
拷贝另为一份配置文件,名字就叫appstore
1 cp default ./appstore
第三步:
1 sudo vi appstore
修改默认配置:
1 <VirtualHost *:80> 2 ServerAdmin [email protected] 3 4 DocumentRoot /var/www 5 <Directory /> 6 Options FollowSymLinks 7 AllowOverride None 8 </Directory> 9 <Directory /var/www/> 10 Options Indexes FollowSymLinks MultiViews 11 AllowOverride None 12 Order allow,deny 13 allow from all 14 </Directory> 15 16 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 17 <Directory "/usr/lib/cgi-bin"> 18 AllowOverride None 19 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 20 Order allow,deny 21 Allow from all 22 </Directory> 23 24 ErrorLog ${APACHE_LOG_DIR}/error.log 25 26 # Possible values include: debug, info, notice, warn, error, crit, 27 # alert, emerg. 28 LogLevel warn 29 30 CustomLog ${APACHE_LOG_DIR}/access.log combined 31 32 Alias /doc/ "/usr/share/doc/" 33 <Directory "/usr/share/doc/"> 34 Options Indexes MultiViews FollowSymLinks 35 AllowOverride None 36 Order deny,allow 37 Deny from all 38 Allow from 127.0.0.0/255.0.0.0 ::1/128 39 </Directory> 40 41 </VirtualHost>
为:
1 <VirtualHost *:8080> //端口和地址 2 ServerAdmin [email protected] 3 4 DocumentRoot /var/www/appstore //环境路径(之前www是根目录,如果访问8080端口,那根目录就是appstore) 5 <Directory /> 6 Options FollowSymLinks 7 AllowOverride None 8 </Directory> 9 <Directory /var/www/appstore/> //环境路径 10 Options Indexes FollowSymLinks MultiViews 11 AllowOverride None 12 Order allow,deny 13 allow from all 14 </Directory> 15 16 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 17 <Directory "/usr/lib/cgi-bin"> 18 AllowOverride None 19 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 20 Order allow,deny 21 Allow from all 22 </Directory> 23 24 ErrorLog ${APACHE_LOG_DIR}/appstore_error.log //apache错误打印 25 26 # Possible values include: debug, info, notice, warn, error, crit, 27 # alert, emerg. 28 LogLevel warn 29 30 CustomLog ${APACHE_LOG_DIR}/appstore_access.log combined //apache进入错误打印 31 Alias /doc/ "/usr/share/doc/" 32 <Directory "/usr/share/doc/"> 33 Options Indexes MultiViews FollowSymLinks 34 AllowOverride None 35 Order deny,allow 36 Deny from all 37 Allow from 127.0.0.0/255.0.0.0 ::1/128 38 </Directory> 39 40 </VirtualHost>
第四步:
1 sudo vi ../ports.conf
增加:
1 NameVirtualHost *:8080 2 Listen 8080
第五步:
1 sudo a2ensite appstore
第六步:
1 sudo service apache2 restart
ok!访问8080端口地址试试
Ubuntu下通过apache建立虚拟主机
时间: 2024-10-11 21:11:38