Running Wordpress repo locally through MAMP. Assets not being pulled in - php

Currently I am trying to run a Wordpress repo locally for development. I am not using MAMP pro even though I still have a 9 day trail. I figured since I'm going to be using the free version for now I might as well work with that. I have my Apache & MySQL server running along with the Document Root pointing to my Sites folder where my projectName repo sits. I'm still running off of the default port of Apache 8888.
After I start the servers, I open WebStart and import my DB into phpMyAdmin. Everything works perfectly fine and the copy of my db gets imported. I then make sure that my wp-config.php file has the appropriate settings to access this db. I then click on My Website. This pulls up the content of the website. However, it does not pull in any of the assets(imgs/js/css). I receive the following errors in the console:
Failed to load resource: net::ERR_EMPTY_RESPONSE http://projectName.dev/wp-content/uploads/2016/09/logo-footer-1.png
Failed to load resource: net::ERR_EMPTY_RESPONSE http://projectName.dev/wp-content/themes/projectName/images/circle.png
And so the list goes on and on for pretty much every asset the project could possibly have. Now configuration is NOT my strong suit, and at this point I am at a loss of what could possibly be happening. Awhile ago I did follow a tutorial on how to setup my files so that I can access them in the web browser by simply typing the name of the project with the domain .dev, example: projectName.dev. I started having issues with this after upgrading to OS Sierra and it no longer works. Could this possibly be the reason as to why it is looking for these assets in the projectName at the .dev domain?
I apologize if this does not make sense. I am willing to provide anyone with any information on this as I need as much help as possible because I still need to level up my configuration skills. Let me know if you have questions.

The images and other assets are referenced with an absolute filepath (i.e. the URL of the server on which you first set it up). This has to be changed in all database entries. There are tutorials for this on the net, but the most simple version is to open the sql file in an editor and search & replace the general URL part in the complete database.
Be sure to keep a backup of the file - that might not work on the first try...

Related

Multiple Instances of XAMPP on an External Portable Harddisk

