Difference between revisions of "Local Web Server"
From Wikicliki
Line 41: | Line 41: | ||
then restart apache | then restart apache | ||
<pre>sudo /usr/sbin/apachectl restart</pre> | <pre>sudo /usr/sbin/apachectl restart</pre> | ||
+ | |||
+ | == mojave 10.14 == | ||
+ | |||
+ | https://discussions.apple.com/docs/DOC-13841 |
Revision as of 05:46, 21 September 2019
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