📜 ⬆️ ⬇️

My experience setting up apache x64 under windows 8.1 x64

image

Good day, dear readers. In this article I want to share with you a personal experience of setting up Apache under Windows 8.1 x64.
There was a time - I installed Windows 8.1 for myself and I think, since I’ve got it, “give me a kick” I’ll take Apache up! And as usual, he was very pleased with me (nameplate: "Sarcasm"). I had to tinker almost the whole night to raise the server. And I managed it! After that, I decided to write a small article on how to configure Apache so that the other person would not spend as much time on it as I did.
After a few minutes of deliberation, I decided to write a step-by-step instruction, which will consist of several sections:
  1. Folder preparation
  2. Apache setup
  3. PHP setup
  4. MySQL setup
  5. Install phpMyAdmin

Well, let's get started.

Folder preparation


I really do not like to have everything lying around, anywhere, so first we will create folders where we will have programs and websites.
Create a “C: \” drive on the disk (or where you prefer) the “Server” folder:
C:\Server\
In it we will create 2 folders:
C:\Server\web is the folder in which we will have programs
C:\Server\domains - and in this folder will be our sites
So, in the \ web \ folder we create 3 folders for apache, php, mysql:
C:\Server\web\apache\
C:\Server\web\php\
C:\Server\web\mysql\
Next, go to the domains folder and create a folder \ localhost \
C:\Server\domains\localhost\
Inside the folder we will have 2 subfolders: public_html - for the site files; logs - for text files in which “who” is logged accessed the site and what errors have occurred in the work of the site.
C:\Server\domains\localhost\public_html\
C:\Server\domains\localhost\logs\
This completes the folder structure, proceed to the Apache configuration.

Apache setup


To install Apache, we need Apache itself (Cap). Since we have Windows 8.1 x64, we will install Apache x64.
For download, click on the link:
www.apachelounge.com/download/win64
and download "httpd-2.4.6-win64.zip". We also need the “Microsoft Visual C ++ 2010 (x64) Redistributable Package” for normal operation. To do this, download it from this link:
www.microsoft.com/ru-ru/download/details.aspx?id=14632
and install.
After downloading our archive with Apache, open it. Having opened the archive, we will see the “Apache24” folder, go into it. A lot of folders and files of the program appear, everything is unpacked into the previously prepared folder:
C:\Server\web\apache\
It should turn out like this:
C:\Server\web\apache\bin\
C:\Server\web\apache\cgi-bin\
C:\Server\web\apache\conf\
C:\Server\web\apache\error\
C:\Server\web\apache\htdocs\
C:\Server\web\apache\icons\
C:\Server\web\apache\include\
C:\Server\web\apache\lib\
C:\Server\web\apache\logs\
C:\Server\web\apache\manual\
C:\Server\web\apache\modules\
Folders such as \ cgi-bin \, \ htdocs \, \ icons \ and \ manual \ we don’t need - you can delete them.
Go to the folder:
C:\Server\web\apache\conf\
And open the Apache configuration file - “httpd.conf” with any text editor. In this file, each line contains directives for configuring Apache, and lines beginning with a # (pound sign) - a comment and an explanation. Let's start the setup:
Apache configuration file
# Apache
ServerRoot “C:/Server/web/apache”
# IP (80 )
Listen 127.0.0.1:80
# Apache
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module "C:/Server/web/php/php5apache2_4.dll"
# Apache, php, php-
AddHandler application/x-httpd-php .php
# php
PHPIniDir “C:/Server/web/php”
#
ServerName 127.0.0.1:80
#
<Directory />
Options Includes Indexes FollowSymLinks
AllowOverride All
Allow from all

#
DocumentRoot “C:/Server/domains”
# , .
<IfModule dir_module>
DirectoryIndex index.php index.html index.htm index.shtml

