{"id":26,"date":"2013-04-29T22:10:00","date_gmt":"2013-04-30T02:10:00","guid":{"rendered":"http:\/\/naplandgames.com\/blog\/2013\/04\/29\/preparing-for-game-2-learning-php-and-mysql\/"},"modified":"2018-12-18T09:14:54","modified_gmt":"2018-12-18T14:14:54","slug":"preparing-for-game-2-learning-php-and-mysql","status":"publish","type":"post","link":"https:\/\/naplandgames.com\/blog\/2013\/04\/29\/preparing-for-game-2-learning-php-and-mysql\/","title":{"rendered":"Preparing for Game 2 &#8211; Learning PHP and MySQL"},"content":{"rendered":"<p><span style=\"font-family: Georgia, serif; font-size: 15px; line-height: 24px;\">In order for my next game to be able to save user data and transfer data for turns and chat I&#8217;ll need to set up a server and learn how to get data on and off it vial simple HTTP commands. I began my adventure today and will chronicle what I&#8217;ve done so others can easily set up a test system. I feel that what I&#8217;m trying to do is so basic (send data to be written to a database and retrieve that data)<\/span><br \/>\n<span style=\"font-family: Georgia, serif; font-size: 15px; line-height: 24px;\"><br \/>\n<\/span><span style=\"font-family: Georgia, serif; font-size: 15px; line-height: 24px;\">First thing&#8217;s first, set up Apache Server. This was pretty easy: download the ZIP for Apache 2.0, extract the files to the directory of your choice (I chose c:\/Apache), make a few minor changes to its config file, and then just open up some ports on your router and unblock them from your firewall. That&#8217;s it! I had this part of the project going before noon today and was pretty happy with the information I was able to find.<\/span><br \/>\n<span style=\"font-family: Georgia, serif; font-size: 15px; line-height: 24px;\"><br \/>\n<\/span><span style=\"font-family: Georgia, serif; font-size: 15px; line-height: 24px;\">There are a ton of guides out there on how to set up Apache server (2.0 Win32) in Windows, so I&#8217;m not going into great detail here. One thing I should mention is that you should be careful with security. If you&#8217;re just testing an app then shut down your server when not testing. Once the server is installed you should see an icon in your taskbar&#8217;s icon try (tiny up arrow over by the clock). Left clicking on this will allow you to quickly start\/stop\/restart the server.<\/span><br \/>\n<span style=\"font-family: Georgia, serif; font-size: 15px; line-height: 24px;\"><br \/>\n<\/span><span style=\"font-family: Georgia, serif; font-size: 15px; line-height: 24px;\">After you&#8217;ve downloaded the ZIP for Apache server 2.0 for win32 x86 and extract it to the directory of your choice you can start meddling with the configuration file. It&#8217;s called <b><i>httpd.conf<\/i>\u00a0<\/b>and located in the Apache\/conf folder. Simply open it up with Notepad and make the following changes:<\/span><\/p>\n<ul>\n<li><span style=\"font-family: Georgia, serif;\"><span style=\"font-size: 15px; line-height: 24px;\">Find this<\/span><\/span><span style=\"font-family: Georgia, serif;\"><span style=\"font-size: 15px; line-height: 24px;\">:\u00a0<\/span><\/span><span style=\"font-family: 'Courier New', Courier, monospace; font-size: 15px; line-height: 20.796875px;\"><b>ServerName localhost:80<\/b>\u00a0<\/span><span style=\"font-family: Georgia, serif; font-size: 15px; line-height: 24px;\">and replace\u00a0<\/span><span style=\"font-family: 'Courier New', Courier, monospace; font-size: 15px; line-height: 20.796875px;\"><b>localhost<\/b>\u00a0<\/span><span style=\"font-family: Georgia, serif; font-size: 15px; line-height: 24px;\">with whatever name you want. This will be the name you type into your browser on the server computer to check things as you set them up. I left mine alone.<\/span><\/li>\n<li><span style=\"font-family: Georgia, serif;\"><span style=\"font-size: 15px; line-height: 24px;\">You also might want to change this\u00a0<span style=\"font-family: 'Courier New', Courier, monospace; line-height: 20.796875px;\"><b>ServerAdmin admin@localdomain<\/b>\u00a0<\/span>to whatever email address you might want to use. Again I left this alone as my server won&#8217;t need email functionality.<\/span><\/span><\/li>\n<li><span style=\"font-size: 15px; line-height: 24px;\"><span style=\"font-family: Georgia, serif;\">If you don&#8217;t want to use the default directory for you website&#8217;s files then change the\u00a0<\/span><span style=\"font-family: Courier New, Courier, monospace;\"><b>DocumentRoot &#8220;C:\/Apache\/Apache2\/htdocs&#8221;<\/b> <\/span><span style=\"font-family: Georgia, Times New Roman, serif;\">to the directory of your choice.<\/span><\/span><\/li>\n<li><span style=\"font-family: Georgia, serif;\"><span style=\"font-size: 15px; line-height: 24px;\">Change the line\u00a0<\/span><\/span><span style=\"font-family: 'Courier New', Courier, monospace; font-size: 15px; line-height: 20.796875px;\"><b>DirectoryIndex index.html\u00a0<\/b><\/span><span style=\"font-size: 15px; line-height: 24px;\"><span style=\"font-family: Georgia, serif;\">to also include <\/span><span style=\"font-family: Courier New, Courier, monospace; font-weight: bold;\">index.php <\/span><span style=\"font-family: Georgia, Times New Roman, serif;\">&#8211; we&#8217;ll use that later after we set up PHP.<\/span><\/span><\/li>\n<li><span style=\"font-size: 15px; line-height: 24px;\"><span style=\"font-family: Georgia, Times New Roman, serif;\">Next we&#8217;ll want to set up a password. This is done by going to the <\/span><span style=\"font-family: Courier New, Courier, monospace; font-weight: bold;\">Apache\/bin <\/span><span style=\"font-family: Georgia, Times New Roman, serif;\">directory then hold shit and right click in a blank area of the Windows Explorer window and &#8220;Open Command Window Here&#8221; for a command prompt. Type <\/span><b><span style=\"font-family: Courier New, Courier, monospace;\">htpasswd -c &#8220;c:\/Apache\/Apache2\/pw.txt&#8221; yourName<\/span><\/b><span style=\"font-family: Georgia, Times New Roman, serif;\">. Replace the directory with your actual directory and replace\u00a0<b style=\"font-family: 'Times New Roman';\"><span style=\"font-family: Courier New, Courier, monospace;\">yourName<\/span><\/b>\u00a0with whatever name you want for the admin account. You&#8217;ll then be prompted to create a password and you&#8217;re done.<\/span><\/span><\/li>\n<li><span style=\"font-size: 15px; line-height: 24px;\"><span style=\"font-family: Georgia, Times New Roman, serif;\">Now we need to create a script to manage the login. Create a file in Notepad and name it <\/span><b><span style=\"font-family: Courier New, Courier, monospace;\">.htaccess<\/span><\/b><span style=\"font-family: Georgia, Times New Roman, serif;\"> then enter the following:<\/span><\/span><\/li>\n<\/ul>\n<blockquote>\n<pre data-textannotation-=\"\" style=\"-webkit-box-shadow: rgba(0, 0, 0, 0.498039) 0px 0px 5px 0px inset; background-color: #666666; box-shadow: rgba(0, 0, 0, 0.498039) 0px 0px 5px 0px inset; box-sizing: border-box; color: #bdeeff; direction: ltr; font-family: courier; font-size: 14px; line-height: 1.6; margin-bottom: 19px; margin-left: 18px; margin-top: 10px; max-width: 100%; overflow: scroll; padding: 16px 35px 20px; width: 549.2125244140625px;\">AuthType Basic\r\nAuthName \"This is a private area, please log in\" \r\n\r\nAuthUserFile \"<b style=\"font-family: 'Times New Roman'; font-size: 15px; line-height: 24px; white-space: normal;\"><span style=\"font-family: Courier New, Courier, monospace;\">c:\/Apache\/Apache2\/pw.txt<\/span><\/b>\"\r\nAuthGroupFile \/dev\/null \r\n\r\n&lt;Limit GET POST PUT&gt;\r\nrequire valid-user\r\n&lt;\/Limit&gt;<\/pre>\n<\/blockquote>\n<ul>\n<li><span style=\"font-size: 15px; line-height: 24px;\"><span style=\"font-family: Georgia, Times New Roman, serif;\">Restart Apache server and then open a browser and enter<\/span> <span style=\"font-family: 'Courier New', Courier, monospace;\"><b>localhost<\/b><\/span><span style=\"font-family: Georgia, Times New Roman, serif;\"><b style=\"font-size: small;\">\u00a0<\/b>if all went well you should be prompted to enter your username and password. If you didn&#8217;t create any index.html or index.php yet then you won&#8217;t see anything else, so go ahead and create that if you want.<\/span><\/span><\/li>\n<li><span style=\"font-size: 15px; line-height: 24px;\"><span style=\"font-family: Georgia, Times New Roman, serif;\">Now you&#8217;re going to want to set this up so that you can access it via the web so open up your router&#8217;s settings and port forward port 80 for the IP address of your server. Then set your server&#8217;s IP to be in the DMZ (usually under WAN setup). \u00a0You may also want to make sure the computer you&#8217;re using as a server has a fixed IP on the network and the address has been reserved on the router.\u00a0<\/span><\/span><\/li>\n<li><span style=\"font-size: 15px; line-height: 24px;\"><span style=\"font-family: Georgia, Times New Roman, serif;\">Finally you&#8217;ll want to open up your firewall and add an exception for two-way traffic on port 80. Now you should be able to go to any computer on the internet and login to see your website.<\/span><\/span><\/li>\n<\/ul>\n<div><span style=\"font-family: Georgia, Times New Roman, serif;\"><span style=\"font-size: 15px; line-height: 24px;\">That&#8217;s all it takes. Many other guides I see have a bit more detail, but they seem like they expect you don&#8217;t know much about changing your router settings or how to navigate Windows Explorer to find files. I hope that this guide is a bit more to-the-point and helps the slightly advanced user get up and running quickly. If you&#8217;re stuck on any point you might want to search Google for a more detailed guide. For many I hope this will get you up and running in a jiffy.<\/span><\/span><\/div>\n<div><span style=\"font-family: Georgia, Times New Roman, serif;\"><span style=\"font-size: 15px; line-height: 24px;\">\u00a0<\/span><\/span><\/div>\n<div><span style=\"font-family: Georgia, Times New Roman, serif;\"><span style=\"font-size: 15px; line-height: 24px;\">Next up is setting up PHP and then MySQL. Thanks for reading, see you next time!<\/span><\/span><\/div>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_26\" class=\"pvc_stats all  \" data-element-id=\"26\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/naplandgames.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In order for my next game to be able to save user data and transfer data for turns and chat I&#8217;ll need to set up a server and learn how to get data on and off it vial simple HTTP commands. I began my adventure today and will chronicle what I&#8217;ve done so others can easily set up a test system. I feel that what I&#8217;m trying to do is so basic (send data to be written to a database and retrieve that data) First thing&#8217;s first, set up Apache Server. This was pretty easy: download the ZIP for Apache&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/naplandgames.com\/blog\/2013\/04\/29\/preparing-for-game-2-learning-php-and-mysql\/\">Continue reading<span class=\"screen-reader-text\">Preparing for Game 2 &#8211; Learning PHP and MySQL<\/span><\/a><\/div>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_26\" class=\"pvc_stats all  \" data-element-id=\"26\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/naplandgames.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"a3_pvc":{"activated":true,"total_views":1009,"today_views":8},"_links":{"self":[{"href":"https:\/\/naplandgames.com\/blog\/wp-json\/wp\/v2\/posts\/26"}],"collection":[{"href":"https:\/\/naplandgames.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/naplandgames.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/naplandgames.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/naplandgames.com\/blog\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":2,"href":"https:\/\/naplandgames.com\/blog\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":130,"href":"https:\/\/naplandgames.com\/blog\/wp-json\/wp\/v2\/posts\/26\/revisions\/130"}],"wp:attachment":[{"href":"https:\/\/naplandgames.com\/blog\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/naplandgames.com\/blog\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/naplandgames.com\/blog\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}