I installed WAMP server 2.5 (not the first time. I installed on my other laptop which works fine).
It seems that WAMP is running fine because the WAMP icon turns green and I’m able to open localhost and PHPMyAdmin but, the problem occurs when I try to run other PHP files, the Chrome shows the PHP code as it is and IE downloads the file.
I can run index file from localhost but when I drag drop index file it doesn't work.
I can run index file from localhost but when I drag drop index file it
doesn't work.
Yes, this is expected behavior. Not just on WAMP but absolutely any local LAMP-based web development setup. Dragging and dropping a file like index.php won’t actually get the LAMP setup to parse the file.
PHP needs to be processed by an interpreter to get it run. Either from the command line or via a web server with a PHP interpreter setup as a module. When you drag and drop the file into a browser, that file never gets processed via the web server.
To get PHP processed and run it must simply be run via a URL connected to that local development server; such as the address http://localhost/index.php or http://localhost/ since an index.php should be automatically loaded by the web server as a directory index.
Related
I have a remote server on 'somedomain.cloudapp.azure.com' and I have a php file named on that server.
I would like to preview the 'index.php' file on browser to see the output. I used to open the files and edited it through terminal, but now I want to see the output of the php file.
I know from localhost I just put on the browser URL localhost and it preview the index.php, how to do that for a file that is on remote server?
You need multiple thing to see your result on the web page running on the own server ; like that web server such as engine nginx or apache , php-cli , if you using database you need phpMySql and there dependencies.
I've installed XAMPP on my Windows 10 machine.
Apache works (call to any .php file in htdocs in browser gives desired results - PHP gets executed).
But when I call .php from my React app (devserver on localhost:3000) in devtools I see that it returns just php script by itself.
I also tried adding "proxy": "http://localhost", to my package.json, but didn't get desired results.
I think there's something with Apache configuration, but don't know what exactly.
I have a Wordpress 4.5.4 website I downloaded from a remote server to my local development server installing both, the files and the database.
On the remote server is working "apparently OK" but on my local server is doing something strange because on lot of files is doing the following appending:
http://<domain>.com/wp-content/themes/mytemplate/style.css?ver=1.8.4
Notice the version at the end: 1.8.4 while the current version is: 4.5.4
(this situation happens with lot of files)
Then I checked on the server and for these files the version at the end is the right one: 4.5.4
Then on both, on the remote server and on the local development server I read the global variable: $wp_version and on both cases I got the right version: 4.5.4, so I don't know why the 1.8.4 at the end as default version for those files on my local development server?
On my local development server the website looks really different than on the remote server and the files I download as well as the database is the right one, because on the root of the remote directory I put a dummy file and I can read it via the browser using the url. Also, I tried changing the database password on the wp-config.php file on the server and I got database connection error, so the files I downloaded and the database are the right ones.
Any idea on how to solve this?
EDIT 1
Remote server: CentOS release 6.8 / PHP v5.3.24 / MySql v14.14
Local Dev server: Windows 7 / Wamp64 / PHP v7.0.0 / MySql v14.14
EDIT 2
On the local development server I modified the .htaccess file and the Windows' hosts file to use the same domain and avoid the necessity of these kind of changes (and be totally transparent for browsers). I do this with tons of websites, so for me is a normal procedure. Then my problem is not a localhost/domain.com conflict.
The version add in a wp_enqueue_script() or wp_enqueue_style() is an optional value, and is related to the script version.
This value could be add the developper for caching purpose but it is not always corresponding to the WordPress version. The example you show is only relative to the theme and it's certainly hardcoded by the developper (this could be great to show us the wp_enqueue_style() ).
If version is set to false, a version number is automatically added equal to current installed WordPress version. But, some script can check and enqueue different file (I think about for minify css that will not load when you are enqueuing file locally).
In case, verify that both server show the same
get_bloginfo('version');
If not, change your local value with phpmyAdmin.
Hope it gives you some hints.
You need to manually update the siteurl and home options in the _options table and replace your domain with something like http://localhost, and remember to add the port number if you are running it at a different port than the usual 80
I've installed LAMP on my Ubuntu laptop with no apparent problems and successfully did the phpinfo() test by navigating to the file through the browser. But the same file is downloaded instead of executing when I'm trying to build from Sublime Text 3 using the following script:
{ "cmd": ["/opt/google/chrome/google-chrome" ,"$file"] }
That worked the first couple of times I tested it, but stopped right after I changed the name of the build system and hasn't been functioning since even after I reversed the change. How would I go about fixing the issue?
$file is "The full path to the current file, e.g., C:\Files\Chapter1.txt.".
Apache isn't causing the file to be downloaded; you aren't requesting it from Apache.
You need to translate $file into a URL on your HTTP server.
When I right click my local PHP file and select "open with Firefox" Firefox gets the focus for a second, but then the file opens in Dreamweaver instead. The same happens when I drag the file onto Firefox, or enter the URL ("file:///...") manually, or expressly select Firefox as the default application for PHP files. How can I get Firefox to show the file?
Firefox is not capable of handling PHP files, therefore it delegates their handling to a program that can do so (in your case, this is Dreamweaver).
PHP files should be served by a web server to the client (Firefox), which will display you the rendered content (probably HTML). PHP files are rendered by the PHP interpreter and then they are served using the HTTP protocol to a client as a web resource. So actually, you never open a PHP file with a browser, you just consume the HTTP resource that corresponds to the rendered output of that file.
Firefox can show .html-files. You have to install a webserver (xampp) to interprete .php-files. When xampp is installed, start xampp-control-panel, open your browser and (in case ur file is "test.php" in "c:\xampp\htdocs\test.php") and type http://localhost/test.php.
But first, right-click any php-file->Open with...->choose program, then select Firefox in the list.
You must install a local web server like xamp, wamp or easyphp.
Then you locate your files in that's www directory and see your file in browser with path:
localhost/myphp.php
Have a good time.
I have this solution to open a php on linux :
php -S localhost:8000
and open a firefox and go to the page :
http://localhost:8000/index.php
It works well for me.
The quickest way is to rename localhost/yourfile.php onto localhost/yourfile.html. (Tested on loop's Ubuntu 16.04 LTS)
You should deactivate adblock for localhost (or your domain), it should runs.
ABP icon -> click on deactivate on localhost -> F5