# log-
ErrorLog “C:/Server/domains/logs/error.log”
CustomLog “C:/Server/domains/logs/access.log”
# alias phpMyAdmin, alias cgi
<IfModule alias_module>
Alias /pma “C:/Server/domains/phpMyAdmin”
ScriptAlias /cgi-bin/ “C:/Server/web/apache/cgi-bin/”

# cgi
<Directory “C:/Server/web/apache/cgi-bin”>
AllowOverride None
Options None
Require all granted

#
<IfModule mime_module>
…
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

# :
Include conf/extra/httpd-mpm.conf
Include conf/extra/httpd-autoindex.conf
Include conf/extra/httpd-vhosts.conf
Include conf/extra/httpd-manual.conf
Include conf/extra/httpd-default.conf
<IfModule setenvif_module>
BrowserMatch "MSIE 10.0;" bad_DNT

<IfModule headers_module>
RequestHeader unset DNT env=bad_DNT


This completes the httpd.conf configuration.
In the Apache httpd.conf configuration file, additional configs were included:
Include conf/extra/httpd-mpm.conf
Include conf/extra/httpd-autoindex.conf
Include conf/extra/httpd-vhosts.conf
Include conf/extra/httpd-manual.conf
Include conf/extra/httpd-default.conf
Open the file “C: \ Server \ web \ apache \ conf \ extra \ httpd-mpm.conf” and quickly go over it.
# , pid-:
<IfModule !mpm_netware_module>
PidFile “C:/Server/web/apache/logs/httpd.pid”

The remaining parameters are left unchanged. Open the file "httpd-autoindex.conf", change only the lines with the path there:
Alias /icons/ "c:/Server/web/apache/icons/"
<Directory "C:/Server/web/apache/icons">
Options Indexes MultiViews
AllowOverride None
Require all granted

Next, go to the file "httpd-vhosts.conf", delete its contents. After we have done this, we begin to replenish it:
Apache Hosts File
# localhost
<VirtualHost localhost:80>
DocumentRoot "C:/Server/domains/localhost/public_html"
ServerName localhost
ErrorLog "C:/Server/domains/localhost/logs/error.log"
CustomLog "C:/Server/domains/localhost/logs/access.log" common

# phpMyAdmin ( )
<VirtualHost phpmyadmin:80>
DocumentRoot "C:/Server/domains/phpmyadmin/public_html"
ServerName localhost
ErrorLog "C:/Server/domains/phpmyadmin/logs/error.log"
CustomLog "C:/Server/domains/phpmyadmin/logs/access.log" common

')
This is where the file editing ends. Further, in the remaining files, we rule only the paths:
File "httpd-manual.conf":
AliasMatch ^/manual(?:/(?:da|de|en|es|fr|ja|ko|pt-br|ru|tr|zh-cn))?(/.*)?$ "C:/Server/web/apache/manual$1"
<Directory "C:/Server/web/apache/manual">
No changes are made to the "httpd-default.conf" file. This completes the Apache configuration setting.

PHP setup


