Installing a local server on Windows

Installing a local server on Windows

To deploy a working environment, you will definitely need to install a local?server on Windows?– as a rule, such a bundle includes two elements:

  • GIT (Distributed Version Control System);
  • local server (MySQL, Apache, mongodb, Memcached, nginx, PHP).

In our case, for clarity, we will consistently install PuTTY, GIT, the gentleman's Denwer set (Apache, MySQL, PHP), Nginx, as well as Memcached, and MongoDB. All this is necessary for the full deployment of the local server.

How to install PuTTY

This client will allow us to access the project remotely and securely via?SSH?or Telnet. You just need to go to the?https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.htmlofficial website?of the developer, download the installer and install everything in the standard way. There will be no difficulties. You will have to deal with the setup yourself since this is not the main topic of our article.

Installing GIT

Again, go to the?https://tortoisegit.org/official TortoiseGit website, select the appropriate release version, download, and install. We recommend TortoiseGit, as it is more stable and reliable from the point of view of development.

Denwer

A standard set of any web developer, including an installer, a web server, a MySQL database, PHP, a virtual hosting management system, and a number of other important components.

To install, you need to download the basic Denwer kit, as well as additional PHP5 modules. It is important to emphasize here that you will have to register, and only then you will be able to get a link to download the software to your email.

Memcached

We have already described this object caching system in detail in a?separate article, so we will not linger here for a long time. To install, you will need to download an archive with a file in the binaries format, and then unpack it into the \usr\local\memcached directory.

In order for Memcached to run together with Denwer, you will have to write a small script with startup commands. To do this, in the \denwer\scripts\init directory.d\ create a file with the name memcached.pl , open it in edit mode and write the following lines:

#!perl -w
package Starters::Memcached;
BEGIN { unshift @INC, "../lib"; }
?
use StartManager;
?
my $basedir = '/usr/local/memcached/';
chdir($basedir);
?
StartManager::action
??$ARGV[0],
??start => sub {
????###
????### START.
????###
????????print "Starting memcached\n";
????????system("memcached.exe -d");
????????print "? Started!\n";
??},
??stop => sub {
????###
????### STOP.
????###
????????print "Stopping memcached\n";
????????system("TASKKILL /F /IM memcached.exe");
????????print "? Stopped!\n";
??};
?

return 1 if caller;        

init.d/memcached

We call the file 40_memcached and save it in three different folders:

  • \denwer\scripts\main\start
  • \denwer\scripts\main\stop
  • \denwer\scripts\main\restart

After that, open the text script index.php and add three lines to it:

$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211);
echo ‘Memcache ver: ’ . $memcache->getVersion();        

Configuring the Nginx Web Server

During the installation of a local server on Windows, you can not do without a web server – in our case, this is?Nginx. You just need to go to the official developer's website, download the Windows version and unpack the files to the \usr\local\nginx directory.

The next step is to configure a virtual host for your test site. Open \usr\local\nginx\conf\nginx.conf in edit mode and add the lines:

?	server {
??????????listen 127.0.0.1:80;
??????????server_name www.test.local test.local;
?
??????????if ($host = 'test.local'){
??????????????rewrite ^/(.*)$ https://www.test.local$1 permanent;
??????????}
?
??????????location ~* \.(jpeg|jpg|gif|png|css|js|pdf|txt|tar)$ {
??????????????root Z:\home\/test.local\www;
??????????}
??????????location / {
??????????????ssi on;
?????????????
??????????????proxy_pass https://127.0.0.1:8080/;
??????????????proxy_set_header X-REQUEST_URI $request_uri;
??????????????proxy_set_header X-Real-IP $remote_addr;
??????????????proxy_set_header X-Forwarded-for $remote_addr;
??????????????proxy_set_header Host $host;
??????????????proxy_connect_timeout 60;
??????????????proxy_send_timeout 90;
??????????????proxy_read_timeout 90;
??????????????proxy_redirect off;
??????????????proxy_set_header Connection close;
??????????????proxy_pass_header Content-Type;
??????????????proxy_pass_header Content-Disposition;
??????????????proxy_pass_header Content-Length;
?
??????????????root Z:\home\/test.local\www;
??????????}

??	}        


How to configure Apache

Apache's default operating parameters are often not suitable for work – in particular, it is usually recommended to change the port 80 installed out of the box. Either for security reasons or if another web server is running on this port – for example, the same Nginx. Anyway, go to the?Apache?settings (посилання) and change the template for the virtual host to assign it a different port.

Open the file \usr\local\apache\conf\httpd.conf in edit mode and look for the following lines:

#Listen $&{ip:-127.0.0.1}:$&{port:-6080}
#NameVirtualHost $&{ip:-127.0.0.1}:$&{port:-6080}
#<VirtualHost $&{ip:-127.0.0.1}:$&{port:-6080}>
#? DocumentRootMatch "/home/(?!cgi-)(.*)^1/(?!cgi$|cgi-)(.*)"
#? DocumentRootMatch "/home/(?!cgi-)(.*)/public_html^1"
#? DocumentRootMatch "/home/(?!cgi-)(.*)/public^1"
#? DocumentRootMatch "/home/(?!cgi-)(.*)^1/html/(.*)"
#? DocumentRootMatch "/home/(?!cgi-)(.*)^1/domains/(?!cgi$|cgi-)(.*)"
#? DocumentRootMatch "/var/www/html/(?!cgi-)~(.*)^1/(?!cgi$|cgi-)(.*)"
#? DocumentRoot "$&"?
#? ServerName "%&/-www"
#? ServerAlias "%&/-www" "%&/-www/www" $&{host:-}
#
#? $&{directives:-}
#
#? ScriptAlias /cgi/ "$^1/cgi/"
#? ScriptAlias /cgi-bin/ "$^1/cgi-bin/"
#? AllowEncodedSlashes on

