Using IIS to test php code without a domain name - php

I am starting to work on a website for which I have not chosen a name or bought a domain. I enabled iis and installed php on my computer.
I want to create a temporary website just for testing my code, so I tried to add a website in the IIS Manager by right-clicking in the connections module and selecting "Add Website."
In this case I used "mywebsite.com" as a temporary name. The problem is that someone owns that domain and my browser takes me to their website instead of showing the local one. I tried changing the port from the default of 80 to 25, but I just then my browser says "page not found" when I try to view the webpage(right-click on site in IIS manager > Manage Website > Browse).
At this stage I just want to be able to see the output on my computer. Does anyone know I would do this?

In order to create a custom record that only resolves on your computer you can take the following approach:
Open notepad as an administrator
Open the file %WINDIR%\system32\drivers\etc\hosts
Add the line "127.0.0.1 mywebsite.com"
Ensure that your IIS site actually binds to mywebsite.com:80
Save the file and attempt to resolve the domain name in your browser
However, I highly recommend that you attempt to use a domain name that is not actually real. For instance dev.lauren.local, instead of mywebsite.com, that way you will reduce the likelihood of unexpected results :)

Related

WordPress on localhost can not be reached

I am using wamp to host a local version of my WordPress site. It was working gine until I restarted my computer and now I get this error.
This site can’t be reached
The connection was reset.
I tried restarting the services, and creating a new copy of this site under I different folder and the error still persists. My other non WordPress sites work fine.
Not sure what is going on so any suggestions would be great.
If you've moved your site to a different folder then the root has probably changed. Go to Preferences > Web Server and click on the folder next to Document Root, and navigate to the root directory that has your site then click on Select.
Also, make sure Apache and MySQL servers are running. Hope this helps.
You might have changed your port number from default port number.
Open with the port number that apache server is listening.
In your browser give "localhost:portNumber/WordPress"
Example: localhost:80/wordpress or
localhost:8080/wordpress or
localhost:8081/wordpress.
You Can check your port number from apache part config file.
Watch this video: https://www.youtube.com/watch?v=blmOFr8uZQI
I think its plugin issue from the codebase. Just rename the plugins name one by one in (wp-content/plugin/) folder and check.

Setting up pyrocms/codeigniter on localhost

I am having trouble getting a project to work that I have inherited and not setup myself. I install the DB and make sure the file/folder permissions are correct -- but I am getting this error when I try to get to the local site -
This domain is not set up correctly. Please go to http://localhost/myproject/sites and log in to add this site.
I get that error again when I go to that URL... so not exactly helpful on 'adding sites'.
Is there any way to setup a local site in the database manually without using the installer?
Check the field "domain" in the table "core_sites" in your PyroCMS DB.
This field should be set to the domain you're open the website on.
This is usually caused if you're installing PyroCMS through a different URL, than you use to open the website.
e. g.
install through http://dev-server/website/pyrocms/installer, but call the website on http://pyrodev.local because you've set up a virtual host and corresponding DNS entries.

How to get images to display on website while using XAMPP on Macbook Pro

