Difference between revisions of "Local Web Server"
From Wikicliki
Line 1: | Line 1: | ||
+ | I'm on a new Macbook Pro 16" Sillicon Mac OS 12.3.1 | ||
+ | |||
+ | * Cannot use XAMPP for new macs | ||
+ | * Cannot use in-built apache cos no php | ||
+ | * Started following this https://www.thoughtco.com/how-to-install-php-on-a-mac-2694012 | ||
+ | * Got up to the part where I was supposed to uncomment the php module so it can php but then discovered that PHP was deprecated in macOS 11 and removed from macOS 12 | ||
+ | * also since i forgot - how to Quit the vi editor without saving your changes - Press Esc : q! | ||
+ | * https://wpbeaches.com/updating-to-php-versions-7-4-and-8-on-macos-12-monterey/ | ||
+ | * disable the inbuilt and use home-brew - https://wpbeaches.com/installing-configuring-apache-on-macos-using-homebrew/ | ||
+ | * couldn’t find where the documentroot folder is | ||
+ | * ran “brew info httpd” | ||
+ | * DocumentRoot is /opt/homebrew/var/www. | ||
+ | * discovered that Command-Shift-G brings up a window to access the secret linux style folders | ||
+ | * bookmarked it on mac | ||
+ | |||
+ | [[File:localhost8080.png|800]] | ||
+ | |||
+ | == OUTDATED == | ||
+ | |||
Easiest way for Mac and Win is to use MAMP - https://www.mamp.info/en/ | Easiest way for Mac and Win is to use MAMP - https://www.mamp.info/en/ | ||
Latest revision as of 02:23, 15 May 2022
I'm on a new Macbook Pro 16" Sillicon Mac OS 12.3.1
- Cannot use XAMPP for new macs
- Cannot use in-built apache cos no php
- Started following this https://www.thoughtco.com/how-to-install-php-on-a-mac-2694012
- Got up to the part where I was supposed to uncomment the php module so it can php but then discovered that PHP was deprecated in macOS 11 and removed from macOS 12
- also since i forgot - how to Quit the vi editor without saving your changes - Press Esc : q!
- https://wpbeaches.com/updating-to-php-versions-7-4-and-8-on-macos-12-monterey/
- disable the inbuilt and use home-brew - https://wpbeaches.com/installing-configuring-apache-on-macos-using-homebrew/
- couldn’t find where the documentroot folder is
- ran “brew info httpd”
- DocumentRoot is /opt/homebrew/var/www.
- discovered that Command-Shift-G brings up a window to access the secret linux style folders
- bookmarked it on mac
OUTDATED
Easiest way for Mac and Win is to use MAMP - https://www.mamp.info/en/
WINDOWS - MAMP:
- Download the installer from https://www.mamp.info/en/downloads/ (300MB) - will have copy on thumbdrive in the class
- Install it, unchecking ‘Install MAMP PRO in addition to MAMP’
- By default it will install to C:\MAMP
- Now start MAMP from the window start menu
- Click on Start Servers
- Click on ‘Open start page’
- The page http://localhost/MAMP/ should now open up in your browser.
- Default documents folder is usually C:\MAMP\htdocs
MAC - Fastest way is to use Python SimpleHTTPServer
- All new Macs have Python installed. First open Terminal (Which can be found inside Applications > Utilities). Check which version of python you have by typing "python" into Terminal. Then navigate to the folder with your files inside it.
cd /path/to/project/folder
Use Python's built-in http server:
# Python 2.x python -m SimpleHTTPServer # Python 3.x python -m http.server
Files from that directory will be served up at localhost under port 8000, so you can view the files from that directory if you type this into the browser:
http://localhost:8000/
php 7 doesn't parse
after upgrading mac to mojave 10.14 my php files did not render as webpages but displayed code in the browser. here is the fix
edit httpd.conf
sudo pico /etc/apache2/httpd.conf
uncomment this line
#LoadModule php7_module libexec/apache2/libphp7.so
save and close pico ctrl-X
then restart apache
sudo /usr/sbin/apachectl restart