Running Windows 11, 64 bit I need to install multiple instances of XAMPP on my external Hard disk. The drive will always be associated with the letter Z.
The purpose is to learn XAMPP including what the stack is made of i.e., Apache, MariaDB/MySQL, and PHP. Learning route is through various tutorials and online video courses such as:
WordPress Full Course in ONE VIDEO | ZERO to HERO | STEP BY STEP
How To Make A Digital Agency Website From Scratch In 2022 (WordPress And Elementor For Beginners)
These tutorials/courses asks to make projects such as the first is centered around "mywebsite" and the second is "jimakes". In order to do so I was thinking to have one installation of XAMPP at (I am using the Lab as the main folder in the drive Z)
Z:\Lab\xampp\htdocs\mywebsite
Z:\Lab\xampp\htdocs\jimakes
Now I will have 1 XAMPP installation and multiple WordPress installations (The WordPress installtions will be in each of the projects respective folders so that tinkering one WordPress installation does not effect the other).
The problem is following through the 2nd course/tutorial and installing the WordPress theme (jimakes), Astra, I came across problems that required me to change some settings in the .htaccess file and php.ini files which I messed up. This resulted in messing up the "mywebsite". This required me to uninstall everything and do a clean reinstall of XAMPP and WordPress. And that resulting in also removing the htdocs folder. (There is an option of not removing that folder during the uninstall process but I don't want to do that say just to be sure I have a clean reinstall with default settings).
Now I am thinking to have multiple XAMPP installations and a single WordPress installation such as
Z:\Lab\mywebsite\xampp\htdocs\PUBLIC_HTML
Z:\Lab\jimakes\xampp\htdocs\PUBLICC_HTML
The purpose is two fold. First I can happily chip away with messing everything up in one project and it won't effect the other. The second I am trying to replicate a real hosting live server from one of the server providers such as Go Daddy or Host Gator as much as possible so that migrating from the local development environment to the production one is as pain less as possible when I move on to real projects.
Now to cut the story short and trying to catch the river in a cup I would ask
To create a exact replica of the hosting providers environment on a local development environment with the aim of firstly learning technologies such as PHP, MariaDB/MySQL, WordPress and later on exporting real life project from the local development to hosting environment with the confidence that all I need to do is move the files (FTP via FileZilla?). This cannot be achieved since if I am not wrong, one can never install cPanel locally. Secondly who has the time to consider in so many variables for example you cannot create a new database or user using phpMyAdmin in a hosting account but you can on a local environment.
WHM & Cpanel cannot create database
What needs to be changed for once and once only. You will notice that I have changed the htdocs to PUBLIC_HTML as the root document folder (Is it same as the Server Folder?). The aim is to actually learn PHP and WordPress and MySQL without being bothered about why it's not working. I know why it's not working itself is an important part of learning but it just muddles the waters since your objective is to learn the technologies and not why it's not working (The why it's not working comes later, don't ask me why, I am too dumb to learn two things at a time).
I tried installing Apache, MySQL/MariaDB, and PHP manually without using XAMPP. This resulted in learning about more about installations and errors and how to fix them and blah blah blah rather than actually learning PHP, MariaDB/MySQL and WordPress. Exactly the thing that I was trying to avoid. Some would argue you cannot learn one without the other but I already have HTML and CSS under my belt (I know, I know, JavaScript, I will get there) and again the purpose is to move to the backend and save time by avoiding and worrying about how to fix them errors (took me two hours to figure out why my php manual installation was not working. Turns out one needs to set PATH in system environment variables in Windows 11)
PHP Not Executable in Command Prompt Windows, Environment Variable is set
Why can't I just use a hosting provider production environment? Than why XAMPP is there?
You have a lot of asks here, you shoould split them to individual asks, i Will help you with the Title Ask.
Is as common task have into dev environment many projects, but you can run all with a single instance and a single port, such as 80 in dev machine.
You can set Many Virtual Hosts so istead of use default http://localhost you can create a better host for each project, Eg:
http://project1.local
http://project2.local
and proceed with development with no pain, here a tutorial, teaching how you can create this env.
https://www.wdb24.com/how-to-setup-multiple-virtual-hosts-on-xampp/

October CMS installation running on Laravel Homestead, server returning mixed up static assets

I've been developing a website built on OctoberCMS, using the Laravel Homestead vagrant box as my local development server and have so far been getting along swimmingly. I developed most of a theme this way.
However I've recently started running into a problem wherein requests for assets/vendor.css in the theme assets succeed but receive a text/html response containing HTML for the homepage instead of the proper CSS.
This means vendor CSS for the page doesn't load. However if you repeat the request for vendor.css with "open in new tab" after page load the correct asset is returned, and the Chrome 'sources' tab also shows the correct asset.
This strange behaviour seems to extend to JS assets. I'm currently looking at a request for assets/vendor/jquery.js where the inital response actually contains the contents of assets/theme.css - and this is causing JS errors in the console.
In this case however if I make the request to that URL again I actually still receive the same incorrect CSS, but once again the Chrome 'sources' tab actually shows the correct asset.
Inspecting the files in my code editor I see the correct assets under the correct filenames and locations.
It seems I might have an issue with Homestead's web server. However I'm confused about where it might have come from as I haven't reconfigured anything and this has been working fine previously.
I've confirmed that the problem still persists even after deleting the homestead VM, and then building a brand new one and installing a fresh copy of OctoberCMS, without importing any of my own custom theme files.
I tried having a look into the nginx logs on the VM to see if I could spot anything odd, but it looks like they all have no content, 0 lines.
I'm a bit stumped and haven't found much helpful searching around.
Any suggestions? Help much appreciated.
So I've managed to re-build my project in such a way that this time I didn't reproduce the problem.
I'm pretty sure that ultimately it was caused by the fact that I relocated the homestead VM (and projects therein) by renaming its containing folder.
In previous attempts I had been deleting the VM by running vagrant destroy and then re-creating it by running vagrant up.
Once I completely deleted the homestead repository and re-cloned it from scratch from laravel/homstead on github, then proceeeded to vagrant up and set up OctoberCMS, I no longer experienced the issue.
I suspect perhaps the original path to my VM (before rename) was still in a configuration file somewhere in the laravel/homestead project and the disconnect between this value and the actual filepath was causing the problem.

How to get running on a local dev environment from an existing and complex Magento2 project

At work we took back our existing store running on Magento 2 from an external development agency. I need to get the project running in local development (with docker).
I familiarized myself with a vanilla project from the official docs and managed to get it running by downloading the vanilla template with composer, granting the proper permissions on files and folder and running the magento setup:install command.
My question is how do one goes when kick starting from an existing (production running) project?
Do I need to run setup:install again? If I do, why?
What do I need to import from production to ensure any content or configuration created via the admin is also running on my local setup? Should I import the complete Database from production?
I know our setup is using more than just php and mysql, but env.php seems to be listing only db configuration and admin url. Where can I get the complete service configuration informations about what our setup uses?
Anything else I am missing to get started with an existing project for local development?
As someone who is running Magento 2 on a local environment myself, hopefully I can shed some light on this.
If you have a direct copy of the live site, you do not need to run setup:install again.
Ensure you have a copy of the entire Magento 2 site (you can technically ignore the vendor folder, as you can run composer install and it will redownload those files, but that's up to you). Also get a copy of the entire database. Magento 2 is notorious for copying the same data to multiple tables so something could break if you don't have everything.
What do you mean by "service configurations" If you are referring to Magento 2 extensions, that data is saved in the database, not the env.php file. env.php is only for server side configurations, such as the DB information, Caching, and things of that nature. On mine, I use Redis for site Cache, so that would be included in that file as well, as an example.
When you first unpack the site to your local environment, run composer update in the directory. This will ensure you have all the proper files installed. If you are going to run a local dev environment, set the mode to development with the following command: bin/magento deploy:mode:set developer. This will allow you to make changes and to view those changes by just refreshing the page, rather than flushing cache all the time.
All queries are replied correctly by Eric. I am also not sure about "service configurations" you have mentioned here. If this is about third-party extensions/services you can check config.php file for this.

Laravel, homestead VM phpmyadmin installation

I'm unable to properly configure phpmyadmin in the VM provided by Laravel.
These are some of the questions asked when installing it.
Pass: secret
I've tried "phpmyadmin", "homestead"...
Here's what I get:
I just can't seem to make it work, I've been struggling with this for quite a while now.
Here is another option that I had suggested on another question, a much simpler DM admin program than phpmyadmin that is full featured and is a breeze to install (it is literally just one php file):
Another alternative that I found super simple and that worked right out of the box I set up a new Nginx site from inside the Homestead box using the serve.sh script:
serve adminer.app /home/vagrant/Code/adminer/
And then in there I dropped the one page successor to phpmyadmin, Adminer. I also renamed it to "index.php" to make it just work. Then after adding the adminer.app entry to my hosts file I was good to go.
Had not used a web based MySQL interface in years since I just didn't like maintaining phpMyAdmin but this one is sweet. One file (plus an optional CSS file if you want a nicer theme) and that is all. Easy to maintain and update.

cant run php files in a folder on windows 7 webserver which was previously created on xp webserver?

im doing a php project. all is fine doing it in xp webserver which im using iis..but now i have set up a new pc with windows 7 and iis.
problem is when i copy my php files which is in a folder(e.g portal1) from the xp wwwroot to the windows 7 wwwroot, i cant access it on the browser. it returns an internal server error.
now i assumed i didnt properly set up my web server or even php. i have done it a dozen times following tutorials and im pretty sure its all correct.
i have done a further research on the folder itself and has led me to a theory that this has to do with permissions.
when i copy directly the whole thing,it wont run, BUT if i CREATE a folder and the subfolder with all the same names as the one i copied and just take the php files and put it accordingly, it runs ok!!
now that has something to do with inherited permission i think. how do i overcome this?
i dont want to everytime take the updated work folder from my partner which is done in xp and i have to create new folder and its subfolder with all the same name on my machine and then copy the php files accordingly. thats a lot of work!!
i just want to copy the folder and put it in my wwwroot folder and run it on the browser without problems. how do i overcome this permission issue?
any ideas?
By the sounds of things, you're working on a project with someone else. Copying & pasting is the absolute worst way of sharing files when working on a project with multiple people. You should really be using versioning like git. That's pretty hard to set up and learn though. An easy solution which will work for the time being (but won't manage conflicts well) is to use Dropbox. Set up a free Dropbox account, and create a folder in that called www or whatever you want. Then install WAMP (way better than IIS), and create an alias to the www folder in your Dropbox. Do this on both machines. Now every time your partner makes a change, it will be instantly reflected on your machine, and vice versa. Easy, free, and will work while you learn a versioning tool.
I know this doesn't address your actual problem, but it should be more helpful to you.

Categories