I am installing Smarty on Ubuntu. I follow the installation notice:
placing libraries under usr/local/lib/php/Smarty;
creating smarty directories under var/ (as far as I understand, that must not be placed under the web server document root directory);
creating my project under the root directory var/www/ with a php file for executing the application.
I does not work so far, because, as I suppose, any php file outside the server root directory var/www/ is not readable by php.
How can I manage to both place those libraries .php files outside the root server directory and having them read by php?
Where did I make a mistake?
Thank you for your help.
Victor
Related
i'm new to bluemix, and don't know how to change the default index to look to public folder of the zend application, so have a php starter build, pushed the application to server, and when i call my_url, it's showing the default index file, and when i type my_url/public it's showing the zend index page ( obviously ).I want when i type my_url/ to take me to public/ folder by deafult.
So has anyone had this kind of "problem"... Searched on their forums, but there is nothing about this case...
Check out the docs here. https://github.com/cloudfoundry/php-buildpack/blob/master/docs/usage.md
The easiest way to use the build pack is to put your assets and PHP files into a directory and push it to CloudFoundry. When you do this, the build pack will take your files and automatically move them into the WEBDIR (defaults to htdocs) folder, which is the directory where your chosen web server looks for the files.
Additionally if you place anything in the lib dir it will not be publically aviailable.
If you place a file in root of your app called .bp-config/options.json you can override the htdocs dir.
https://github.com/cloudfoundry/php-buildpack/blob/master/docs/config.md#httpd-nginx-and-php-configurations
WEBDIR Set a custom location for your web or public files. This is the root directory from which the web server will host your files and the root directory from which PHP-FPM will look for your PHP files. Defaults to htdocs. Other common settings are public, static or html. Path is relative to /home/vcap/app.
I have a VPS and use PHP 5.5 and Apache 2.2 on a 64bit CentOS.
I have many domains on this VPS that used a shared library named core.
each Domain redirect to a directory with same name in apache html's directory. to be clear, this directory's structure is like this:
cd /var/www/html/
ls
core
site1_dir
site2_dir
site3_dir
site4_dir
...
for example http://www.site1.com root directory is /var/www/html/site1_dir
but there are many files and libraries in core that can't be address like this:
http://www.site1.com/../core/etc
so i created an empty folder, named core in each site's directory and i want to put a .htaccess file in them, in ordor to access core contents in each domains. for example:
http://www.site1.com/core/js/script.js must be a direct link from /var/www/html/core/js/script.js .
creating this .htaccess file is my question, and any other given options will be useful for me.
You should be able to create a symlink in each dir to the upper core dir and then work the files that way.
I am having a lot of headaches with the Smarty PHP Template Engine - Version 2.6.0 (smarty.net)
An error I keep getting in my error_log is
PHP Fatal error: Smarty error: unable to write to $compile_dir
'/var/www/vhosts/domain/library/templates/compiled'. Be sure
$compile_dir is writable by the web server user. in
/var/www/vhosts/domain/library/Smarty-2.6.0/libs/Smarty.class.php on
line 1088
I have made the folder and files writable with permissions set to 777 but still this error keeps happening.
It is making updating the template files a nightmare as currently I am updating the code in two places -> the templates folder and the compiled folder. It's like no compilation is happening so editing the already compiled file is the only way I can make a change to the site.
However, I had a template file that was being included in another template file and this was not in the compiled directory. After making a simple text change in this file has now completely removed that section of the site and the page just breaks that section is supposed to appear.
I am completely stumped with this and am hoping some of you with Smarty experience will be able to help me out.
Thank you in advance.
make sure you assign the compile dir in the smarty configuration file
here is sample of the config i use and it's working fine with me
/////Smarty including
require_once('libs/Smarty.class.php');
$smarty = new Smarty();
$smarty->template_dir = 'template'; // template folder
$smarty->compile_dir = 'cache'; // Create a Folder Cache with 777 Permission
This Settings works fine with latest smarty edition Smarty 3.x.
You need to edit the file httpd.conf
vim +231 /etc/httpd/conf/httpd.conf
See what User and and Group are specified there,
if for example you see this:
User asterisk
Group asterisk
Then you need to give permission to that user/group on the directory /var/www/
chown -R asterisk:asterisk /var/www/
Sorry for you advanced guys, I'm actually teaching myself some PHP so this may seem like a beginner's question.
I'm using a testing server and then uploading to a remote server. The index.php file is located in "C:\XAMPP\htdocs\php_site" on my local pc and in "home/www/myname.atwebpages.com/" on the remote server. Now the code I'm trying to run is just a simple:
define ('ROOT', $_SERVER['DOCUMENT_ROOT']);
include ROOT."menu/menu.php";
This code works fine for the remote server. However, when attempted on my local machine, it spits out this error:
Warning: include(C:/XAMPP/htdocs/menu/menu.php): failed to open stream: No such file or directory in C:\XAMPP\htdocs\php_site\index.php on line 21
Clearly, it's not looking in the php_site folder. Instead, it's tying to find a menu folder in the htdocs directory, but it's not there. The menu folder is located inside the site folder, php_site. If I chance around the code to work on the local machine, it no longer works on the remote server. I'm a little confused as to how to get around this problem.
I think $_SERVER['DOCUMENT_ROOT'] is defined by apache, so you'd need to change the config there. Or, define the ROOT constant relative to where you actually put your files, so if you do something like:
define ('ROOT', dirname(__FILE__));
Put that in a constants file in the same folder as your index.php.
Your document root on the remote and local machines is different. On your local machine your document root is the htdocs directory, and the php_site folder is merely a sub-folder, and thus the path is wrong.
I suggest either making the ROOT directory be a relative directory to the index page, or have a constants file in the root directory of the PHP site that defines the root directory as the directory it is in (which would be in the php_site directory on your local machine, the same directory as your index page). define ('ROOT', dirname(__FILE)); would work in this situation.
Another idea is to use a try-catch to catch the failure of the include statement, and attempt to try another directory, perhaps using define ('ROOT', $_SERVER['DOCUMENT_ROOT']); first, and if it fails, attempt to use define ('ROOT', $_SERVER['DOCUMENT_ROOT'] . 'php_site/'); instead.
I'm trying to build a project deployment tool, and part of it needs to export a repo from a working copy within PHP.
My directory structure is like
/
- dir1
- dir2
- versioned
and I want to export the 'versioned' directory. So I have
svn_export('/dir1/dir2/versioned', 'source');
but for some reason, I get this error:
svn_export(): svn error(s) occured 155007 (Path is not a working copy directory) '/dir1/dir2' is not a working copy 2 (No such file or directory) Can't open file '/dir1/dir2/.svn/entries': No such file or directory
So for some reason this is speaking about 'dir2', not 'versioned'. Is there a reason for this? Is there something about this implementation I'm not getting?
Thanks!
Where is the root of the repository? You need to make it a relative path -- as your code stands, it looks in the root directory for /dir1 (root of the server, not the html root)
Somehow I overlooked like 3 times that I was using a repo that didn't exist anymore