I have Web-Developer Server Suite, with PHP 5.25, which I downloaded from SourceForge.
My operating system is Windows 7 Home Edition.
I upgraded Apache to the latest version and will be upgrading PHP to 5.38 soon.
It works well, apart from one small problem; virtual hosts outside the main webroot
(C:/www/vhosts) do not display PHP scripts, or indeed any scripts at all; just the plain code. All virtualhosts work within C:/www/vhosts, but not any of the other locations I've declared in vhosts.
The other locations are:
C:/www/
C:/www/vhosts-test/
C:/www/businessweb/
C:/www/newmediasite/public_html/
This is despite the fact I declared the locations in httpd-vhosts.conf !
How would I get the server to understand PHP outside the main webroot, and also ASP.NET
(bear in mind I added mod_aspdotnet as well).
I'd gladly appreciate any advice on this; just spent a day-and-a-half rebuilding my webserver, moving files from a backup (all PHP and MySQL) after reinstalling Web-Developer Server Suite (which, IMHO, is pretty good for a beginner).
I'm not sure where to go with this, but I'll add, just for relevance, that this is strictly a development server for testing.
You can place your scripts in protected directory outside your Webroot so they are not accessible by your visitors.
However you need to place a script in your Webroot, that include these scripts. Most of the Firmwares implement a similar functionality.
<?php
require_once('/var/usr/myConfigDir/config.php');
?>
As I understand, only the directory configured as Webroot will be able to execute scripts. Already Apache adds a security layer for not executing scripts outside Webroot.
So if your target is to protect some of your scripts, you can do that, otherwise, I don't think it's possible.
From my understanding of your question, you want to be able to have your PHP files anywhere on your computer, yet have them still be able to execute. I do not believe this is possible, as PHP files are opened through the webserver i.e 127.0.0.1/foo.php instead of file://foo.php/
The webserver is configured to execute the files in /www, unless there is a setting somewhere (which I am unaware of) all PHP scripts will have to rest in /www.
Related
I've got a website which I need to move across to another server, however i've got a problem with the directory paths and how they've been setup throughout the whole site.
So on every page, there're includes that look like the following
<?php include($_SERVER['DOCUMENT_ROOT'].'/views/includes/header.php'); ?>
This setup works perfectly fine on its own server because the DOCUMENT_ROOT is fine, however, the issue i've ran into is that i've just brought this down onto my localhost where the DOCUMENT_ROOT is
/Applications/MAMP/htdocs
when i need it to look like this
/Applications/MAMP/htdocs/website-name
Is there anywhere in the Perch CMS or .htaccess where i can perhaps change the DOCUMENT_ROOT or otherwise without having to amend every single link?
Thanks.
If you have mod_rewrite activated in Apache, you could use a rewrite rule in .htaccess.
http://httpd.apache.org/docs/current/mod/mod_rewrite.html
$_SERVER is a global variable. You could also override it in an entry point PHP script.
I guess you're using the free MAMP where setting up hosts is a manual task? Now you're running the site in a subdirectory of the root, right?
I strongly recommend always running the CMS in the root. Running CMS in a subdomain is always trouble, in my experience. Also, you want your local and remote setup to be as similar as possible.
With MAMP PRO it's very easy to set up multiple roots, it's a good investment to avoid the hassle with manual apache configs. Works flawlessly.
I am working on a moodle based project, which I inherited from someone else. Having copied the files into htdocs folder and started MAMP, the files still don't show in the browser. Instead, the browser automatically initiates a download. I might be required to change the config file, however, since I do not have much experience with php and SQL I am not sure what exactly. My part of the project is to develop html and css, but need to be able to run it locally first.
What do I need to do to get the files run locally? The route I use is localhost:8888/whatever/whatever/index.php
In case someone else runs into the same problem - Apache downloads php files instead of reading them - here is what helped me.
.htaccess file may need changes if the application has changed servers.
Delete (at least rename if you don't want to remove it) config.php and run the application through the browser. It should initiate install automatically.
To run php and SQL I used MAMP.
I've installed Nginx + FPM-PHP under Debian and ArchLinux. Both are working fine. However, I can't figure out how to get the PHP part to follow symlinks. I've also tried with Lighttpd, but to no avail.
Here is what I want to do:
Root directory configured as usual: /srv/http
Symlinks from each project to /srv/http (example: /home/user/projects/site1 to /srv/http/#site1), in such a manner that to test a local development, I just need to add the name of the site to the URL: "http://localhost/site1/xyz" or "http://localhost/site2/abc", etc;
I can make it work (after fixing permissions) with html and other static files, but whenever there is a PHP script, I get the famous "Primary script unknown" error. Inside the "real root" directory (/srv/http) there is not such an error. But when I tried to copy a subdirectory to another location (ie /home/user/projects/xyz) and symlink it to /srv/http/, I get that error.
I've followed many tutorials, including excellent posts by a Danish guy. But I can't make it work. I've tried to use all combinations of "fastcgi_param SCRIPT_FILENAME", ALIAS, etc, including hardcoding another directory into it to make sure this was (or not) the cause of the problem.
So, here are the questions:
Is it possible to use symlinks for PHP execution under nginx or lighttpd?
This setup is for development only, is there a reason not to use it?
What kind of magic would be necessary to make it work?
Since the target environment is going to be nginx (there are other projects already working), I would like to stick to nginx for development, if possible. For the sake of speed, I would also use lighttpd too. I would like to avoid Apache (only because of resources), if feasible.
I installed Eclipse PDT for PHP development on my Ubuntu box (running Apache2 as server),
I tried to create a PHP project and run it as "PHP Web Application" as show in the picture:
But when I click "Run" the browser pops out and giving 404 error saying it cant find localhost/test/newfile.php .
Does Eclipe PDT having its own internal webserver? (If so, I tried by shutting down my Apache2 ,but still giving the same error)
Finally, as a work around, I changed my workspace location to "/var/www" and created my projects there. But wondering whether its the best way to develop using PDT?
The questions you ask are not directly related to Eclipse PDT but how to setup the development server.
I suggest not to move the project into the webroot but to make Apache visit your development/project directory instead.
There are multiple ways to do that:
You can create a symlink (softlink) making a URL-Path point to a directory. You need to allow Apache to follow symlinks.
You can make use of the Alias directive to do something similar.
Virtual Hosts to make the webserver point to the location you're looking for via it's domain name. You can then create "fake" domain names within your hosts file like example.com.loc for the local development version of your website.
You can even use mod_rewrite for that (not that good option).
As you can see there are multiple ways to have this in a manageable fashion. Depending on your needs, the symlink variant is probably most easy to accomplish. If you need more security, the Alias Directive is similarly easy to accomplish. Virtual hosts start to make sense if you're more familiar with apache configuration and you need more control of the URLs (some software is that dumb that it needs to reside on the top path / beneath an URL otherwise it just does not work (yeah, crap, but virtual hosts come to the rescue then). The mod_rewrite "solution" is just named for completeness reasons, it's more asking for trouble if you're not firm with mod_rewrite and as you're new to apache configuration, leave it next to your road and ignore that suggestion.
All these ways allow you to have one or more development projects next to static websites on your server. I personally have configured virtual hosts on my devbox, and on my earlier devbox I was just using alias directives.
Keep in mind that you need to restart the apache service if you edited the configuration:
$ sudo /etc/init.d/apache2 restart
And most importantly: Before you edit the configuration file, copy it over to a backup file-name. Always backup configuration files before you edit them. You don't want to loose the working settings, believe me ;)
I want to run different web app on different ports on same server, I have a apache php server running on a Linux machine. How can I achieve this ? and when I Google I stumble upon 'tomcat', what is this ? I am a noob, so please forgive if that is a stupid question.
Check the apache manual for the VirtualHost directive. It'll explain everything.
One thing to remember (it caught me out first time) - if you use virtual hosts, you have to define a virtual host for the default page too.
Don't worry about Tomcat at the moment. If you don't know what it is, you don't need it yet.
Step 1: Install the Tomcat files
Download Tomcat 4.1 or 5.5, and unzip it into an appropriate directory. I usually put it in /usr/local, so it ends up in a directory called /usr/local/apache-tomcat-5.5.17 (5.5.17 being the current version as of this writing), and make a symlink named /usr/local/tomcat to that directory. When later versions come out, I can unzip them and relink, leaving the older version in case things don’t work out (which rarely if ever happens, but I’m paranoid).
Step 2: Make directories for each instance
For each instance of Tomcat you’re going to run, you’ll need a directory that will be CATALINA_BASE. For example, you might make them /var/tomcat/serverA and /var/tomcat/serverB.
In each of these directories you need the following subdirectories: conf, logs, temp, webapps, and work.
Put a server.xml and web.xml file in the conf directory. You can get these from the conf directory of the directory where you put the tomcat installation files, although of course you should tighten up your server.xml a bit.
The webapps directory is where you’ll put the web applications you want to run on the particular instance of Tomcat.
I like to have the Tomcat manager webapp installed on each instance, so I can play with the webapps, and see how many active sessions there are. See my instructions for configuring the Tomcat manager webapp.