Apache在测试服务器上设置多个项目 [英] Apache Setup Multiple Project On Test Server

查看:96
本文介绍了Apache在测试服务器上设置多个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Virtualbox上使用CentOS 7和Apache.

I'm using CentOS 7 and Apache on my Virtualbox.

此VM具有自己的IP地址(XXX.XX.XX.XX).

This VM has its own IP address (XXX.XX.XX.XX).

在下面具有此设置,我可以通过输入 http://XXX.XX.XX.XX

Having this setting below, I can access my project on the browser by typing http://XXX.XX.XX.XX

<VirtualHost *:80>       
  DocumentRoot /var/www/html/project_name/public/       

  <Directory /var/www/html/project_name/> 
    AllowOverride All 
  </Directory> 

  ErrorLog /var/log/apache2/project_name-error_log 
  CustomLog /var/log/apache2/project_name-common_log combined
</VirtualHost> 

我的问题是我还有另一个将在此计算机上运行的Web应用程序项目.

My problem is I have another web app project that will run on this machine.

我可以配置使用以下不同的端口号访问两个项目的地方吗?

Can I configure wherein the two projects will be accessible using different port numbers like below?

http://192.168.10.1:8001
http://192.168.10.1:8002

解决方案:

这是我对其进行管理的方式:

Here's how I managed it to make it work:

Listen 8001
Listen 8002 

<VirtualHost *:8001> 
ServerName ipaddress:8001 

<VirtualHost *:8002> 
ServerName ipaddress:8002

推荐答案

<VirtualHost *:80>
        ServerName www.example.com
        DocumentRoot /var/www/html/project_name/public/
</VirtualHost>
<VirtualHost *:80>
        ServerName example.com
        DocumentRoot /var/www/html/project_name/public/
</VirtualHost>


<VirtualHost *:80>
        ServerName www.abc.com
        DocumentRoot /var/www/html/project_name1/public/
</VirtualHost>
<VirtualHost *:80>
        ServerName abc.com
        DocumentRoot /var/www/html/project_name1/public/
</VirtualHost>

尝试一下.在配置中,您可以在同一端口80上设置具有不同目录的多个域

Try this. Inside config you can set multiple domain with different directory on same port 80

第二个选项的运行方式类似于 http://xx.xxx.xxx.xx/project1 http://xx.xxx.xxx.xx/project2

Second option running like http://xx.xxx.xxx.xx/project1 and http://xx.xxx.xxx.xx/project2

在项目文件夹中的.htaccess中设置

set up in .htaccess inside project folder

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond  %{REQUEST_URI}  !^/mm.*$
    RewriteRule ^(.*)$ public/$1 [L,QSA]

    RewriteCond  %{REQUEST_URI}  ^/mm.*$
    RewriteRule ^/mm/(.*)$ public/mm/$1 [L,QSA]
</IfModule>
AddDefaultCharset utf-8

这篇关于Apache在测试服务器上设置多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