在默认 80 以外的其他端口上运行 magento [英] Running magento on other port than default 80

查看:46
本文介绍了在默认 80 以外的其他端口上运行 magento的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在端口 8080 上配置了 Apache 虚拟主机以指向我的 magento 网站.

I have configured Apache virtual hosting on port 8080 to point to my magento website.

        Listen 8080

        <VirtualHost 6x.2x.6x.1x:8080>

    ServerAdmin webmaster@localhost
    ServerName domainname.com
ServerAlias *.domainname.com
DocumentRoot /var/www/sites/domain/

    <Directory />
            Options FollowSymLinks
            AllowOverride all
            Order allow,deny
            allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined
    ServerSignature On

<LocationMatch ".*svn.*">
    Order allow,deny
    Deny from all
</LocationMatch>

           </VirtualHost>

当我访问www.domain.com:8080网站时,js、css、img等东西都没有加载,因为端口没有附加到链接上

When i go to the website www.domain.com:8080 the js, css, img and other things are not loaded because the port is not attached to the links

以下是 magento .htaccess 中的重写规则,但似乎不起作用:

Here is a rewrite rule in magento .htaccess that does not seem to work:

         <IfModule mod_rewrite.c>

############################################
## enable rewrites

    Options +FollowSymLinks
    RewriteEngine on

############################################
## you can put here your magento root folder
## path relative to web root

    #RewriteBase /magento/

############################################
## workaround for HTTP authorization
## in CGI environment

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

############################################
## always send 404 on missing files in these folders

    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php
    RewriteCond %{SERVER_PORT} !^8080$
    RewriteRule .* http://6x.2x.6x.1x:8080/index.php [L]

       </IfModule>

Rewrite-mod 是在不同端口上运行 magento 站点的正确解决方案吗?如果是,我在当前的 Rewrite 规则中的错误在哪里?

Is Rewrite-mod the right solution to run magento site on different port? If yes, where is my mistake in the current Rewrite rule?

谢谢,

玛格特

推荐答案

我管理一个 magento 站点,其中一个 live shop 在端口 80 上的一台服务器上运行,而开发站点在端口 3000 上的另一台服务器上运行.站点从实时到开发我需要做的就是更改 core_config_data 表中的两行,具有:

I manage a magento site where a live shop is running on one server on port 80 and a dev site is running on another server on port 3000. When copying the site from live to dev all I need to do is change two rows in the core_config_data table, having:

  • path="web/unsecure/base_url"
  • path="web/secure/base_url"

您需要在网址末尾添加您的端口号,仅此而已.就我而言,这两行如下所示:

You need to add your port number at the end of the url and that is all. In my case those two rows look like this:

(config_id, scope, scope_id, path,值)

(config_id, scope, scope_id, path, value)

(默认,0,网络/不安全/base_url,,http://www.dev-server.com:3000/)

(default, 0, web/unsecure/base_url, ,http://www.dev-server.com:3000/)

(默认,0,web/secure/base_url,,http://www.dev-server.com:3000/)

(default, 0, web/secure/base_url, ,http://www.dev-server.com:3000/)

请注意,我的开发服务器上没有证书,因此我没有使用 https 作为安全 base_url.如果您希望使用 https,则应将此设置更改为 https,并且最后应省略自定义端口.

Note that I don't have a certificate on my dev server so I am not using https as the secure base_url. If you wish to use https this setting should be changed to https and you should omitt the custom port at the end.

不需要修改标准的 .htaccess 文件,应该避免修改.

Modification of the standard .htaccess file is not needed, and should probably be avoided.

编辑

如果您无权访问数据库,您可以尝试创建一个 php 文件,该文件将使用 magento 修改数据库:

If you don't have access to the DB you can try creating a php file which will modify the database using magento:

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

require_once ( "app/Mage.php" );
Mage::app('default');

$db = Mage::getSingleton('core/resource')->getConnection('core_write');

$db->query("UPDATE `core_config_data` SET `value` = 'http://dev-server.com:3000/' WHERE `path` = 'web/secure/base_url';");

$db->query("UPDATE `core_config_data` SET `value` = 'http://dev-server.com:3000/' WHERE `path` = 'web/unsecure/base_url';");
?>

您需要将此文件放在根 magento 文件夹中,或者如果您将其放在其他地方,请将路径更改为 Mage.php.

You need to put this file in the root magento folder or change the path to Mage.php if you put it somewhere else.

这篇关于在默认 80 以外的其他端口上运行 magento的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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