Welcome Guest, Not a member yet? Register   Sign In
Starting downstream of server root directory
#1

The user_manual says under Installation that, "Normally the index.php file will be at your root."  (Here on SL6, "root" means /var/www/html/ )  That's not going to happen.  I have lots of other web stuff running on my server and am trying to port a site (call it "foo") built with CodeIgniter by someone else, so I want this tree to start at /var/www/html/foo/ and that's where index.php goes.  It doesn't seem to work.  I've set base_url in /var/www/html/foo/application/config/config.php, but it seems to never find that file in the first place, presumably because it's looking under /var/www/html/ instead of under /var/www/html/foo/ -- Catch-22!  Or at least that's what seems to be happening.  How do I make it play nice with a its sitemates?  
Reply
#2

I'm not familiar enough with SL6 ( I assume you mean ScientificLinux 6 ) to advise specifically, but Apache, using virtual hosts, allows setting of the Document Root.  This points at your site root, ie:

DocumentRoot /var/www/html/foo/

Virtual hosts allow me to set base_url to the real uri:

config['base_url'] = 'http://foo.com';

If you're not running Apache, I'm afraid I cannot advise further.
CI 3.1 Kubuntu 19.04 Apache 5.x  Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing.
Clarity is desirable over Brevity every time.
Reply
#3

I do use Apache, but I am not fond of virtuality; I like to see where I really am. So... I am REQUIRED to use virtual hosts if I want to run CI on a host that does other things? That seems a little "my way or the highway" to me.
Reply
#4

(This post was last modified: 01-09-2015, 10:36 AM by Narf.)

(01-09-2015, 09:21 AM)JHBrewer Wrote: I do use Apache, but I am not fond of virtuality; I like to see where I really am.  So... I am REQUIRED to use virtual hosts if I want to run CI on a host that does other things?  That seems a little "my way or the highway" to me.

No, that is not the case. Setting the base_url to 'http://hostname/directory/' is absolutely fine (even with a bare IP address instead of a hostname).

If you can't reach the application at all however, the base_url setting isn't likely to be the cause. Check if you've properly set set the $system_path and $application_path variables in the index.php script and also your .htaccess / mod_rewrite rules (probably lacking RewriteBase or redirecting to '/index.php' instead of '/foo/index.php'; don't do both!)
Reply
#5

Thanks, that's a big relief. What seems to be happening here is that the <?=base_url()?> function (javascript, I presume?) embedded in lines such as

<link href="<?=base_url()?>assets/css/plugins.css" rel="stylesheet">

in the HTML generated by index.php is not being evaluated, but left in the HTML code as plain text. (I've checked a working version of the same site on a different server, and in that case base_url() is evaluated and the corresponding line of HTML is the explicit path, as expected.

I have javascript enabled, so that should not be the problem.

So it's not that base_url is set wrong in /foo/application/config/config.php but rather that <?=base_url()?> is not being recognized as a function and so is not being evaluated. I guess. Any idea why this would occur?
Reply
#6

Those are PHP short tags, which on some older versions of PHP are optional (so this indicates the server may be running an old version of PHP with short tags disabled). You can replace the <?=base_url()?> with <?php echo base_url(); ?>, which should at least get the script to execute properly.
Reply
#7

Hi again. Problem found: I didn't have PHP short-code enabled in my php.ini, but the guy who wrote the site originally assumed it would be turned on. Since I've never used it (old FORTRAN hacker, remember?) the short-code command looked like javascript to me and I misinterpreted the failure.

All okay now (AFAIK).

Thanks for your patience. -- Jess
Reply
#8

I would recommend doing as much as is within your power to get the version of PHP on your server upgraded. As mentioned in the PHP manual ( http://php.net/manual/en/ini.core.php#in...t-open-tag ), the <?= short tags are always available in versions of PHP from 5.4 onwards. While CI supports older versions of PHP, version 5.3 of PHP reached "end of life" in August, meaning it has not received any security patches in 4 months ( http://php.net/eol.php ).

I've been in the situation of having to pick a lot of this up from scratch myself, so I'll just add a note that client-side JavaScript will be enclosed in <script> tags, optionally with a lang or type attribute. One of the reasons the question mark is used at the start of the opening tag for many server-side languages is that it is not a valid character for an element name in HTML or XML, so no valid HTML element will start with <?.
Reply
#9

(01-09-2015, 09:21 AM)JHBrewer Wrote: ...So... I am REQUIRED to use virtual hosts if I want to run CI on a host that does other things? That seems a little "my way or the highway" to me.

Certainly not. I use virtual hosts in development since I can then keep multiple sites on the same machine and use a real domain name in my configuration. It's up to you.
CI 3.1 Kubuntu 19.04 Apache 5.x&nbsp; Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing.
Clarity is desirable over Brevity every time.
Reply
#10

You all do realize that there is a config option to rewrite short tags, even if the server has them disabled in php.ini...it's more bulletproof than JUST relying on the server to have them enabled. It first checks to see if they're enabled in php.ini and will only rewrite them to full php tags if it isn't.

/*
|--------------------------------------------------------------------------
| Rewrite PHP Short Tags
|--------------------------------------------------------------------------
|
| If your PHP installation does not have short tag support enabled CI
| can rewrite the tags on-the-fly, enabling you to utilize that syntax
| in your view files. Options are TRUE or FALSE (boolean)
|
*/
$config['rewrite_short_tags'] = TRUE; //FALSE by default
Reply




Theme © iAndrew 2016 - Forum software by © MyBB