#</VirtualHost>        

How to set up Denwer autorun with Nginx

Go to the directory \denwer\scripts\init.d\, here you need to create a file nginx.pl . Its contents should look like this:

#!perl -w
package Starters::Nginx;
BEGIN { unshift @INC, "../lib"; }
?
use StartManager;
?
my $basedir = '/usr/local/nginx/';
chdir($basedir);
?
StartManager::action
??$ARGV[0],
??start => sub {
	###
	### START.
	###
????	print "Starting Nginx\n";
????????system("start nginx.exe");
????	print "? Started!\n";
??},
??stop => sub {
	###
	### STOP.
	###
????	print "Stopping Nginx\n";
????????system("nginx.exe -s stop");
????	print "? Stopped!\n";
??};
?

return 1 if caller;        

  • \denwer\scripts\main\start
  • \denwer\scripts\main\stop
  • \denwer\scripts\main\restart

To check the scripts, restart Denwer – if CSS is connected, everything is done correctly.

How to configure MongoDB

This document-oriented system is often used on local servers, as it has a clear object structure and advanced query capabilities. In addition, it is convenient to scale the database, which sometimes saves a lot of time. You can download it from?https://www.mongodb.com/the official website of the developers.

Before installing MongoDB, you will need to download the PHP driver – go to github and find the file php_mongo.dll . After downloading, upload it to the \usr\local\php5\ext\ directory. You can connect the extension in the php.ini file by adding the line:

extension=php_mongo.dll        

Next comes the installation of the service:

> cd C:\WebServers\usr\local\mongodb\bin\
> mongod.exe --install --dbpath=C:\WebServers\usr\local\mongodb\db\ --logpath=C:\WebServers\usr\local\mongodb\logs\
#!perl -w
package Starters::mongoDB;
BEGIN { unshift @INC, "../lib"; }
?
use StartManager;
?
StartManager::action
??$ARGV[0],
??start => sub {
	###
	### START.
	###
????????print "Starting mongoDB\n";
????????system("net start mongoDB");
????????print "? Started!\n";
??},
??stop => sub {
	###
	### STOP.
	###
????????print "Stopping mongoDB\n";
????????system("net stop mongoDB");
???	 print "? Stopped!\n";
??};

?
return 1 if caller;        

Now, by analogy with the previous steps, open the text editor, write inside:

init.d/mongod        

  • \denwer\scripts\main\start
  • \denwer\scripts\main\stop
  • \denwer\scripts\main\restart

After that, we recommend visiting the official website of MongoDB developers and choosing an admin panel to your liking – all people have different tastes regarding interfaces, so we will not give any universal recommendations.

Finally, we add that instead of PuTTY, you can use KiTTY, and the Denwer bundle can be replaced with the Open Server software environment – it was also created with an eye on web developers and works fine under Windows. We hope our material helped you figure out how to install a local server on Windows and prepare it for work on the project. Thanks for your attention!

要查看或添加评论,请登录

Vladimir Lebedenko的更多文章

  • Web 2.0 and Web 3.0: why everyone talks about them

    Web 2.0 and Web 3.0: why everyone talks about them

    The Internet needs a revolution. You may have noticed that the current model of the Internet is compromised: there is…

  • What are firewalls?

    What are firewalls?

    A firewall is a network security system that filters all traffic according to preset principles and rules. If you…

  • What CMS is better for VPS Joomla or Drupal?

    What CMS is better for VPS Joomla or Drupal?

    If a user is thinking about creating a website or a blog, they will certainly be confronted with the choice of a…

  • Building an RPM package using Nginx as an example

    Building an RPM package using Nginx as an example

    RPM is a package manager used in Red Hat-based Linux operating systems. RPM data storage is performed using the cpio…

  • Why does the 504 Gateway Time Out error occur and how to fix it?

    Why does the 504 Gateway Time Out error occur and how to fix it?

    When trying to load a web page the server may display a 504 Gateway Time Out error. If you see this code on the screen,…

  • Litespeed web server and caching

    Litespeed web server and caching

    Web browsers and how they work is the reason why caching has become a part of our everyday life. If you can't access a…

  • How passwords are stolen from the browser during XSS attacks

    How passwords are stolen from the browser during XSS attacks

    Security headers are one of the most important links in the chain of tools and mechanisms that protect a website from…

    1 条评论
  • Absolute Globalization: How Submarine Internet Cables Unite the Planet

    Absolute Globalization: How Submarine Internet Cables Unite the Planet

    Although the global Starlink satellite system, which provides users with high-speed Internet, is making all the…

  • How to choose a server location and what it affects

    How to choose a server location and what it affects

    Hosting providers offering VPS/VDS and dedicated server rental services always provide an opportunity to choose the…

  • Thank you page, how you should do it?

    Thank you page, how you should do it?

    Experienced developers of websites and Landing Pages necessarily create a thank you, because it greatly increases the…

社区洞察

其他会员也浏览了