I built an HTML/CSS website and then added PHP functionality. Installed XAMPP. Since installing XAMPP, everything on the site works except the images. Image files don't display. They are all properly referencing the directory. In fact, before using XAMPP, the images displayed fine on the HTML webpages. After using XAMPP and re-saving as .php, they stopped working. Nothing else changed. I figure it must be a settings issue. Thoughts, anybody?
Thanks a billion in advance!
#john steve I had also the same issue. I tried lots of thing suggested on different forums but it did not work. Finally I set up permission for each images and it worked.
I just had the same problem. And the reason was that my images folder had no-access permission. I changed the permission to Read/Write for admin and Read-only for everyone else. It is possible to change permission for each individual time but it is time consuming, therefore changing the permission of parent folder is effective.
The following steps are for MAC OS:
Open applications folder
Locate XAMPP folder
Right click > get info.
In pop-up window locate the 'sharing & permission' section
Click the 'locked' padlock symbol
Enter admin password
Change 'Everyone' permissions to read & write
In the get info window still, select the 'cog' icon' drop down option
at the very bottom and select 'Apply to enclosed items' this will
adjust the permission across all sub-folders as well.
Re-lock the padlock symbol
Close the 'Get Info' window.
And for Windows:
-
Locate XAMPP folder
Right-click the folder, click Properties, and then click the Security tab.
Click Edit to open the Permissions for <Object> dialog box.
Click the name of the group or user.
In the Permissions for <User or Group> box, select the Allow check box.
References: Microsoft and Stackoverflow
#Manuel is right. If the problem persists, try absolute paths in image src. The absolute paths will be like http://localhost:8888/your-website-folder/your-images-folder/your-image-name
In windows you don't use port number (which is 8888) in this case
Good luck.
Its probably an issue with accessing local files on a "domain" that is not local. Just update you're images path to something relative or within localhost and it will be fine. Its a browser security thingy to not load local files when you are not opening a file directly from a file path. (Cross-domain or Same-origin policy). The idea is to not let any website sniff your local files and it doesn't work differently for localhost which can be an alias to any IP (doesn't nnecessarily to be 'local').
To fix this issue, move all your assets into the folder that is the root for localhost and e.g. use "images/someImage.jpg" instead of "c:\somePath\someImage.jpg". You cannot mix up c:\ with a page served from http://localhost/.
You will see this issue popping up in the network panel of chrome developer tools or Firebug extension when working with Firefox. It's really NOT recommended to, but it's possible to turn off this crucial security settings: http://joshuamcginnis.com/2011/02/28/how-to-disable-same-origin-policy-in-chrome/ - I would warn anybody to do it that way, though.
I figured out the problem: all of my images had permissions marked: "everyone: no access." I changed it to: "everyone: read only" I did this simply by right clicking (aka control-clicking) each image and then clicking "get info." I then scrolled down to "Sharing & Permissions." It's self explanatory from there. Thanks for the help everyone!
You have to set read and write permissions to each image you want to use. I assume you can probably do the entire folder in and it will cascade down. On mac right click (two finger) => get info => at bottom set all to read/write. reload page. Presto.
Please check the folder name. Don't use uppercase letter in folder names. I tried all solutions advices but finally found that solution. My pictures folder was "Resimler" then I couldn't see the pictures but I changed as "resimler" then it is worked.

How to Set up PHP Test Server in Dreamweaver?

I am trying to setup a PHP server so that I could use the "Live" feature in Dreamweaver, in addition to being able to preview in my browser without having to upload the .php file via an FTP application every time, which is not efficient when I want to do quick small previews.
I have setup a new website and selected a folder for the site on my local drive.
For the server, I have the following information (I don't know how much of it is relevant):
Remote: Yes
Test: Yes
Server Name: Server
Connect using: FTP
FTP Address: my domain name
Username: my username
Password: my password
Port: 21
Root directory: blank
Use passive FTP: Yes
Use IPV6 Transfer Mode: No
Use proxy: No
Use FTP performance optimization: Yes
Maintain Synchronization Information: Yes
Automatically upload files to server on save: Yes
Enable file checkout: No
Server model: PHP MySQL
When I test the server, it is successful and I am able to get the site/server to show up in "Manage Sites". However, when I want to test my .php file on the "Live" preview panel or as a preview in Chrome, I get the error message: "Dynamically-related files could not be resolved because the site definition is not correct for this server." When I upload the .php file to my FTP manually, the page displays properly but when I try doing this it either does not work or the Chrome preview mode just spits out the entire raw code.
I tried and Googled, but I could not find a solution to this problem. Any help would be greatly appreciated.
Side note: I have my hosting from GoDaddy and the server from there is based on MySQL.
Thank you.
To set up PHP server with dreamweaver follow the following steps
Step 1.
Make Sure you have MAMA(For MAC OX) or WAMP (Window OS) install. If you dont know where to get then click this link
http://www.mamp.info/en/downloads/ and install in you system. (make sure if you are using skype close it because skype and mamp use same port. Later you can chage the port for Skype)
Step 2:
Open Dreamweaver and choose
Site > New Site
Step 3:
Type your site name and click on browse button to locate you htdocs folder (which is normally inside you mamp/wamp folder on you root directory).
Step 4:
Select Server from left hand side and click on add (+) sign.
Follow the following:
Server Name: localhost
Connect Using: Local/Network
Server Folder: (this is wehre your site located (i.e. inside htdocs folder)
Web URL: http://localhost/yourSiteName (yourSiteName is name of your folder)
Click Save.
Step 5:
Check Testing and click SAVE
Step 6:
Last but not least Open File Panel
Window > Files
Now create a new file and Save it inside you folder.
Thats it you are set mate.
hope thats helps
Cheers!
The problem is when you try and run your PHP file from your local machine, there's no web server running - nothing on your machine knows what to do with that file.
The solution is to run a local version of Apache, PHP, MySQL on your local machine - the easiest way to do is to download xaamp - http://www.apachefriends.org/en/xampp.html. Put your website files in the htdocs directory once it's installed, and you can view them by going to http://localhost/websitefoldername

PHP mkdir Permission Denied running on Windows Server 2008 IIS 7 due to Read Only Attribute?

I'm having a problem with a PHP website running on IIS 7 on Windows Server 2008.
There is one line of code calling mkdir which is erroring and the error log reads:
"... permission denied ..."
I have ruled out anything to do with folder permissions (I have tried multiple groups: Everyone, Users, IUSR, Network Service etc. with no luck).
I need to know how mkdir works, does it check the read-only attribute of the parent folder?
If so, then this could be the root of the problem as all folders in Windows Server 2008 are marked as "Read Only" and the checkbox is greyed-out - Microsoft say it is "by design" but I think it is really "bad design".
Please help.
P.S. The line of code which errors can be found here https://github.com/LimeSurvey/LimeSurvey/blob/070d255ba381d7abcd231d7c9e0c7d11f5578c97/admin/templates.php#L1182 it is line 1182.
SOLUTION:
It was a permissions issue after all!
We were applying permissions to the wrong folder (smacks hand to forehead)
There are two "Templates" folders: /Templates and /Uploads/Templates
/Template is for default templates whereas /Uploads/Templates is for user-created ones
We gave the "Users" group r/w/execute/modify permissions to /Uploads/Templates folder
Whereas previously we were applying permissions to /Templates
To debug this I used echo to output the $target value
LESSONS LEARNT:
Always read the error message - it said "permission denied" and I didn't believe it
Don't assume the obvious to be true - /Templates wasn't the right folder
If the code is erroring then debug the code and don't try to guess the problem
Debug the code using simple techniques such as outputting variable values - e.g. echo
Listen to the majority - most people here were right in saying IT IS A PERMISSIONS ISSUE!
Most errors have a simple fix - don't go looking for something complex
Bounty awarded to #BOMEz because of the useful quote from mkdir() documentation which indicated that I should double-think the permissions. #BOMEz also provided a tailored answer and interacted with me via comments which helped.
As a test (preferably in a development environment) give the IIS user full access to the parent folder. If this makes it work, slowly start taking away privileges to see which ones you need.
Try changing:
if(mkdir($target,0777))
to:
if(mkdir($target))
Windows ignores the mode option. Might be some weird bug causing it to fail.
Additionally for your $target variable could you try forcing it to link to the full Windows path? Such as C:\Program Files\ IIS\...
I've ran into situations with windows before where access was denied attempting to use a relative path, but the full path works just fine.
EDIT:
Looking at the comments on the documentation for mkdir() one commenter mentions that you might also need to add execute permissions to the user:
If you're getting a Permission Denied error, but are certain the
permissions and ownership where you are trying to create the directory
are correct, check again:
The location where you are trying to create the directory in must have
the Execute permission for the owner trying to create it, regardless
of if the folder is Readable, or Writable.
This may be obvious to some, but was not to me at first. Hopefully
this will save you the trouble I went through.
Since you didn't mention a control panel of any sort I'm going to assume you have access to the server either physical or remote desktop. I'm also going to assume you checked your php.ini settings.
That being said, there is a work around for some of these permission problems.
You will need to create an administrator account (and add it to the administrators group) for this site to use or simply use your administrator credentials.
Open the IIS manager
Expand Sites
Highlight the site in question
On the right side of the screen click 'Basic Settings', a dialog box should pop up.
Click the button at the bottom that says 'Connect as...'
Select 'Specific user' and then click the 'Set...' button
Type the user name and password of either your account or the account you created.
Hit 'Ok' button 3 times.
This is a bit of a sledge hammer fix since it will grant full unrestricted access to the file system from your scripts.
If you created a new user and you want to maintain some level of script security then you can try pulling the user out of the administrators group and then giving it full permissions on only that site with the following:
Highlight site
Right-Click, Edit Permissions
Security Tab
Click 'Edit' button
Click 'Add' button
Click 'Advanced' then 'Find Now'
Double click on the user you created
Click 'Ok'
Highlight your user, tick the box under allow that is next to full control
click 'Ok' twice
If asked, select that you want to apply to all directories and files.
~
If your still having issues then there is a good chance your php setup is configured incorrectly or corrupt. (Safe mode turned on maybe?)
Following is the explanation of permissions.
Read
On a File: this means reading content of the files
On a Directory: it means viewing the contents of the directory, namely, being able to use ls or dir
Write
On a File: this means being able to edit content of the files
On a Directory: it means being able to create/modify content of the directory, namely making new files or folders in that directory.
Execute
On a File: this means executing the code from the file (for scripts/executables)
On a Directory: it means, entering the directory. You can not cd into that directory without this permission.
--
So, now that makes it clear the answer to your problem (as you guessed correctly), for making new directory or writing new files into the directory you need write permission on that directory. So for making folders into say C:/your_folder/ you need, write and execute permissions on that folder. (Yes you need execute too, as apparently for mkdir you need to go inside the folder first.)
One of the issues that we run into quite often is that files have been moved from any location to the websites location, maintaining the original permissions instead of inheriting the permission needed by the application pool user of the pool that's beeing used by the website.
So one good thing to try would be to right click your document root folder, go to properties and then the security tab. Press the advanced button, check the checkbox a "Replace permission entries on all child objects with entries shown here that apply to child objects". That way you can atleast be sure all your permissions are set on all subfolders and files.
We nerver had any problems with the read only attribute, even though this is checked for all our folders. (grayed out/checked). So i doubt that is your problemen.

Categories