Server/port noob here. I just downloaded the latest Apache for my Mac OS X Lion. When I type in http: //localhost/ (no space), it comes up with a web page that says "It works." However, I can't get any other web page to open. I'm trying to get it to read a PHP document for a mobile web application, but it keeps 404ing and saying the document doesn't exist (the only document it has read thus far is the index.html document that says "It works"). I have tried things like http: //local host/User/directoryofthemobileapp/index.php, and all sorts of things like that, then I tried dropping a copy of the mobile app into the folder with the "It works" html doc, and it still failed to recognize it. The path of the "It works" doc is /Library/WebServer/Documents/index.html.en, but this information hasn't helped me yet. I have tried a lot of different URLs to access documents on my Mac, but to no avail.
Thanks in advance! Help is appreciated!
change the contents of index.html.en
put this in it
<?php
phpinfo();
?>
if that works, it should tell you that php is indeed setup correctly and where all your directories are
If you're looking to do some PHP development I recommend setting yourself up with what's known as a MAMP Stack. It stands for Mac, Apache, PHP, MySQL.
There's a great (free) program here that lets you set it all up easily:
http://www.mamp.info/en/index.html
From MAMP's easy interface you can set the Apache document root manually to any location on your Mac so you can start serving files locally.
Once you feel a bit more comfortable with the configuration and the server side technologies, I can't recommend Vagrant enough (http://www.vagrantup.com). It allows you to set up and provision virtual servers. I do all of my PHP development on a LAMP stack and I have total control. It's a great learning experience. Using a provisioning tool like Puppet and Chef you can deploy your development environment on any machine.
The default document root for apache on Mac OSX (Lion + atleast) is
/Library/WebServer/Documents/
You will need to put your documents here to be able to access them from a browser or change the apache configuration to point the document root to the appropriate directory on your machine.
You must also make sure that the webserver has permission to read the files you are trying to serve over the internet. For example the following directory structure represents my Mac's /Library/WebServer/Documents/ directory:
-rw-r--r-- 1 root wheel 31958 Jun 20 2012 PoweredByMacOSXLarge.gif
-rw-r--r-- 1 root wheel 3726 Jun 20 2012 PoweredByMacOSX.gif
-rw-r--r-- 1 root wheel 44 Jul 31 13:53 index.html.en
-rw-r--r-- 1 root wheel 44 Jan 7 16:00 index.php
Since apache is running as Root on my machine (bad practice by the way, apache should not be running as a priveledged user, however my webserver is not exposed to the internet so there is little risk in my case) it can read all of the files in the directory, and when i point my browser to http:// localhost/index.php I see the contents of index.php:
<?php
echo '<h1>This also works</h1>';
?>
Related
I'm fairly new to programming in general and even more on PHP, so basically I'm following this tutorial on how to print "Hello World" on a localhost but looking at the tutorial I see that the document root is shown when the localhost is launched compared to mine showing less information. So I'm unable to save my program in the right location since i can't seem to figure out where is that document root.
Your document root is configured in Apache (assuming you use PHP through Apache httpd server here).
Look in your httpd.conf file, you will find directive DocumentRoot, which will show you what directory it uses. It will most probably be something like .../htdocs or .../www or .../html.
I've set up a LAMP machine with Centos, apache, MySQL and PHP 7.4.
my user via ssh is mformisano, I'm able to login via SFTP with mformisano and browse folders.
It's an intranet machine, so we are not so severe on restrictions, but, if I type the address into the browser I can execute PHP files, but these files are not able to extract files, create files, etc into the var/www/html folder.
Actually the www folder is:
drwxr-s---. 4 apache apache 31 29 ott 22.34 www
inside:
drwxr-xr-x. 21 root root 4096 29 ott 22.34 ..
drwxr-x---. 2 apache apache 6 19 ott 15.54 cgi-bin
drwxrwxr-x+ 3 apache apache 4096 2 nov 10.49 HTML
If I give permission to mformisano, I can browse via FTP, PHP is executed.
If I give permission to apache:apache I cannot browse, PHP is executed.
If I give permission to mformisano:apache I can browse, PHP is executed.
If I give permission to mformisano:mformisano I can browse, PHP is not executed.
I do need to both browse and execute PHP, so mformisano:apache should be the right way, but when I execute kickstart.php (a WordPress plugin that extracts a .jpa archive) this is not extracting and give me an error about writing permissions.
What am I doing wrong?
The PHP files are going to be parsed by Apache. Typically Apache will be running under the user www-data, in any case find out what user Apache is running under and give the appropriate permissions to the user that apache is running as. If you are a single person running the sever I would recommend SFTP login as root user, this will give you permissions to modify whatever you want on the server, but remember to change the owner and groups for any files you create as root user before logging out.
I am trying to get a php / Drupal based website. The site also uses solr, something which I've never used before. I inherited this site and the documentation I was left says that I may need to restart solr which can be done by running:
sudo /etc/init.d/tomcat6 restart
I can see from my Drupal admin that solr isn't running so I tried running it. I unexpectedly got a message saying sudo: tomcat6: command not found. However when I list the directory tomcat6 is clearly there.
These are the permissions:
-rwxr-xr-x 1 root root 7929 Mar 16 2012 tomcat6
Does anyone know what the problem with this is and how I can resolve it?
This apparently was always working and I haven't installed anything since I started with this linux machine (VM).
You should run it this way ./tomcat6 start, if you want to run it directly using tomcat6 start you should add the script's directory path to your PATH environment variable.
In a typical PHP application what should the file permissions of .php, .html and image files be? I'm using PHP5 with Apache on a Linux box.
Thanks
There is no "typical" situation imo.
In our production systems our file permissions for the entire DocumentRoot are:
-rw-rw-r-- 186 deploy deploy 677 Nov 17 11:32 template.php
They are owned by the deploy user, as that's the user we use to deploy our application in our production environment. They are group writable so that others in the deploy group (sysadmins, developers) can modify them if need be. In a shared system you would probably not have 0664 because you wouldn't want other people reading your files, and you'd probably use 0660 or 0640.
html and images should be readonly to the to web server's user
php should be read & execute
We recently switched from using PCs at work to Macs, so I'm new to the *nix way of doing things. I have the default Apache running that shipped with 10.5, but I've noticed that when I drag files from a Windows server to my machine, the permissions are changed. Specifically, I'm writing data to an XML file, and occasionally after swapping some files back and forth, it stops working.
Can someone help me understand why this is happening and how I can either force Windows to respect the original file permissions (they were set on my machine when I created the file) or apply a less secure set of default permissions when the files are moved from Windows to Mac?
A couple facts to be aware of:
I'm using the Cornerstone Subversion client.
I can use Terminal if you spell it out for me.
Ultimately I'm uploading these files via Transmit to a Linux server in another location.
I'm already familiar with using Get Info to change the file permissions, but maybe I'm doing something wrong.
I'm logged in as root. (I know, bad bad bad.)
I should also mention I know this is a simple question that should have a simple answer, but I've googled up and down without finding it. I need your help.
Thanks.
It would be incredibly helpful if you could drop to the Terminal, use cd to navigate to the folder with the files that don't work because of permissions and then type: ls -l (those are both lowercase Ls back there).
If you start from your home folder, it'll look something like this:
macbookpro:~ artlogic$ cd Sites
macbookpro:Sites artlogic$ ls -l
total 8
drwxr-xr-x 6 artlogic staff 204 Mar 11 2008 images
-rw-r--r-- 1 artlogic staff 2628 Mar 11 2008 index.html
macbookpro:Sites artlogic$
Please paste the output into this thread. Knowing what Apache is changing the permissions to would help.
On a side note, Apache generally runs under a different user and permission level than the logged in user and so if it's somehow creating or overwriting files it may be changing the permissions that way.