Installing php 7. How to install local apache server with php, mysql, phpMyAdmin on windows machine

The Apache project does not provide binary versions software, but only the source code. However, they can be obtained from third party sites:

  • ApacheHaus ;
  • Apache Lounge.

Download Apache Windows 32-bit ( httpd-2.4.20-win32-VC14.zip) or the 64-bit version ( httpd-2.4.20-win64-VC14.zip). Check if you have installed 64-bit OS. You can use msinfo32.exe to determine this. This tool helps in gathering information about the computer, in diagnosing problems, or it can be used to access other tools.

To run it run the command Run > msinfo32 > press Enter.

After you find desired version, download the Zip archive, and then extract its contents to the C:Apache24 folder.

Before starting the Apache server, if you want to change the listening port to 8181 :

  • Open in text editor file C:Apache24confhttpd.conf ;
  • Find the following line: Listen 80 ;
  • And change it to: Listen 8181 .

Save your changes.

Now you can start the Apache Windows 7 server:

Open a command prompt as an administrator and navigate to the bin subdirectory:

Type httpd.exe and press Enter .

If a dialog box appears on the screen with a message that the MSVCR140.dll file is missing, you need to install Visual C++ Redistributable for visual studio 2015 (select vc_redist.x64.exe if you have it installed 64-bit Windows).

Now open a browser and enter http://localhost:8181 into the address bar to launch the demo site.

Installing PHP 7 on Windows

PHP 7 is a major update to the server-side web development language PHP. Download the VC14 x64 Thread Safe (2016-Apr-29 00:38:19) zip archive. If you have downloaded 32-bit version of Apache, PHP x86 must be installed.

Create a folder named " php7”, extract the contents of the php-7.0.6-Win32-VC14-x64.zip archive into it, and then place the folder in the root of drive C:

Configuring Apache to use PHP

Open the setup configuration file Windows Apache C:Apache24confhttpd.conf.

Copy the following lines to the top of the file:

  • AddHandler application/x-httpd-php.php;
  • AddType application/x-httpd-php .php .html;
  • LoadModule php7_module "c:/php7/php7apache2_4.dll";
  • PHPIniDir "c:/php7" .

In chapter add the line index.php and place it before index.html :

DirectoryIndex index.php index.html

Save the file Apache PHP windows. Now rename the file C:php7php.ini-development to C:php7php.ini.

Enabling mod_rewrite to rewrite URLs

Open the configuration file Apache C:Apache24confhttpd.conf;
Find the line in it #LoadModule rewrite_module modules/mod_rewrite.so and remove the hash symbol "#";
Find all occurrences of the string " AllowOverride None" and change them to " AllowOverride All".

Setting up PHP with MySQL

Edit the php.ini file and uncomment the extensions directory. Remove the character "; » at the beginning of the lines:

; Directory in which the loadable extensions (modules) reside. ; http://php.net/extension-dir ; extension_dir = "./" ; On windows: extension_dir="ext"

Activate the following lines, this will enable the MySQL modules to run:

extension=php_mysqli.dll extension=php_pdo_mysql.dll

As well as the lines below if you are using the Apache PHP MySQL Window s installation in a development environment:

extension=php_curl.dll extension=php_fileinfo.dll extension=php_gd2.dll extension=php_mbstring.dll extension=php_openssl.dll

Uncomment error_log to enable file logging:

; Log errors to specified file. PHP"s default behavior is to leave this value ; empty. ; http://php.net/error-log ; Example: error_log = c:php7php_errors.log

Save your changes.

IMPORTANT! Set Windows PATH to find PHP

  • Right click on the label My Computer - Properties - Advanced - Environment Variables;
  • In chapter " System variables"Find the item" Path", Click on it and select" Change";
  • Add the path to the php folder at the end ( required after the semicolon ";"). For example: ";C:php7 ";
  • Click OK.

How to check if PHP is installed

Create a file at C:Apache24htdocsphpinfo.php and add the following code to it:

Restart Apache Windows and then in your browser navigate to http://localhost:8181/phpinfo.php. This page should display information about installed version PHP.

In the past, there was a large manual on how to install a LEMP stack on a server from scratch. Unfortunately, this material has sunk into oblivion during the transfer of articles, and I have no desire to write it again.

UPD: New language version, - PHP 7.3, - .

The release of the stable version 7.2 took place at the end of November. There are quite a few changes, but now they are not about them. Below is a simple way I have updated my existing one PHP 7.1 FPM to PHP 7.2 FPM.

1. Add a repository.

sudo add-apt-repository ppa:ondrej/php sudo apt update

2. Install packages.