Since we have Windows 8.1 x64 and Apache x64 installed and configured, then php should be x64.
Go to the site:
www.anindya.com/tag/php
and download the php archive of the latest version. We need php as a module, i.e. for this download Thread Safe. After the archive has been downloaded, open it and transfer the contents to the “C: \ Server \ web \ php \” folder. Create two empty folders “tmp” and “upload”. Further in this folder we look for the file “php.ini-development” and rename it to “php.ini”. Open the file in a text editor and change directives (commenting lines in the file starts with a semicolon).
Configure php.ini
short_open_tag = On
zlib.output_compression = On
post_max_size = 64M
include_path = ".;:\Server\web\php\includes"
extension_dir = "C:/Server/web/php/ext"
upload_tmp_dir = "C:/Server/web/php/upload"
upload_max_filesize = 64M
extension=php_bz2.dll
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
extension=php_sockets.dll
extension=php_sqlite3.dll
; [Date] (http://php.net/date.timezone)
date.timezone = "Asia/Yekaterinburg"
session.save_path = ":/Server/web/php/tmp/"

At this setting php ends.

MySQL setup


We put MySQL x64 as a socket for windows. Download the archive with the latest version of MySQL x64:
dev.mysql.com/downloads/mysql
In the bottom of the page we find Windows (x86, 64-bit), ZIP Archive and click on the “Download” button. You will be transferred to the registration page on the site. Click at the bottom of the page "No thanks, just start my download" to start downloading the MySQL archive. After the archive has been downloaded, open it and transfer the entire contents of the folder to “C: \ Server \ web \ mysql \”
Now open the MySQL configuration file - “C: \ Server \ web \ mysql \ my-default.ini”. We delete all its contents and enter our data there.
[client]
port=3306
host=127.0.0.1
[mysqld]
port=3306
bind-address=127.0.0.1
enable-named-pipe
basedir="C:/Server/web/mysql/"
datadir="C:/Server/web/mysql/data/"
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
That's all. In the configuration file, we indicated that the scripts can access the server via both local IP and socket connections.
It remains the case for small. Add the paths to Apache and MySQL to the “PATH” system variable, for this:
  1. Drag the mouse to the bottom right corner of the screen.
  2. Click the Search icon and enter: control panel
  3. Select System -> Advanced.
  4. Select Environment Variables, in the System Variables menu, find the PATH variable and click on it.
  5. Register paths to Apache and MySQL:

;C:\Server\web\apache\bin;C:\Server\web\mysql\bin
Next, install the Apache and MySQL services. To do this, use the key combination "Win + X", a drop-down menu appears in the lower left corner. Choose "Command line (administrator)".
At the command prompt, enter to install Apache:
httpd –k install
to install MySQL:
mysqld.exe --install MySQL --defaults-file=”C:\Server\web\mysql\my-default.ini”
Set a password for the MySQL user. To do this, start the MySQL service with the command:
NET start MySQL
After the service has started, set the password:
mysqladmin –u root password
In the file "httpd-vhosts.conf" we have registered two sites, in order for the browser to see them, the site names must be added to the file "hosts". Go to the folder:
C:\Windows\System32\Drivers\etc\
open the “hosts” file with any text editor (run as administrator) and add to the end of the file:
127.0.0.1 localhost
127.0.0.1 phpmyadmin
Save the file.
For the convenience of starting and stopping the Apache and MySQL services, we will create the start-server.bat and stop-server.bat files.
To do this, go to the folder "C: \ Server \" and create these two files.
Contents of "start-server.bat":
@echo off
NET start Apache2.4
NET start MySQL
Contents of "stop-server.bat":
@echo off
NET stop Apache2.4
NET stop MySQL
Apache, PHP and MySQL setup is now complete. In order to test the server, let's create a file “index.php” with the contents in the folder “C: \ Server \ domains \ localhost \ public_html”:

 <?php echo phpinfo(); 

Next, run our server, for this run "start-server.bat" as administrator. After the server has started, open a browser and enter “localhost” in the address bar.
A page with information about PHP should appear.

Install PhpMyAdmin


Download the latest version of PhpMyAdmin from here:
www.phpmyadmin.net/home_page/index.php
Open the downloaded archive and transfer the contents of its folder to the folder for our domain "C: \ Server \ domains \ phpmyadmin \ public_html \".
Find the file “config.sample.inc.php”, make a copy of it and rename the copy in “config.inc.php”. Open the file with a text editor and change the data:

 <?php //     $cfg['blowfish_secret'] = 'a8b7c6d'; $i = 0; $i++; $cfg['Servers'][$i]['auth_type'] = 'cookie'; $cfg['Servers'][$i]['host'] = 'localhost'; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = false; $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['AllowNoPassword'] = false; $cfg['UploadDir'] = ''; $cfg['SaveDir'] = ''; ?> 

Save and close the file. Open in the browser the site "http: // phpmyadmin" and enjoy.

The article turned out to be voluminous, but I hope useful.

Source: https://habr.com/ru/post/203012/


All Articles