Difference between revisions of "Local Web Server"
From Wikicliki
(Created page with "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...") |
|||
Line 24: | Line 24: | ||
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: | 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: | ||
<pre>http://localhost:8000/</pre> | <pre>http://localhost:8000/</pre> | ||
+ | |||
+ | |||
+ | == 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 | ||
+ | <pre>sudo pico /etc/apache2/httpd.conf</pre> | ||
+ | |||
+ | uncomment this line | ||
+ | <pre>#LoadModule php7_module libexec/apache2/libphp7.so</pre> | ||
+ | |||
+ | save and close pico | ||
+ | ctrl-X | ||
+ | |||
+ | then restart apache | ||
+ | <pre>sudo /usr/sbin/apachectl restart</pre> |
Revision as of 04:08, 17 August 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