\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Becky (earth2becky)} \pdfinfo{ /Title (lamp-on-osx-high-sierra.pdf) /Creator (Cheatography) /Author (Becky (earth2becky)) /Subject (LAMP on OSX High Sierra Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{843CA3} \definecolor{LightBackground}{HTML}{F7F2F9} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{LAMP on OSX High Sierra Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Becky (earth2becky)} via \textcolor{DarkBackground}{\uline{cheatography.com/45156/cs/13355/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Becky (earth2becky) \\ \uline{cheatography.com/earth2becky} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 27th June, 2018.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Helpful Links}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{fa-arrow-right\}\} \{\{link="https://websitebeaver.com/set-up-localhost-on-macos-high-sierra-apache-mysql-and-php-7-with-sslhttps"\}\} Install Apache, MySQL, PHP on macOS High Sierra 10.13\{\{/link\}\} \newline % Row Count 4 (+ 4) \{\{fa-arrow-right\}\} \{\{link="https://coolestguidesontheplanet.com/install-apache-mysql-php-and-phpmyadmin-on-macos-high-sierra-10-13/"\}\}Set up localhost on macOS High Sierra (Apache, MySQL, and PHP 7) with SSL/HTTPS\{\{/link\}\}% Row Count 9 (+ 5) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Turn on apache}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{- At the terminal, type: {\bf{\textgreater{}}} `sudo apachectl start` \newline % Row Count 2 (+ 2) - In a browser type: `localhost` or `localhost/index.html` \newline % Row Count 4 (+ 2) - If you see: {\bf{It Works!}}, it works.% Row Count 5 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.76 cm} x{4.24 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Apache General Information}} \tn % Row 0 \SetRowColor{LightBackground} Apache Doc Root Directory & \seqsplit{/Library/WebServer/Documents} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} httpd.conf lives in: & \seqsplit{/etc/apache2/httpd.conf} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} localhost web access & {\bf{http://localhost/index.php}} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Other docs and dirs in Document Root & phpinfo.php, phpmyadmin, php.ini, inc/ \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} bash alias & `docroot='cd /Library/WebServer/Documents\textbackslash{}'` \tn % Row Count 11 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Turn on PHP}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{At the terminal, type: {\bf{\$\textgreater{}}} `sudo vi /etc/apache2/httpd.conf` \newline % Row Count 2 (+ 2) Uncomment: `\#LoadModule php7\_module \seqsplit{libexec/apache2/libphp7.so`} \newline % Row Count 4 (+ 2) Save file then restart apache: {\bf{\$\textgreater{}}} `sudo apachectl restart` \newline % Row Count 6 (+ 2) In the document root: {\bf{\$\textgreater{}}} `sudo vi index.php` \newline % Row Count 7 (+ 1) Enter: \newline % Row Count 8 (+ 1) `\textless{}?php` \newline % Row Count 9 (+ 1) `phpinfo();` \newline % Row Count 10 (+ 1) `?\textgreater{}` \newline % Row Count 11 (+ 1) Save file then restart apache: {\bf{\$\textgreater{}}} `sudo apachectl restart` \newline % Row Count 13 (+ 2) In a browser, type: `localhost/index.php`% Row Count 14 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Install MySQL}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{- Download from \seqsplit{https://dev.mysql.com/downloads/mysql} \newline % Row Count 2 (+ 2) - Choose the version for your OS \newline % Row Count 3 (+ 1) - Click "No thanks, just start my download" \newline % Row Count 4 (+ 1) - Go through the download process \newline % Row Count 5 (+ 1) - Make sure you copy the password for root@localhost \newline % Row Count 7 (+ 2) - Start MySQL Server \newline % Row Count 8 (+ 1) - Add `/usr/local/mysql/bin` to path in `.bash\_profile` \newline % Row Count 10 (+ 2) To update password, see "{\bf{If you lock yourself out of phpmyadmin}}"% Row Count 12 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Install phpmyadmin}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{- Download \{\{link="https://www.phpmyadmin.net/downloads/"\}\}phpmyadmin\{\{/link\}\} \newline % Row Count 2 (+ 2) - Make new directory in the document root: `sudo mkdir phpmyadmin` \newline % Row Count 4 (+ 2) - Make it writeable by owner (which could be root): `sudo chmod 755 phpmyadmin` \newline % Row Count 6 (+ 2) - Unzip or unpack the zip file and copy to new directory \newline % Row Count 8 (+ 2) Also see: \{\{link="https://docs.phpmyadmin.net/en/latest/setup.html"\}\}phpmyadmin setup doc\{\{/link\}\} \newline % Row Count 10 (+ 2) - From \seqsplit{`localhost/phpmyadmin/setup`}, create a new server connection by clicking {\bf{New server}} \newline % Row Count 12 (+ 2) - Under Authentication tab, enter `root` as user and new password for root \newline % Row Count 14 (+ 2) Then click {\bf{Save}}. \newline % Row Count 15 (+ 1) - Now navigate to `localhost/phpmyadmin`% Row Count 16 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{If you lock yourself out of phpmyadmin:}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{...by turning on no password {\bf{IN}} phpmyadmin: \newline % Row Count 1 (+ 1) At the command line: \newline % Row Count 2 (+ 1) `\$ sudo mysql` \newline % Row Count 3 (+ 1) `{\bf{mysql\textgreater{}}} SET PASSWORD FOR \seqsplit{root@localhost=PASSWORD('letmein');`} \newline % Row Count 5 (+ 2) `{\bf{mysql\textgreater{}}} quit;` \newline % Row Count 6 (+ 1) Now use username {\emph{root}} and password {\emph{letmein}}% Row Count 7 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.6 cm} x{4.4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Database Access Information}} \tn % Row 0 \SetRowColor{LightBackground} Directory for include files & {[}docroot{]}/inc \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} MySQL Login file & db\_conn.php \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} PHP include line & `require\_once 'inc/db\_conn.php';` \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{{\bf{{[}docroot{]}/inc/db\_conn.php}} \newline `\textless{}?php` \newline `// credentials for connecting to database` \newline `\$host = 'hostname'; //database hostname` \newline `\$user = 'db\_user'; //database username` \newline `\$pw = 'db\_user\_pw'; //database user password` \newline `\$db = 'database'; //mysql database name` \newline `?\textgreater{}`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Database normalization}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{FIRST NORMAL FORM}} \newline % Row Count 1 (+ 1) \{\{fa-arrow-right\}\}NO repeating columns containing same type of data \newline % Row Count 3 (+ 2) \{\{fa-arrow-right\}\}ALL columns contain a single value \newline % Row Count 5 (+ 2) \{\{fa-arrow-right\}\}Unique PRIMARY KEY for each row\{\{nl\}\} \newline % Row Count 7 (+ 2) {\bf{SECOND NORMAL FORM}} \newline % Row Count 8 (+ 1) \{\{fa-arrow-right\}\}Table must be in First Normal Form \newline % Row Count 10 (+ 2) \{\{fa-arrow-right\}\}Create new tables for any data that is repeated in columns \newline % Row Count 12 (+ 2) \{\{fa-arrow-right\}\}Each new table needs a unique PRIMARY KEY for each row. `AUTO\_INCREMENT` can do this.\{\{nl\}\} \newline % Row Count 15 (+ 3) {\bf{THIRD NORMAL FORM}} \newline % Row Count 16 (+ 1) \{\{fa-arrow-right\}\}Table must be in First and Second Normal Form. This is usually all that is necessary. \newline % Row Count 19 (+ 3) \{\{fa-arrow-right\}\}Any data that is {\emph{not}} dependent on a primary key, but {\emph{is}} dependent on another value, should be removed to another table. This is a very strict use of normalization.% Row Count 23 (+ 4) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}