{"id":2343,"date":"2018-11-14T05:29:02","date_gmt":"2018-11-14T05:29:02","guid":{"rendered":"https:\/\/miloserdov.org\/?p=2343"},"modified":"2019-02-21T01:47:11","modified_gmt":"2019-02-21T01:47:11","slug":"web-server-installation-guide-on-windows-apache-php-mariadb-and-phpmyadmin-how-to-provide-local-web-server-security","status":"publish","type":"post","link":"https:\/\/miloserdov.org\/?p=2343","title":{"rendered":"Web server installation guide on Windows: Apache, PHP, MariaDB and phpMyAdmin. How to provide local web server security"},"content":{"rendered":"<div class=\"0b20205ac99e89c6cabdb919fd9d1a8a\" data-index=\"1\" style=\"float: none; margin:10px 0 10px 0; text-align:center;\">\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:block; text-align:center;\"\r\n     data-ad-format=\"fluid\"\r\n     data-ad-layout=\"in-article\"\r\n     data-ad-client=\"ca-pub-7219829351026140\"\r\n     data-ad-slot=\"9942251718\"><\/ins>\r\n<script>\r\n     (adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\r\n\r\n\n<\/div>\n<h2 style=\"text-align: justify;\">\n\tTable of contents<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\t<a href=\"#1\">1. Web server on a computer<\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"#2\">2. What does a web server consist of<\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"#3\">3. Download a web server for Windows<\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"#4\">4. Installing a web server in Windows<\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"#5\">5. Installing Apache 2.4 in Windows<\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"#6\">6. Installing MariaDB on Windows<\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"#7\">7. Installing PHP on Windows<\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"#8\">8. Installing phpMyAdmin on Windows<\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"#9\">9. How to secure a web server on Windows<\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"#10\">10. Conclusion<\/a>\n<\/p>\n<hr \/>\n<p style=\"text-align: justify;\">\n\tIf you are interested in installing Apache, PHP, <strong>MySQL<\/strong> and phpMyAdmin on Windows, then see <a href=\"https:\/\/miloserdov.org\/?p=55\" target=\"_blank\">this manual<\/a>.\n<\/p>\n<h2 style=\"text-align: justify;\">\n\t<a id=\"1\" name=\"1\"><\/a>Web server on a computer<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tA web server on your computer is a very convenient way to work with web applications for any purpose:\n<\/p>\n<ul>\n<li style=\"text-align: justify;\">\n\t\ttesting new CMS and other programs\n\t<\/li>\n<li style=\"text-align: justify;\">\n\t\twriting and debugging PHP scripts\n\t<\/li>\n<li style=\"text-align: justify;\">\n\t\torganization of your own working environment (various useful programs running on a web server &#8211; organizers, aggregators)\n\t<\/li>\n<li style=\"text-align: justify;\">\n\t\torganization of local network resources (file sharers, chat rooms, streaming video and other services for all devices in an apartment)\n\t<\/li>\n<li style=\"text-align: justify;\">\n\t\tcreation of a laboratory (training in penetration testing with special vulnerable web applications)\n\t<\/li>\n<\/ul>\n<h2 style=\"text-align: justify;\">\n\t<a id=\"2\" name=\"2\"><\/a>What does a web server consist of<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tIn most cases, the server includes four main components:\n<\/p>\n<ul>\n<li style=\"text-align: justify;\">\n\t\t<strong>Apache<\/strong> is the web server itself, which processes incoming requests from users and send them back pages of a web sites. Without additional modules, Apache is mainly intended for displaying static pages in which there are no changes on the server side.\n\t<\/li>\n<li style=\"text-align: justify;\">\n\t\t<strong>PHP<\/strong> is an environment for running PHP scripts. PHP scripts allow you to create highly functional websites, dynamic web applications, save data to a database and request data from there.\n\t<\/li>\n<li style=\"text-align: justify;\">\n\t\t<strong>MariaDB<\/strong> is a database management system. To make it easier to understand &#8211; this is the database in which all the information is stored. Until recently, MySQL was probably the most popular DBMS. As for MariaDB, it is based on MySQL, but with some modifications. If you are wondering what the difference is, then see the details <a href=\"https:\/\/miloserdov.org\/?p=1827\" target=\"_blank\">here<\/a>. If MySQL is the requirement for an application, then MariaDB is also suitable, as they are compatible with each other.\n\t<\/li>\n<li style=\"text-align: justify;\">\n\t\t<strong>phpMyAdmin<\/strong> is an example web application that runs on PHP. With phpMyAdmin, you can view databases, create new databases and tables, populate and delete them, make backup copies of databases and restore from backups. phpMyAdmin is very popular, so many consider it part of the web server\n\t<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">\n\tI will show installation of the server on the example of Windows 10.\n<\/p>\n<h2 style=\"text-align: justify;\">\n\t<a id=\"3\" name=\"3\"><\/a>Download a web server for Windows<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\t<strong>Download Apache<\/strong>\n<\/p>\n<p style=\"text-align: justify;\">\n\tTo download Apache for Windows, go to: <a href=\"https:\/\/www.apachelounge.com\/download\/\" target=\"_blank\">apachelounge.com\/download\/<\/a>. Choose Win64 or Win32 version (the first for 64-bit systems, and the second for 32-bit). On the same page, download C++ Redistributable Visual Studio 2017: <a href=\"https:\/\/aka.ms\/vs\/15\/release\/VC_redist.x64.exe\" target=\"_blank\">vc_redist_x64<\/a> or <a href=\"https:\/\/aka.ms\/vs\/15\/release\/VC_redist.x86.exe\" target=\"_blank\">vc_redist_x86<\/a>. It contains the necessary libraries for the web server, since Apache for Windows was compiled in Visual Studio 2017. By the way, C++ Redistributable Visual Studio 2017 is also needed for the PHP interpreter and MariaDB.\n<\/p>\n<p style=\"text-align: justify;\">\n\tInstall the downloaded vc_redist &ndash; we will not return to it.\n<\/p>\n<p style=\"text-align: justify;\">\n\t<strong>Download PHP<\/strong>\n<\/p>\n<p style=\"text-align: justify;\">\n\tTo download PHP for Windows, go to <a href=\"https:\/\/windows.php.net\/download\/\" target=\"_blank\">windows.php.net\/download\/<\/a>. There select the file <strong>VC15 x64 Thread Safe<\/strong> or <strong>VC15 x86 Thread Safe<\/strong>. Note: you need to download the <strong>Zip<\/strong> file (and not the <strong>Debug Pack<\/strong>).\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/91.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-2351\" height=\"940\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/91.png\" width=\"1270\" srcset=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/91.png 1270w, https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/91-1000x740.png 1000w, https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/91-768x568.png 768w\" sizes=\"(max-width: 1270px) 100vw, 1270px\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\t<strong>Download MariaDB<\/strong>\n<\/p>\n<p style=\"text-align: justify;\">\n\tTo download MariaDB for Windows, go to <a href=\"https:\/\/downloads.mariadb.org\/\" target=\"_blank\">downloads.mariadb.org<\/a>. There, click on the green button of the latest release. On the page that opens, find a file that looks like <strong>mariadb-xx.x.xx-winx64.zip<\/strong> or <strong>mariadb-xx.x.xx-win32.zip<\/strong>. When you click on the file, another page will open, there simply find and click the button that says &lsquo;<strong>No thanks, just take me to the download<\/strong>&rsquo;.\n<\/p>\n<p style=\"text-align: justify;\">\n\t<strong>Download phpMyAdmin<\/strong>\n<\/p>\n<p style=\"text-align: justify;\">\n\tDownload phpMyAdmin from <a href=\"https:\/\/www.phpmyadmin.net\/\" target=\"_blank\">phpmyadmin.net<\/a>. There, find the button with the word <strong>Download<\/strong>.\n<\/p>\n<h2 style=\"text-align: justify;\">\n\t<a id=\"4\" name=\"4\"><\/a>Installing a web server in Windows<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tCreate a directory structure of our server. The main idea is to separate executable files from data files. This is convenient for server maintenance, including backup.\n<\/p>\n<p style=\"text-align: justify;\">\n\tIn the root of the <strong>C:\\ <\/strong>drive, create the <strong>Server<\/strong> directory. In this directory, create two subdirectories: <strong>bin<\/strong> (for executable files) and <strong>data<\/strong>.\n<\/p>\n<p style=\"text-align: justify;\">\n\tGo to the <strong>data<\/strong> directory and there create subfolders <strong>DB<\/strong> (for databases) and <strong>htdocs<\/strong> (for sites).\n<\/p>\n<h2 style=\"text-align: justify;\">\n\t<a id=\"5\" name=\"5\"><\/a>Installing Apache 2.4 in Windows<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tFrom the httpd-x.x.xx-win64-VC15.zip archive with the downloaded web server, unpack the <strong>Apache24<\/strong> folder to the <strong>C:\\Server\\bin\\<\/strong> directory.\n<\/p>\n<p style=\"text-align: justify;\">\n\tIn the <strong>C:\\Server\\bin\\Apache24\\conf\\<\/strong> folder, open the <strong>httpd.conf <\/strong>file with a text editor. This is the main Apache configuration file &#8211; all the settings we will do in it. Lines that begin with <strong>#<\/strong> are comments and the server does not pay attention to them.\n<\/p>\n<p style=\"text-align: justify;\">\n\tTo install the correct server root folder, find the string\n<\/p>\n<pre class=\"brush:plain;\">\r\nDefine SRVROOT &quot;c:\/Apache24&quot;<\/pre>\n<p style=\"text-align: justify;\">\n\tand replace it with\n<\/p>\n<pre class=\"brush:plain;\">\r\nDefine SRVROOT &quot;c:\/Server\/bin\/Apache24&quot;<\/pre>\n<p style=\"text-align: justify;\">\n\tScrolling through the list of modules. It is a list of all available extensions (plug-ins) of the server. Those that are commented out are disabled. To enable them, remove the <strong>#<\/strong> sign at the beginning of the line.\n<\/p>\n<p style=\"text-align: justify;\">\n\tTo begin with, I recommend to include only mod_rewrite. For this line\n<\/p>\n<pre class=\"brush:plain;\">\r\n#LoadModule rewrite_module modules\/mod_rewrite.so<\/pre>\n<p style=\"text-align: justify;\">\n\tchange to\n<\/p>\n<pre class=\"brush:plain;\">\r\nLoadModule rewrite_module modules\/mod_rewrite.so<\/pre>\n<p style=\"text-align: justify;\">\n\tFind the line\n<\/p>\n<pre class=\"brush:plain;\">\r\n#ServerName www.example.com:80<\/pre>\n<p style=\"text-align: justify;\">\n\tand change to\n<\/p>\n<pre class=\"brush:plain;\">\r\nServerName localhost<\/pre>\n<p style=\"text-align: justify;\">\n\tThis directive sets the server name, which does not affect anything. But if you do not register this name, then a warning will be displayed (that there is no name) &#8211; this confuses some users, as they take this message as an error.\n<\/p>\n<p style=\"text-align: justify;\">\n\tFind the following rows\n<\/p>\n<pre class=\"brush:plain;\">\r\nDocumentRoot &quot;${SRVROOT}\/htdocs&quot;\r\n&lt;Directory &quot;${SRVROOT}\/htdocs&quot;&gt;<\/pre>\n<p style=\"text-align: justify;\">\n\tand replace them with\n<\/p>\n<pre class=\"brush:plain;\">\r\nDocumentRoot &quot;c:\/Server\/data\/htdocs\/&quot;\r\n&lt;Directory &quot;c:\/Server\/data\/htdocs\/&quot;&gt;<\/pre>\n<p style=\"text-align: justify;\">\n\tIn short, <strong>DocumentRoot<\/strong> is the main directory where all the virtual hosts and site files will be placed. And <strong>Directory<\/strong> in this case sets the settings of the primary host (if necessary, you can create several virtual hosts with different settings).\n<\/p>\n<p style=\"text-align: justify;\">\n\tJust below find the lines (comments are provided for orientation):\n<\/p>\n<pre class=\"brush:plain;\">\r\n# AllowOverride controls what directives may be placed in .htaccess files.\r\n# It can be &quot;All&quot;, &quot;None&quot;, or any combination of the keywords:\r\n#   AllowOverride FileInfo AuthConfig Limit\r\n#\r\nAllowOverride None<\/pre>\n<p style=\"text-align: justify;\">\n\tAnd replace with (only the last line changes):\n<\/p>\n<pre class=\"brush:plain;\">\r\n# AllowOverride controls what directives may be placed in .htaccess files.\r\n# It can be &quot;All&quot;, &quot;None&quot;, or any combination of the keywords:\r\n#   AllowOverride FileInfo AuthConfig Limit\r\n#\r\nAllowOverride All<\/pre>\n<p style=\"text-align: justify;\">\n\tWith this setting we have enabled support for the <strong>.htaccess<\/strong> file. It is needed for <strong>mod_rewrite<\/strong> and other features. Using the <strong>.htaccess<\/strong> file, you can deny access to a specific folder and change some server settings at the folder level.\n<\/p>\n<p style=\"text-align: justify;\">\n\tFind the line\n<\/p>\n<pre class=\"brush:plain;\">\r\nDirectoryIndex index.html<\/pre>\n<p style=\"text-align: justify;\">\n\tand change to\n<\/p>\n<pre class=\"brush:plain;\">\r\nDirectoryIndex index.php index.html index.htm<\/pre>\n<p style=\"text-align: justify;\">\n\tSave the configuration file.\n<\/p>\n<p style=\"text-align: justify;\">\n\tNow open the Windows command line, to do this, press the <strong>Win+x<\/strong> keys and select <strong>Windows PowerShell (Admin)<\/strong> there:\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/915.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-2347\" height=\"619\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/915.png\" width=\"275\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tIn the opened window, copy the commands to install and start Apache (after entering each command, press ENTER):\n<\/p>\n<pre class=\"brush:bash;\">\r\nc:\\Server\\bin\\Apache24\\bin\\httpd.exe -k install\r\nc:\\Server\\bin\\Apache24\\bin\\httpd.exe -k start<\/pre>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/93.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-2357\" height=\"207\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/93.png\" width=\"883\" srcset=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/93.png 883w, https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/93-768x180.png 768w\" sizes=\"(max-width: 883px) 100vw, 883px\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tOpen <a href=\"http:\/\/localhost\/\" target=\"_blank\">http:\/\/localhost\/<\/a> in your web browser.\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/96.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-2356\" height=\"316\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/96.png\" width=\"476\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tThe web server is working, but there is not a single file in the document folder.\n<\/p>\n<p style=\"text-align: justify;\">\n\tAdd to the <strong>C:\\Server\\data\\htdocs\\<\/strong> folder HTML files, for example the file <strong>hello.htm<\/strong> with the following contents:\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;!DOCTYPE HTML&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;meta charset=&quot;utf-8&quot;&gt;\r\n&lt;title&gt;My first file on my web server&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;p&gt;Hurray, the web server is working! It&#39;s time to learn HTML!&lt;\/p&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p style=\"text-align: justify;\">\n\tOpen <a href=\"http:\/\/localhost\/\" target=\"_blank\">http:\/\/localhost\/<\/a> again and you will see your file:\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/97.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-2355\" height=\"317\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/97.png\" width=\"419\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tI think you got the point &#8211; in the <strong>C:\\Server\\data\\htdocs\\ <\/strong>folder place your HTML files and sites. In <strong>C:\\Server\\data\\htdocs\\<\/strong> you can make subfolders of any nesting level, they will be available at addresses like <strong>http:\/\/localhost\/subfolder<\/strong>.\n<\/p>\n<h2 style=\"text-align: justify;\">\n\t<a id=\"6\" name=\"6\"><\/a>Installing MariaDB on Windows<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tNext we configure and launch MariaDB. Begin by unpacking the contents of the mariadb-xx.x.x-winx64.zip archive into the <strong>C:\\Server\\bin\\<\/strong> folder. Rename new folder to <strong>mariadb<\/strong>. It turns out that MariaDB is located on the disk in the <strong>C:\\Server\\bin\\mariadb\\ <\/strong>folder.\n<\/p>\n<p style=\"text-align: justify;\">\n\tMove the <strong>C:\\Server\\bin\\mariadb\\data\\<\/strong> folder to the <strong>C:\\Server\\data\\DB\\ <\/strong>folder.\n<\/p>\n<p style=\"text-align: justify;\">\n\tIn the <strong>C:\\Server\\bin\\mariadb\\<\/strong> folder create the <strong>my.cnf <\/strong>file and copy into it:\n<\/p>\n<pre class=\"brush:plain;\">\r\n[mysqld]\r\n \r\ndatadir=&quot;c:\/Server\/data\/DB\/data\/&quot;\r\nbind-address = 127.0.0.1<\/pre>\n<p style=\"text-align: justify;\">\n\tSave and close this file.\n<\/p>\n<p style=\"text-align: justify;\">\n\tTo install and start the service run the commands:\n<\/p>\n<pre class=\"brush:bash;\">\r\nC:\\Server\\bin\\mariadb\\bin\\mysqld --install\r\nnet start mysql<\/pre>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/99.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-2354\" height=\"214\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/99.png\" width=\"522\" \/><\/a>\n<\/p>\n<h2 style=\"text-align: justify;\">\n\t<a id=\"7\" name=\"7\"><\/a>Installing PHP on Windows<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tTo install and connect PHP to Apache on Windows, in the <strong>c:\\Server\\bin\\<\/strong> folder, create a <strong>PHP<\/strong> subfolder and copy the contents of the php-x.x.xx-Win32-VC15-x64.zip archive into it.\n<\/p>\n<p style=\"text-align: justify;\">\n\tIn the <strong>C:\\Server\\bin\\PHP\\<\/strong> directory find the <strong>php.ini-development<\/strong> file and rename it to <strong>php.ini<\/strong>, then open it with a text editor.\n<\/p>\n<p style=\"text-align: justify;\">\n\tIn this file, find the line\n<\/p>\n<pre class=\"brush:plain;\">\r\n;extension_dir = &quot;ext&quot;<\/pre>\n<p style=\"text-align: justify;\">\n\tand replace it with:\n<\/p>\n<pre class=\"brush:plain;\">\r\nextension_dir = &quot;C:\\Server\\bin\\PHP\\ext\\&quot;<\/pre>\n<p style=\"text-align: justify;\">\n\tNow find the lines that begin with <strong>;extension=<\/strong>:\n<\/p>\n<pre class=\"brush:plain;\">\r\n;extension=bz2\r\n;extension=curl\r\n;extension=fileinfo\r\n;extension=gd2\r\n;extension=gettext\r\n;extension=gmp\r\n;extension=intl\r\n;extension=imap\r\n;extension=interbase\r\n;extension=ldap\r\n;extension=mbstring\r\n;extension=exif ; Must be after mbstring as it depends on it\r\n;extension=mysqli\r\n;extension=oci8_12c ; Use with Oracle Database 12c Instant Client\r\n;extension=odbc\r\n;extension=openssl\r\n;extension=pdo_firebird\r\n;extension=pdo_mysql\r\n;extension=pdo_oci\r\n;extension=pdo_odbc\r\n;extension=pdo_pgsql\r\n;extension=pdo_sqlite\r\n;extension=pgsql\r\n;extension=shmop<\/pre>\n<p style=\"text-align: justify;\">\n\tUncomment the extensions you need. I recommend activating extensions that are almost certainly needed (just replace the previous lines in the configuration file with the following):\n<\/p>\n<pre class=\"brush:plain;\">\r\nextension=bz2\r\n;extension=curl\r\nextension=fileinfo\r\nextension=gd2\r\nextension=gettext\r\nextension=gmp\r\n;extension=intl\r\n;extension=imap\r\n;extension=interbase\r\n;extension=ldap\r\nextension=mbstring\r\nextension=exif ; Must be after mbstring as it depends on it\r\nextension=mysqli\r\n;extension=oci8_12c ; Use with Oracle Database 12c Instant Client\r\nextension=odbc\r\nextension=openssl\r\n;extension=pdo_firebird\r\nextension=pdo_mysql\r\n;extension=pdo_oci\r\n;extension=pdo_odbc\r\n;extension=pdo_pgsql\r\nextension=pdo_sqlite\r\n;extension=pgsql\r\n;extension=shmop<\/pre>\n<p style=\"text-align: justify;\">\n\tAlso uncomment the lines (except one):\n<\/p>\n<pre class=\"brush:plain;\">\r\n;extension=soap\r\n;extension=sockets\r\n;extension=sodium\r\n;extension=sqlite3\r\n;extension=tidy\r\n;extension=xmlrpc\r\n;extension=xsl<\/pre>\n<p style=\"text-align: justify;\">\n\tIt turns out:\n<\/p>\n<pre class=\"brush:plain;\">\r\nextension=soap\r\nextension=sockets\r\n;extension=sodium\r\nextension=sqlite3\r\nextension=tidy\r\nextension=xmlrpc\r\nextension=xsl<\/pre>\n<p style=\"text-align: justify;\">\n\tSave and close this file.\n<\/p>\n<p style=\"text-align: justify;\">\n\tNow we need to enable PHP in Apache. To do this, in the file <strong>c:\\Server\\bin\\Apache24\\conf\\httpd.conf<\/strong>, add the lines to the very end:\n<\/p>\n<pre class=\"brush:plain;\">\r\nPHPIniDir &quot;C:\/Server\/bin\/PHP&quot;\r\nAddHandler application\/x-httpd-php .php\r\nLoadModule php7_module &quot;C:\/Server\/bin\/PHP\/php7apache2_4.dll&quot;<\/pre>\n<p style=\"text-align: justify;\">\n\tSave and close the file.\n<\/p>\n<p style=\"text-align: justify;\">\n\tAfter that, restart Apache on the command line:\n<\/p>\n<pre class=\"brush:bash;\">\r\nc:\\Server\\bin\\Apache24\\bin\\httpd.exe -k restart<\/pre>\n<p style=\"text-align: justify;\">\n\tTo verify that PHP works in Windows, in the directory <strong>c:\\Server\\data\\htdocs\\<\/strong> create a file called <strong>i.php<\/strong>\n<\/p>\n<p style=\"text-align: justify;\">\n\tCopy to this file:\n<\/p>\n<pre class=\"brush:php;\">\r\n&lt;?php\r\nphpinfo ();<\/pre>\n<p style=\"text-align: justify;\">\n\tIn your browser, open the <a href=\"http:\/\/localhost\/i.php\" target=\"_blank\">http:\/\/localhost\/i.php<\/a> link. If you see a similar page, it means that PHP is properly configured and successfully works with Apache on Windows:\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/914.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-2350\" height=\"934\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/914.png\" width=\"1262\" srcset=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/914.png 1262w, https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/914-1000x740.png 1000w, https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/914-768x568.png 768w\" sizes=\"(max-width: 1262px) 100vw, 1262px\" \/><\/a>\n<\/p>\n<h2 style=\"text-align: justify;\">\n\t<a id=\"8\" name=\"8\"><\/a>Installing phpMyAdmin on Windows<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tIn the directory <strong>c:\\Server\\data\\htdocs\\<\/strong> copy the contents of the archive phpMyAdmin-x.x.x-all-languages.zip. Rename the resulting folder to <strong>phpMyAdmin<\/strong>, it turns out that phpMyAdmin is located in the <strong>C:\\Server\\data\\htdocs\\phpMyAdmin\\<\/strong> directory.\n<\/p>\n<p style=\"text-align: justify;\">\n\tIn this folder, create a&nbsp;<strong>config.inc.php<\/strong>&nbsp;file with a text editor and copy to this file:\n<\/p>\n<pre class=\"brush:php;\">\r\n&lt;?php\r\n \r\n\/* Servers configuration *\/\r\n$i = 0;\r\n \r\n\/* Server: localhost [1] *\/\r\n$i++;\r\n$cfg['Servers'][$i]['verbose'] = &#39;&#39;;\r\n$cfg['Servers'][$i]['host'] = &#39;localhost&#39;;\r\n$cfg['Servers'][$i]['port'] = &#39;&#39;;\r\n$cfg['Servers'][$i]['socket'] = &#39;&#39;;\r\n$cfg['Servers'][$i]['connect_type'] = &#39;tcp&#39;;\r\n$cfg['Servers'][$i]['extension'] = &#39;mysqli&#39;;\r\n$cfg['Servers'][$i]['auth_type'] = &#39;cookie&#39;;\r\n$cfg['Servers'][$i]['user'] = &#39;root&#39;;\r\n$cfg['Servers'][$i]['password'] = &#39;&#39;;\r\n$cfg['Servers'][$i]['nopassword'] = true;\r\n$cfg['Servers'][$i]['AllowNoPassword'] = true;\r\n \r\n\/* End of servers configuration *\/ \r\n$cfg['blowfish_secret'] = &#39;kjLGJ8g;Hj3mlHy+Gd~FE3mN{gIATs^1lX+T=KVYv{ubK*U0V&#39;;\r\n$cfg['DefaultLang'] = &#39;ru&#39;;\r\n$cfg['ServerDefault'] = 1;\r\n$cfg['UploadDir'] = &#39;&#39;;\r\n$cfg['SaveDir'] = &#39;&#39;;<\/pre>\n<p style=\"text-align: justify;\">\n\tSave and close this file.\n<\/p>\n<p style=\"text-align: justify;\">\n\tTo access phpMyAdmin, go to <a href=\"http:\/\/localhost\/phpMyAdmin\/\" target=\"_blank\">http:\/\/localhost\/phpMyAdmin\/<\/a>, enter <strong>root<\/strong> as the user name, leave the password field <strong>empty<\/strong>:\n<\/p>\n<p style=\"text-align: justify;\">\n\tThe message below is shown:\n<\/p>\n<pre class=\"brush:plain;\">\r\nThe phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. Find out why.\r\nOr alternately go to &#39;Operations&#39; tab of any database to set it up there.<\/pre>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/916.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-2349\" height=\"916\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/916.png\" width=\"1209\" srcset=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/916.png 1209w, https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/916-1000x758.png 1000w, https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/916-768x582.png 768w\" sizes=\"(max-width: 1209px) 100vw, 1209px\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tTo learn more, go to <a href=\"http:\/\/localhost\/phpMyAdmin\/chk_rel.php\" target=\"_blank\">http:\/\/localhost\/phpMyAdmin\/chk_rel.php<\/a>:\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/917.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-2348\" height=\"315\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/917.png\" width=\"1059\" srcset=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/917.png 1059w, https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/917-1000x297.png 1000w, https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/917-768x228.png 768w\" sizes=\"(max-width: 1059px) 100vw, 1059px\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tIt will be written there:\n<\/p>\n<pre class=\"brush:plain;\">\r\nConfiguration of pmadb&hellip; not OK\r\nGeneral relation features Disabled\r\nCreate a database named &#39;phpmyadmin&#39; and setup the phpMyAdmin configuration storage there.<\/pre>\n<p style=\"text-align: justify;\">\n\tTo fix the problem, it is enough to create the required database, to do this, just go to <a href=\"http:\/\/localhost\/phpMyAdmin\/chk_rel.php?db=&amp;goto=db_operations.php&amp;create_pmadb=1\" target=\"_blank\">http:\/\/localhost\/phpMyAdmin\/chk_rel.php?db=&amp;goto=db_operations.php&amp;create_pmadb=1<\/a>\n<\/p>\n<h2 style=\"text-align: justify;\">\n\t<a id=\"9\" name=\"9\"><\/a>How to secure a web server on Windows<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tAfter starting the server it will not be superfluous to take care of its security. Network service carries an increased risk because other devices and people can connect to it, including attackers. Under certain conditions, not only the web server can be compromised, but the entire computer on which this server is running and even other devices on the local network can be compromised. Since Apache works with elevated privileges in Windows and file permissions are not properly configured, a web server with a vulnerable script could allow an attacker to access any file on the computer.\n<\/p>\n<p style=\"text-align: justify;\">\n\t<strong>Denying access from outside to MariaDB\/MySQL<\/strong>\n<\/p>\n<p style=\"text-align: justify;\">\n\tA standard web server, including the one we just installed, has two network services:\n<\/p>\n<ul>\n<li style=\"text-align: justify;\">\n\t\tthe web server itself, which listens on port 80 (when HTTPS is enabled, port 443 is also listened)\n\t<\/li>\n<li style=\"text-align: justify;\">\n\t\tnetwork service of database management system, that is, MariaDB or MySQL, which listens on port 3306\n\t<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">\n\tThe DBMS is a network service, it is convenient because you can connect to MariaDB\/MySQL from another computer and perform various actions on the databases. For local processes, this is also normal &#8211; they connect to the network service using the virtual network interface <a href=\"https:\/\/en.wikipedia.org\/wiki\/Loopback\" target=\"_blank\">Loopback<\/a>. To say short, this is the way to connect to a network service that runs on the same computer. That is, we seem to make a request to the network, and the network service sees these packets as if they came from the network. That is, the network service client and the network service itself work as they should, but the traffic actually does not go anywhere from the computer.\n<\/p>\n<p style=\"text-align: justify;\">\n\tSo, for MariaDB we wrote in the configuration file:\n<\/p>\n<pre class=\"brush:plain;\">\r\nbind-address = 127.0.0.1<\/pre>\n<p style=\"text-align: justify;\">\n\tThis means that it only listens on the network interface with IP address 127.0.0.1, which is related to Loopback. This, in turn, means that no one from outside (outside the computer that the web server is running on) will be able to connect to MariaDB\/MySQL. At the same time, sites and other applications will work with databases as if nothing had happened &#8211; they just use such connections to the address 127.0.0.1.\n<\/p>\n<p style=\"text-align: justify;\">\n\tThat is, MariaDB is already protected.\n<\/p>\n<p style=\"text-align: justify;\">\n\t<strong>Denying access from outside to Apache<\/strong>\n<\/p>\n<p style=\"text-align: justify;\">\n\tAs for the web server, the setting here depends on your needs &#8211; what exactly is the server for?\n<\/p>\n<p style=\"text-align: justify;\">\n\tIf you use the server only for writing scripts, testing sites and you do not need to be able to connect to it from outside, then in the file <strong>C:\\Server\\bin\\Apache24\\conf\\httpd.conf<\/strong>, find the <strong>Listen<\/strong> directive, its default value is:\n<\/p>\n<pre class=\"brush:plain;\">\r\nListen 80<\/pre>\n<p style=\"text-align: justify;\">\n\tAnd replace it with\n<\/p>\n<pre class=\"brush:plain;\">\r\nListen 127.0.0.1:80<\/pre>\n<p style=\"text-align: justify;\">\n\tRestart the server for the changes to take effect:\n<\/p>\n<pre class=\"brush:bash;\">\r\nc:\\Server\\bin\\Apache24\\bin\\httpd.exe -k restart<\/pre>\n<p style=\"text-align: justify;\">\n\tAfter that, no device in the global or local network will be able to connect to your web server. But as before, you can easily open its contents in a web browser using the address <a href=\"http:\/\/localhost\/\" target=\"_blank\">http:\/\/localhost\/<\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tIf you want to make the Apache server available to everyone on the local network, but not available on the global network, then there are two options.\n<\/p>\n<ul>\n<li style=\"text-align: justify;\">\n\t\t<u>The first<\/u>:\n\t<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">\n\tAssign a static address to the computer with the server, and then set it with the <strong>Listen local_IP:80<\/strong> directive. It turns out exactly the effect that is needed: the web server will respond to requests from the local network and will ignore requests from the Internet.&nbsp;For details on setting up static IP, see the article &ldquo;<a href=\"https:\/\/miloserdov.org\/?p=978\" target=\"_blank\">How to make a web-server on Windows accessible to others.<\/a>&rdquo;\n<\/p>\n<ul>\n<li style=\"text-align: justify;\">\n\t\tAlso, <u>the second<\/u> way is simpler than the first:\n\t<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">\n\tIn the <strong>C:\\Server\\data\\htdocs\\<\/strong> folder (this is our root folder for web documents), create a <strong>.htaccess<\/strong> file and type in:\n<\/p>\n<pre class=\"brush:plain;\">\r\nRequire ip 10.0.0.0\/8 172.16.0.0\/12 192.168.0.0\/16 127.0.0.0\/8 ::1\/128<\/pre>\n<p style=\"text-align: justify;\">\n\tThis line allowed access to the server for devices with IP from all local ranges, as well as loopback addresses, for all others, when you try to connect to the server, the following message will be displayed:\n<\/p>\n<pre class=\"brush:plain;\">\r\nForbidden\r\nYou don&#39;t have permission to access \/ on this server.<\/pre>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/913.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-2352\" height=\"104\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2018\/11\/913.png\" width=\"390\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tYou can edit the above line for your needs, for example, you can remove the ranges 10.0.0.0\/8 and 172.16.0.0\/12 if they are not used on your local network. The IP addresses from 10.0.0.0\/8 can be used by the Internet provider for NAT, and 172.16.0.0\/12 can be used for local area networks at the city level (some providers have them). Therefore, if you leave the ranges 10.0.0.0\/8 and 172.16.0.0\/12, then under certain circumstances (the cable of the Internet provider is directly connected to the computer without a router, and the Internet provider uses the ranges 10.0.0.0\/8 and 172.16.0.0\/12) users of these local networks will be able to connect to your server with these settings.\n<\/p>\n<p style=\"text-align: justify;\">\n\tSo also try\n<\/p>\n<pre class=\"brush:plain;\">\r\nRequire ip 192.168.0.0\/16 127.0.0.0\/8 ::1\/128<\/pre>\n<p style=\"text-align: justify;\">\n\tIf everything works and there are no problems, then stop at the second version.\n<\/p>\n<p style=\"text-align: justify;\">\n\t<strong>Setting a password on MariaDB \/ MySQL<\/strong>\n<\/p>\n<p style=\"text-align: justify;\">\n\tBy default, the <strong>root<\/strong> user has an empty password. Since we have disabled access to the MariaDB\/MySQL server from outside, this is not so dangerous. However, the threat remains that the attacker will find a vulnerability in the web application and be able to connect through it. Therefore, if you wish to harden your web server, you can set a password for the <strong>root<\/strong> user in MariaDB\/MySQL.\n<\/p>\n<p style=\"text-align: justify;\">\n\tTo do this, open the command line, enter:\n<\/p>\n<pre class=\"brush:bash;\">\r\ncd C:\\Server\\bin\\mariadb\\bin\\\r\n.\\mysql -u root<\/pre>\n<p style=\"text-align: justify;\">\n\tInside MySQL:\n<\/p>\n<pre class=\"brush:sql;\">\r\nFLUSH PRIVILEGES;\r\nALTER USER &#39;root&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;new_password&#39;;\r\nexit;<\/pre>\n<p style=\"text-align: justify;\">\n\tReplace <strong>new_password<\/strong> with your actual password.\n<\/p>\n<h2 style=\"text-align: justify;\">\n\t<a id=\"10\" name=\"10\"><\/a>Conclusion<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tIn this manual, we learned how to install and configure a web server on Windows, got acquainted with the basic principles of its work. We also learned what needs to be done to make the web server more secure for the main system.\n<\/p>\n<p lang=\"en-US\" style=\"text-align: justify;\">\n\tRecommended for you &#39;<a href=\"https:\/\/miloserdov.org\/?p=2655\" target=\"_blank\">How to protect the Apache web server from hacking in Windows<\/a>&#39;.<\/p>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>Table of contents 1. Web server on a computer 2. What does a web server consist of 3. Download a web server for Windows 4. Installing a web server in Windows 5. Installing Apache 2.4 in Windows 6. Installing MariaDB on Windows 7. Installing PHP on Windows 8. Installing phpMyAdmin<a href=\"https:\/\/miloserdov.org\/?p=2343\" class=\"read-more\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":2350,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[21,200,163,23,22,24,20,16],"class_list":["post-2343","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-work-environment","tag-apache","tag-localhost","tag-mariadb","tag-mysql","tag-php","tag-phpmyadmin","tag-web-server","tag-windows"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/posts\/2343"}],"collection":[{"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/miloserdov.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2343"}],"version-history":[{"count":9,"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/posts\/2343\/revisions"}],"predecessor-version":[{"id":2679,"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/posts\/2343\/revisions\/2679"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/media\/2350"}],"wp:attachment":[{"href":"https:\/\/miloserdov.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/miloserdov.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/miloserdov.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}