Posts

Install and configure OpenServer

Well, itchy hands to install a web server and write the first program in PHP? First of all, go to the official OpenServer website and download the program. I recommend to download the BASIC package, for our needs it will be enough. However, you can see a list of programs that are included in other packages. Perhaps you will find something useful, be it some kind of code editor or GUI client for MySQL DBMS.

So let’s get started. The first step is to download the program itself.

Link to official website: ospanel.io

Installation

We launch the installer and set the directory for installing the program. Installation is a simple unpacking.

After installation is complete, the window will silently close.

Setup

Go to the folder with the unpacked software: C:\OpenServer. Here we see the files to run the OpenServer program for different versions of the system and 3 folders:

  • domains – a folder designed to store your sites. Inside it, we will create our projects, for example: myproject.loc;
  • modules – a folder containing executable files of modules and libraries necessary for their work, additional files;
  • userdata – the folder where the DBMS user data, cache files, logs, and module configuration files are located.

Run one of the exe files in the root, depending on the bit depth of your OS. In my case, this is Open Server x64.exe.

We choose the language and agree with the installation of the necessary libraries:

Reboot the computer. After rebooting, run exe again. An icon with a red flag appears in the tray.

Click on this icon with the right mouse button and select the “Settings” item. The main program window will open. Go to the “Modules” tab and select:

  • PHP version: PHP 7.0
  • Apache version: Apache-PHP-7

Then, go to the “Domains” tab, select “auto search for domains” and select the item with the greatest number of options as the root folder of the domain. You can also add your options here.

Then click “Save” and close the settings window.

Enabling OPCache Accelerator

Remember in the previous lesson we talked about the accelerator? Let’s turn it on. You need to do this in the php.ini file. In order to edit it, right-click on the flag and select the item:

Advanced -> Configuration -> PHP-7

Here you need to remove comments for the lines:

zend_extension="%sprogdir%/modules/php/%phpdriver%/ext/php_opcache.dll"
opcache.enable=1

It should be like this:

Save the file. This completes the configuration.

Hello World

Go to the “domains” folder and create a directory for our project. Let’s call it “myproject.loc”. Inside, create the “www” directory. And inside it is the PHP file “index.php”. Open it and enter the following code:

<?php
echo 'Hello world!';

Now you can start the server and check the script.

If an error occurs when starting the server:

The file C:\Windows\system32\drivers\etc\hosts is not writable

you should close the program and run it as administrator.

The checkbox in the tray should turn green.

Open the browser and go to the address: http://myproject.loc/

Congratulations! Your first (or not?) Program just worked out successfully! We saw the result. And if we now open the page source in the browser, we will see nothing there. The web server gave us the finished result. The user will never see your PHP code. So simple. In the next lesson, we will install and configure the coolest IDE for a PHP developer – PHPStorm. We will also learn how to use it for free.

/ April, 12 at 10:57

I create web projects, develop, optimize and promote websites. If you have any ideas or want to suggest something, then write to me and my team.

Top ↑

One comment on “Install and configure OpenServer

  • Hola! I’ve been reading your weblog for a while
    now and finally got the bravery to go ahead and give
    you a shout out from Atascocita Texas! Just wanted to say keep up the good job!

Leave a Reply