sudo apt install php7.2 php7.2-common php7.2-cli php7.2-fpm php7.2-gd php7.2-mysql php7.2-curl php7.2-simplexml php7.2-zip

dpkg -l | grep php | tee packages.txt

Current packages will be saved to packages.txt. After installation new version PHP open the file and compare the list of installed packages.

3. PHP setup.

We open /etc/php/7.2/fpm/pool.d/www.conf, change the parameter value listen:

Listen = 127.0.0.1:9000

4. NGINX configuration

If you already have the FPM package installed, there is no need to make any changes. Otherwise, in the site config, add\change:

Location ~ \.php$ ( try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_index index.php; include fastcgi_params; )

5. Remove old PHP files.

If everything went well and php -v claims that you are using the required version of PHP, as unnecessary, delete the old files with the command:

Sudo apt purge php7.1*

5. Well, everything.

Do not forget to restart the services after all the changes.

service nginx restart service php7.2-fpm restart

That's all. Enjoy the new PHP 7.2 :)

In this article, we will show you how to install PHP 7.2 on Ubuntu 16.04. PHP (Hypertext Preprocessor) is a server-side scripting language with an open source code, designed primarily for creating dynamic interactive websites. PHP is one of the most popular languages ​​and is freely available for redistribution and modification. PHP can be run on almost any web server (like Apache) and on every OS platform (Linux, Mac OS, Windows). PHP 7.2 was officially released last year. AT latest version PHP 7.2 has new and improved features and functions that will enable developers to write better code.

Requirements:

  • For the purposes of this guide, we will be using an Ubuntu VPS. Ours already comes pre-installed with a working LAMP stack. However, we will still go through all the necessary steps and show you how to install and configure the LAMP stack yourself if you are doing it on a bare server.
  • Also needed full access to an SSH root or .

Step 1. Connect to your server via SSH and update server packages.

Before we start, let's be root user and update your Ubuntu OS packages to the latest version available.

To connect to your server via SSH as root, use the following command:

ssh [email protected] _ADDRESS -p PORT_NUMBER

Replace "IP_ADDRESS" and "PORT_NUMBER" with your actual server IP address and SSH port number.

Once installed, make sure your server OS packages are up to date by running the following commands:

apt-get update apt-get upgrade

If this is your first time logging into your new Ubuntu VPS, you can also check out our article on for some additional basic settings and security.

Step 2. Installing the web server

In this section, we will show you how to install a web server on your VPS. We can install Apache or nginx as a web server. For the purposes of this tutorial, we will install the Apache web server. Apache is a fast and secure web server and one of the most popular and widely used web servers in the world.

To install the Apache web server, run the following command on your server:

apt-get install apache2

Once the installation is complete, you must start Apache:

systemctl start apache2

Also, you can enable Apache for auto start on server boot:

systemctl enable apache2

To check the status of the Apache web server and make sure it is up and running, you can use the following command:

systemctl status apache2

To make sure Apache is running, you can also open your web browser and enter your server's IP address (for example, http://your_server_ip_address). If Apache is successfully installed, you should see Apache's default welcome page.

Step 3: Install PPD Ondřej Surý

PHP 7.2 can be installed using the Ondřej Surý PPA, so install software-properties-common and python-software-properties:

sudo apt-get install software-properties-common python-software-properties

Then add the ondrej PPA and update your sources:

sudo add-apt-repository -y ppa:ondrej/php sudo apt-get update

Step 4Installing PHP 7.2

Install PHP 7.2 using the following command:

Sudo apt-get install php7.2 php7.2-cli php7.2-common

Step 5: Finding and Installing Specific PHP 7.2 Extensions

If you want to install a specific PHP 7.2 extension, you can search if it's available using the following command:

Sudo apt search php7.2

Step 7. Installing the most commonly used PHP extensions.

To install the most commonly used PHP extensions, you can use the following command:

sudo apt-get install php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-intl php7.2-mysql php7.2-xml php7.2-zip

Step 8: Check Your PHP Installation

Use the following command to check the version of PHP installed on your server:

You should get the following result:

PHP 7.2.9-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Aug 19 2018 07:16:12) (NTS) Copyright (c) 1997-2018 The PHP Group Zend Engine v3. 2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.9-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

Now PHP 7.2 has been installed on your Ubuntu server and if we want to change the default PHP version to PHP 7.2 which is used by the web server we need to disable old version PHP 7.0 and enable newly installed.

disable php 7.0

a2dismod php7.0

Enable php 7.2

a2enmod php7.2

Restart the Apache web server for the changes to take effect:

systemctl restart apache2

