小智 29
让他们听不同的端口,你会没事的.
默认Web端口为80.当您在浏览器中打开某个URL而未指定端口时,默认情况下使用80.
您可以将Web服务器配置为侦听其他端口,但您还需要在URL中明确指定它:
http://localhost:8080
Run Code Online (Sandbox Code Playgroud)
选择端口时请注意,您已在盒子上安装并运行的任何软件尚未使用此特定端口号.否则,正如您所猜测的那样,将会发生冲突.
PS就在几天前做重新安装我让IIS无法启动(看似没有理由).原来Skype的新版本占用了这个默认端口!不得不删除其设置"使用端口80和443作为传入连接的替代".
如果你真的想运行单独的服务器来测试服务器软件,请参阅其他答案,但......
听起来(因为你是开发人员,而不是系统管理员吧?)你真的只想在同一台计算机上运行Python和PHP站点.所以,请原谅我,如果我正在阅读您的问题,但这个设置允许我在同一台计算机上使用相同的端口(端口80)在Apache中运行两种类型的站点.
我在/ etc/hosts文件(或Windows上的C:\ Windows\System32\drivers\etc\hosts)中创建新条目并将它们指向127.0.0.1:
127.0.0.1 localhost
# development projects
127.0.0.1 somephpsite.com.local
127.0.0.1 www.somephpsite.com.local
127.0.0.1 otherpythonsite.com.local
127.0.0.1 www.otherpythonsite.com.local
Run Code Online (Sandbox Code Playgroud)
然后在Apache中我为每个站点添加VirtualHosts:
<VirtualHost *:80>
DocumentRoot "/Library/WebServer/Documents"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
<Directory "/Users/Robert/Projects/SomeSite/somephpsite.com">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
DocumentRoot "/Users/Robert/Projects/SomeSite/somephpsite.com"
ServerName somephpsite.com.local
ServerAlias www.somephpsite.com.local
ErrorLog "/Users/Robert/Projects/SomeSite/error.log"
CustomLog "/Users/Robert/Projects/SomeSite/access.log" common
</VirtualHost>
<VirtualHost *:80>
<Directory "/Users/Robert/Projects/OtherSite/otherpythonsite.com">
Order allow,deny
Allow from all
</Directory>
DocumentRoot "/Users/Robert/Projects/OtherSite/otherpythonsite.com/static"
Alias /(.*(\.css|\.gif|\.ico|\.jpg|\.js|\.pdf|\.txt)) /Users/Robert/Projects/OtherSite/otherpythonsite.com/static/$1
WSGIScriptAlias / /Users/Robert/Projects/OtherSite/otherpythonsite.com/wsgi.py
ServerName otherpythonsite.com.local
ServerAlias www.otherpythonsite.com.local
ErrorLog "/Users/Robert/Projects/OtherSite/error.log"
CustomLog "/Users/Robert/Projects/OtherSite/access.log" common
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
因此,PHP站点DocumentRoot就像他们一样运行.Python站点在WSGI中运行.他们都在Apache中运行.然后进行测试,我只需在我用于本地副本的任何浏览器中添加".local".
Web服务器绑定到特定端口.通常,这是端口80.如果未明确指定端口,则这是浏览器将尝试命中的端口.
您可以让备用服务器在不同的端口上运行(8080或8081似乎是Web服务器的流行服务器,但您可以选择它).
这将阻止冲突的发生.80端口的所有内容都会打到旧服务器.一切都到8080(或你决定运行你的服务器的任何端口)将打到你的简单python服务器.
要点击其他服务器,请使用以下网址: -
| 归档时间: |
|
| 查看次数: |
33984 次 |
| 最近记录: |