To test your installation and verify that the Apache, PHP, and PHP extensions are working correctly, create a new php info file:

/var/www/html/phpinfo.php

Add the following content to it:

Open the "phpinfo.php" file using a web browser:

http:// /phpinfo.php or http:// /phpinfo.php

and see the current PHP information on your server.

That's all. You have successfully installed PHP 7.2 on Ubuntu 16.04 server. For getting additional information For PHP 7, refer to the official PHP documentation: http://php.net/docs.php.

Specify your version operating system(I specified 64-bit Windows), and go to the download page (Go to Download Page https://dev.mysql.com/downloads/windows/installer/5.7.html).

I chose to download the full msi installer. At the time of this writing, there was current version MySQL 5.7.21 and downloaded a distribution called mysql-installer-community-5.7.21.0.msi.

Apache 2.4

At the time of preparation of the article, x64 version 2.4.33 was available, built on the basis of vc14:
httpd-2.4.29-o110g-x64-vc14.zip.
The size of the archive is about 10 MB.

PHP 7.2

At the time of writing this article, the x64 version of PHP 7.2 (7.2.2), Thread Safe built on VC15 was available: php-7.2.2-Win32-VC15-x64.zip.
The size Zip archive: 24 MB.
Now there are newer ones.

phpMyAdmin (PMA)

For database management MySQL data on the local computer, install the free phpMyAdmin package.

We will download its distribution kit from the site http://www.phpmyadmin.net/
At the time of writing, version 4.7.7 was available:
phpMyAdmin-4.7.7-all-languages.zip
Size - about 11 MB.

We put the contents of the archive in a pre-prepared folder, for example:
D:\sites\localhost\www

Installation List

Distribution downloaded. Install in this order:

Installing MySQL

Run the previously downloaded MySQL installer (mysql-installer-....msi).

In the License Agreement window, check the box:
I accept the license terms
- and click the Next button.

In the Choosing a Setup Type window, select the Custom item (to choose the parameters for installing the MySQL server yourself). Click the Next button.

In the Select Products and Features window, be sure to select the MySQL Server - X64 component. The rest of the components are optional. Having selected a component in the left part of the window, press the right arrow so that this component from those available for installation goes to the right part of the window - a list of what we will install.

Click Next after selecting components.

In the Installation window, click the Execute button to start the installation for execution.

You can monitor the progress of the installation by clicking the Show Details button.

When the installation is completed (Status becomes complete), click the Next button to proceed to configuring the MySQL server.

In the Product Configuration window, click the Next button.

In the Type and Networking window

leave the item Standalone MySQL Server enabled, click Next.

In the next window Type and Networking
set item Config Type = Development Machine

Leave the checkboxes next to TCP/IP and Open Firewall port for network access.
The MySQL communication port is also left with the default value (Port Number = 3306).

Check the box next to Show Advanced Options.

In the Accounts and Roles window, set the password for the main user (with the login root - administrator).

In the MySQL User Accounts field, you can add other users who will have access to MySQL databases. We will not create others yet: we will connect as root.

AT Windows window Service, check the Configure MySQL Server as a Windows Service item (so that the MySQL server starts as a system service).

Leave the system service name (MySQL57) as default.

We will start the MySQL server service manually (we only need it during the development and testing of local sites), so uncheck the Start the MySQL Server at System Startup item (so that the server does not start every time you start OC Windows).

We will start the service on behalf of the Standard System Account (we do not change this option).

In the Plugins and Extensions window, leave everything as it is. Click Next.

In the Advanced Options window, you can change the parameters of the logs (logs) where the server writes messages in the course of its work. Here you can leave everything as it is.

In the Apply Configuration window, click the Execute button to apply the server configuration.

When finished, click the Finish button.

In the Product Configuration window, click Next.

In the last window of the Installation Complete, checkboxes for items can be left unchecked. Click Finish.

The installation and configuration of the MySQL server is now complete.

You can start/stop the MySQL server manually by going to the list of Windows services.
Find MySQL57 in the list, right click on it and select "Start/Stop".

Installing Apache 2.4 for Windows

There are many articles on the internet that describe how to install Apache 2.4 for Windows. I may repeat something, but I will state my version step by step.

The archive downloaded from the developer's site (using the httpd-2.4.29-o110g-x64-vc14.zip option) contains the Apache24 folder. We place it, along with its contents, on drive C:

In addition to the package itself (the Apache24 folder), the archive contains the readme_first.html file, which is useful to read.

Particular attention should be paid to the presence of the Visual C++ 2015 x64 Redistributable Package in the installed Windows OS.
This package contains a set of libraries without which this build of Apache will not work.
You can download this package for free from the Microsoft website at the link (https://www.microsoft.com/en-us/download/details.aspx?id=49984) given in the readme_first.html file. Be sure to install it if it is not already in your OS.

If you have programs installed on your computer that listen on port 80, then it is better to discourage them from using this port, or assign them another one. The Apache server is configured on this port by default, see the Listen parameter in the C:\Apache24\conf\httpd.conf file

We are trying to start the server (later we will consider the option of starting the server as a system service (service)).
To do this, run the command line in the mode (on behalf of) the administrator.
Go to the C:\Apache24\bin folder and run the httpd.exe program

At the first start, a System Alert may appear Windows Security that windows firewall has blocked some functions of this application (see picture)

Check the box to enable Apache HTTP Server communication for Private networks.
Work in public networks can be prohibited.

Opening any browser, enter in the address bar the address http://localhost/
- the builder page for this Apache server package should appear.

(it is installed with the package in the C:\Apache24\htdocs folder - this is the value of the DocumentRoot variable in the httpd.conf file,
but we will change it later).

So the Apache server starts up and works fine.

If the server does not start, then you need to see what errors it gives. Errors can be seen on startup: command line and in file C:\Apache24\logs\error.log

Let's make it so that the Apache server is started by the service (described in the readme_first.html attached to the distribution).
On a command prompt run as administrator, navigate to the C:\Apache24\bin folder and run the command
httpd -k install

It is convenient to monitor the status of the Apache server service and restart it (we will do it often during configuration) through the C:\Apache24\bin\ApacheMonitor.exe program. Make a shortcut for it and place it in a convenient place to launch it (on the taskbar or on the desktop).

It remains to configure the Apache server for our needs:
focus on the folders in which our sites will be located;
Prepare to work with MySQL and PHP.

Let's say we want to have 2 sites on the local computer with the names localhost and wp-test
http://localhost/
http://wp-test/

For this in system file C:\Windows\System32\drivers\etc\hosts should be lines like this

127.0.0.1 localhost
127.0.0.2 wp-test

The first line usually already exists by default.
We fill the second one ourselves.

These lines tell you to look for hosts named localhost and wp-test at IP addresses 127.0.0.1 and 127.0.0.2
- both addresses correspond to the local computer.

Restarting the OS is optional.

Let's create folders on the local computer to store site files, for example, in the folder:
D:\sites\localhost
D:\sites\wp-test

In each of these folders we will create 2 files with the names
access log
error log
and subfolder www
D:\sites\localhost\www
D:\sites\wp-test\www
- in these folders we will create index.html files with the following content:
this is localhost
this is wp-test

Now let's configure the Apache server to use the virtual hosts corresponding to our sites.

edit configuration file server (C:\Apache24\conf\httpd.conf).
To do this, you need to open it in a text editor.
I use NotePad++ (a very feature rich free editor) for this.

I usually add virtual hosts to the end of this file.

Let's add the following lines there:

#localhost ServerName localhost DocumentRoot "D:/sites/localhost/www" ErrorLog "D:/sites/localhost/error.log" CustomLog "D:/sites/localhost/access.log" common #wp test ServerName wp-test DocumentRoot "D:/sites/wp-test/www" ErrorLog "D:/sites/wp-test/error.log" CustomLog "D:/sites/wp-test/access.log" common AllowOverride All Options Includes FollowSymLinks Require all granted

Checking if browsers open pages at addresses
http://localhost/
http://wp-test/

When opened normally, the page should display the following lines:
this is localhost
and
this is wp-test

Similarly, you can create other virtual web servers on the local computer.

Additional settings for Apache that may come in handy.

Installing PHP 7

The content of the downloaded archive php-7.2.2-Win32-VC15-x64 is placed in the folder C:\php\

Carefully read the C:\php\install.txt file from the distribution.
This file briefly describes how to install PHP on the system and configure it to work with Apache.

The path C:\php is added to the PATH system variable

For testing PHP on our local site http://localhost/
create a php_test.php file in its folder (D:\sites\localhost\www) with the following content:

Then, when opening the address http://localhost/php_test.php, a page with data from the phpinfo command should open.

Prepare Apache for PHP

In httpd.conf file

In the place where the modules are loaded (look for the LoadModule group of commands), at the end of the group (if there is no such line yet), add:

LoadModule php7_module "C:/php/php7apache2_4.dll"

Specify the path where php is installed with the directive:

PHPIniDir "C:/php"

In section add index.php:

DirectoryIndex index.html index.php

In section where commands like AddType application...

add a line

AddType application/x-httpd-php .php

Save httpd.conf and restart Apache.

After that, the test page http://localhost/php_test.php will open.

Let's edit the PHP settings file for phpMyAdmin and more.

Rename the php.ini-production file to php.ini (leave it in the same folder C:\php\)

Edit php.ini like this

Uncomment the line

Extension_dir = "ext"

Enable the parameter (default=Off)

Enable_dl = On

Specify a folder to download temporary files

Upload_tmp_dir="d:/sites/uploadtemp" upload_max_filesize = 500M

In chapter; Dynamic Extensions ;

uncomment the lines:

extension=gd2 extension=mbstring extension=mysqli

Let's enable another extension:

Extension=openssl

For example, to update wordpress plugins on the local site through the admin panel. Otherwise, an error occurs: No working transports found.

To execute long scripts, we will extend the maximum execution time, for example, like this:

Max_execution_time = 300

Installing phpMyAdmin

After downloading the distribution and placing its contents in the folder D:\sites\localhost\www
go to the documentation folder \www\doc\html and open the setup.html file

Following his instructions, let's create a config subfolder in the root directory of the site (www) (this is needed while configuring phpMyAdmin with a script that can be run by opening the setup page at http://localhost/setup/).
Rename the file located in the root directory \www\config.sample.inc.php
to the working file \www\config.inc.php
- open this file for editing and define the $cfg["blowfish_secret"] parameter in it - fill it with any characters, for example, the phrase ANY_WHAT_YOU_WANT:

$cfg["blowfish_secret"] = "ANY_WHAT_YOU_WANT"; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

and, having saved, we will close this file.

Let's check if the pages of the site open:
http://localhost/
http://localhost/index.php

And so we set nginx server now it's time to install php 7.1 on ubuntu. The nginx + php7 bundle has proven itself very well, saving money and server resources.

Installing php 7.1

First, let's add a repository from which we will download and install php 7.1.

sudo add-apt-repository ppa:ondrej/php

Note: If the system encoding is different from utf-8, then there may be problems when adding the php 7.1 repository. So let's run these two commands

sudo apt install -y language-pack-en-base sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php

Update the list of repositories

Sudo apt update

If everything is fine, proceed with the installation ..

Apt install php7.1 php7.1-fpm php7.1-opcache php7.1-zip php7.1-xmlrpc php7.1-xsl php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-odbc php7.1-pgsql php7.1-pspell php7.1-readline php7.1-recode php7.1-snmp php7.1-soap php7.1-sqlite3 php7.1-sybase php7.1-tidy php7.1-xml php7.1-json php7.1-ldap php7.1-intl php7.1-interbase php7.1-imap php7.1-gmp php7.1-gd php7.1-enchant php7.1-dba php7.1-bz2 php7.1-bcmath php7.1-phpdbg php7.1-cgi php7.1-cli

We agree with the installation, we wait until everything is completed.

And so everything is ready - php 7.1, and the extensions are installed. If other versions of php5 were installed on the system, then you can remove them by running the command:

Apt autoremove php5* -y && apt purge php5* -y && apt clean php5*

php 7.1 setup

php setup will be as follows:

  • Fixing vulnerabilities
  • Increasing the file upload size
  • Increasing the script running time
  • opcache setup

Open php.ini

Sudo nano /etc/php/7.1/fpm/php.ini

looking for a line

;cgi.fix_pathinfo = 1

uncomment the line and put 0 instead of one

cgi.fix_pathinfo = 0

Increase the size of uploaded files. We find post_max_size and bring it to the form

Post_max_size = 100M

Let's increase the script processing time, look for max_execution_time by setting 300 seconds - usually needed to work with large mysql tables

opcache.enable=1 opcache.enable_cli=1 opcache.memory_consumption=64 opcache.interned_strings_buffer=4 opcache.max_accelerated_files=7963 opcache.revalidate_freq=20

We save the file. Restart php7.1-fpm

Service php7.1-fpm restart

Install MySQL server and phpmyadmin

sudo apt install mysql-server-5.7

During installation, we will be asked to set a password for the mysql server administrator. Complete the request.
All is ready. Now install the database manager

sudo apt install phpmyadmin

During installation, it will most likely ask you to select a web server, select any, if it asks you to set a password for the database, set it.
Now we will make a symbolic link to the directory where we will have the site

Ln -s /usr/share/phpmyadmin /var/www/html/my.site.ru

You can access the database manager at

My.site.ru/phpmyadmin/

In the future, you can create your own nginx configuration file for the phpmyaadmin database manager, and transfer it to a subdomain like mysql.my.site.ru, and set server authorization.

If you have any questions write in the comments.

Internet