1b. Install Apache, PHP, localhost SSL (https) On Windows 10, all newest 64 bit

HOME
Download config and php test files:  0_Apache24_conf_extra_PHP_ini.zip

Everything works. If I forgot something see URL-s in this article wich served me as tutorials. ZWAMP or simmilar and virtual hosts are not used for this basic example – Apache and PHP are extracted in C: .

Output of C:\Apache24\htdocs\index.php
(see 0_Apache24_conf_extra_PHP_ini.zip) :

Glavni izbornik (Home)

 HTML 5, CSS 3, JS, SSL.                                                             Help
1111111111 2222222222 3333333333 4444444444   444444      Home refresh (http)
4444444444 4444444444 4444444444                                        Home https

C:\Apache24\htdocs\index.php says: JS says: location.protocol=https:

 

https://www.proy.info/how-to-enable-localhost-https-on-wamp-server/
Posted On May 19th, 2017

I did mostly see below Masim Man Dec 1, 2016
1. HOW TO SET UP APACHE WITH SSL (HTTPS) ON LOCALHOST
but URL above has some clearer configs

Step 1: Download and unpack Apache lounge 64 bit (Windows 10 64 bit)
and PHP Version 7.1.9 non thread safe
httpd-2.4.27-Win64-VC15.zip, mod_fcgid-2.3.9-win64-VC15.zip
php-7.1.9-nts-Win32-VC14-x64.zip
SEE HOW TO UNPACK zip-s above : https://www.dionysopoulos.me/233-apache-mysql-php-server-on-windows-with-multiple-simultaneous-php-versions.html
or 0_Apache24_conf_extra_PHP_ini.zip above.

we have C:\Apache24 and C:\PHP\7.1.9

Step 2: Download OpenSSL (32 bits/64 bits Windows)
I did not so, see below Masim Man Dec 1, 2016

Step 3: Configure WAMP to use HTTP+SSL=HTTPS
I did not so, see below Masim Man Dec 1, 2016

Step 4: Create SSL Key and Certificate
I did not so, see below Masim Man Dec 1, 2016

Step 5: Copy the Created SSL Key and Certificate file
I did not so, see below Masim Man Dec 1, 2016

Step 6: Open httpd.conf, php.ini & uncomment
Open C:\Apache24\conf\httpd.conf and uncomment:
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
See whole scripts in .zip above.

Step 7: Open httpd-ssl.conf and make the final changes
Open c:\Apache24\conf\extra\httpd-ssl.conf (see .zip above)
find “<VirtualHost _default_:443>” and below that line find and update below configuration according to your setup:
# General setup for the virtual host
DocumentRoot “c:/Apache24/htdocs”
#ServerName www.example.com:443
ServerName localhost:443
ServerAdmin youremail
ErrorLog “c:/Apache24/logs/sslerror.log”
TransferLog “c:/Apache24/logs/sslaccess.log”
SSLEngine on
SSLCertificateFile “c:/Apache24/conf/server.crt”
SSLCertificateKeyFile “c:/Apache24/conf/server.key”
… and so on, see config files in 0_Apache24_conf_extra_PHP_ini.zip.

Open php.ini, uncomment :
extension=php_openssl.dll

Step 8: Test to make sure it works
check if you are getting Syntax is OK
C:\Apache24\bin>httpd -t
https://localhost/index.php

 

https://www.youtube.com/watch?v=Zdl68h_N2lc Masim Man Published on Dec 1, 2016 :

HOW TO SET UP APACHE WITH SSL (HTTPS) ON LOCALHOST

HTTPS (Hyper Text Transfer Protocol Secure) is a protocol for secure communication over a computer network.

Make icon for C:\Windows\SysWOW64\cmd.exe (run as admin). It shows Apache’s openssl:
openssl version -d
OPENSSLDIR: “C:\Program Files\Common Files\SSL”
openssl version
OpenSSL 1.1.0f 25 May 2017

–We create files :
1. C:\Apache24\conf\server.csr              <–OpenSSL certificate request
2. C:\Apache24\conf\server.pem            <–private key

3. C:\Apache24\conf\server.key             <–from .pem
4. C:\Apache24\conf\server.crt              <–from .key, .csr
see  below :
openssl x509 -req -signkey C:\Apache24\conf\server.key -days 1024 ^
-in C:\Apache24\conf\server.csr -out C:\Apache24\conf\server.crt

00000 –INITIAL
Change config path to where you have installed Apache :
cd C:\Apache24\bin
set OPENSSL_CONF=C:\Apache24\conf\openssl.cnf

11111 & 22222 —     ^ = ALTGRKEY+3 (3 two times)
openssl req -config C:\Apache24\conf\openssl.cnf -new ^
   -out C:\Apache24\conf\server.csr -keyout C:\Apache24\conf\server.pem
ANSWERS: only two :
writing new private key to ‘C:\Apache24\conf\server.pem’
Enter PEM pass phrase: test1
Common Name (e.g. server FQDN or YOUR name) []:localhost

33333
openssl rsa -in C:\Apache24\conf\server.pem -out C:\Apache24\conf\server.key
ANSWER: Enter pass phrase for C:\Apache24\conf\server.pem:test1
writing RSA key

44444
openssl x509 -req -signkey C:\Apache24\conf\server.key -days 1024 ^
    -in C:\Apache24\conf\server.csr -out C:\Apache24\conf\server.crt
Outputs:
Signature ok
subject=C = AU, ST = Some-State, O = Internet Widgits Pty Ltd, CN = localhost
Getting Private key

55555
–C:\Apache24\conf\httpd.conf
search ssl, listen, httpd-ssl and uncomment :
LoadModule log_config_module modules/mod_log_config.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule ssl_module modules/mod_ssl.so

Listen 80
#live commented <IfModule mod_ssl.c>
Listen 443
#</IfModule>

Include conf/extra/httpd-ssl.conf

C:\Apache24\conf\extra\httpd-ssl.conf
SSLSessionCache “shmcb:c:/Apache24/logs/ssl_scache(512000)”

restart Apache
if will not start:  as sdmin in CLI
C:\Apache24\bin>httpd -t
or :
NOT httpd.exe -k restart but so:
C:\Apache24\bin>httpd.exe  — this shows error message

 

————– NEEDED FOR MS INET BROWSERS :
https://www.youtube.com/watch?v=Hhown6DgC00 Masim Man Published on Dec 2, 2016
HOW TO INSTALL AN APACHE SELF SIGNED CERTIFICATE ON WINDOWS 10
On Windows 10, a Self Signed Certificate that wasnt issued by a recognized certificate authority is not trusted by default. A Self Signed Certificates usually used on Local Web Servers (Localhost) that arent available publicly. In this case you are save to
– bypass the warning on any browsers
– or installing it to a trusted root certification authority in Windows 10.
2click C:\Apache24\conf\server.crt
in Certificate dialog Issued to and Issued by is localhost
click button “Install certificate”
for current user
place in store “Trusted root Cert. Authorities”
remove certificate localhost so:
WINKEY -> mmc -> File -> Add/remove snapp-in -> Certificates
-> Add -> My user account

9. Main development, test and production menu (& 3 sites) – PHP 7 RC5, Oracle 11g on Windows 10 all 64 bit

HOME – Download Win10 64 bit AMP config and three sites php scripts.

14.8.2016 I changed a lot, see my article 10. This article 9 can be used only for explanations but everything is in code in 1_3sites_mnu_crud_ver1.rar.

22.11.2015 code refactored – i uploaded sites code version 3, (SINGLETON UTILS-HELPERS CLASS, config_site.php…).

Scripts config_site.php, utls.php, utls_glbsetpg.php and lsweb.php explain most important changes. I hope this is final code skeleton, ver4 will be bug fixes and cosmetic updates. (In ver3 I tested only most important lsweb.php but testing others is good exercise – and it shows how difficult this job is).

Statements (functions) flow article (not yet uploaded) should link together all I wanted to say.

Every (vitual) host – I have them 3: dev, test, production – should have in its web site doc root script which tells web server where are resources which are outside doc tree (global fns, settings, css, imgs)

(Problem with resources outside web doc tree is that we need file_get_contents() fn which is disabled by some inet providers. But if you want own SOAP server eg for direct b2b copying einvoice xml – then every your user should have own web site (bad news for some not needed service brokers – posrednici).)

Most important are:
1. “path science” – unexplained enough in learning materials I met (for SPA script very different than for URL called script).
2. Statements (functions) flow (to understand SW & for debugging) – I shall soon write article 10 or 11 (?) about this (SOAP examples for copying xml across inet will also be soon).

I can not understand SPA & frameworks without above two explained. To me seems that framework authors intentionally do not explain important things about their scripts coding (there is to much commercial interests in free SW) – so we have 100 frameworks instead 5-6.

I am shure that Utils class should be, settings should be in global_config.php both outside web doc tree. Local settings in doc tree should owerwrite global.

Eg my : J:\awww\apl\dev1\config_site.php contais:

 < ?php
 // development site (virtual host on home PC) :
 // J:\awww\apl\dev1\config_site.php
//$_SERVER['DOCUMENT_ROOT'] = J:\awww\apl\dev1\
 // yii2 advanced site (virtual host on home PC) :
 // J:\awww\apl\dev1\zfw\yii205\frontend\web\config_site.php
 // J:\awww\apl\dev1\zfw\yii205\aplmy\backend\web\config_site.php
 // realpath
 use utlmoj\utlmoj as utl;
 $ds = DIRECTORY_SEPARATOR;
 /**
 * CONVENTION: sitedocroot/../zinc = eg J:/awww/apl/zinc
 * site does not know where (outside site doc tree) are global resources
 * (util scripts, css, img for all sites), so we must assign
 * 1. GLOBAL RESOURCES (INCLUDES) FOLDER :
 */
 $gloresdir = realpath($_SERVER['DOCUMENT_ROOT'].'/../zinc'); // 1.
 require_once($gloresdir.'/utls.php'); // 2. util (helper) scripts
 $utl=utl::uget(); // 3. get or create helper fns object (singleton)
 require_once($gloresdir.'/utls_glbsetpg.php'); // 4. global page properties
 /**
 * IN APPL (IN SPA) IF IT NEEDS C R U D :
 * 2. g l o b a l C R U D :
 * $dbi = 'sqlite'; $dsn = 'cars_makes_names_savings.sqlite';
 * require_once($gloresdir.$ds.'db_conn.php');
 * db_conn.php does:
 * 1. require_once($gloresdir.'/klase/dbi.php');
 * 2. require_once($gloresdir.'/tbl/zodiac_mdl.php);
 * CONVENTION for M D L of concrete tbl :
 * require_once($gloresdir.'/tbl/'
 * .str_replace('.php','_mdl.php', basename($curpgpath)));
 * 3. template crud script :
 * require_once($gloresdir.$ds.'crud.php');
 */
 // ******************************************
 //exit();
 ?>

I am not shure if Utils class should have static or non static or both methods & properties (because you need many years PHP programming experience to be shure). Properties of this two working ways are not clear to me and unexplained enough in my learning sources.

Pitty that somebody – PHP expert – which I am not – does not explain this somewhere.

2.Sept.2015 – site_ver2.rar – improved code for all scripts, eg for lsweb.php and added some dir icons and better presented/explained site dir structure (see awww_DIR_NOT_VISIBLE_TO_ME.txt).

This article is enough for (advanced) beginning PHP programming Oracle and SQLite CRUD. 
Articles 1 to 8 are supplementary info.

This article unites my posts 3. Zwamp menu and 5. CRUD simple table (example 1) with refactored code for 5. CRUD and my (I hope) final site directories structure.

Most important examples in this article (others are in site_verx.rar):

Example Šifrarnik – is not finished, but shows much. Model is table (id, few_columns)

Example web server directories listing – dir items listing can be extended with row filters, sorts, downloads… but so as it is is very useful for web development.
Model (input data) is DirectoryIterator().
I find lsweb.php very useful for web development:
J:\awww\apl\dev1\zinc\utl\ls.php          http://dev1:8083/zinc/utl/ls.php  (or with ?dir=J:\awww\apl\dev1)
J:\awww\apl\dev1\zinc\utl\lsweb.php

Code for article 3. Zwamp menu is also contained in  site_verx.rar – it is to complicated for real life sites (except if you like something like)  but is excellent for learning PHP.

 

Oracle example 1

Model (input data) is simple table (šifrarnik) (id, few_columns), but more than 50% programming techniques can be learned on this and next example.


J:\awww\apl\dev1\zinstalac\ddl\DDL_selfjoin.sql:
-- winkey+X -> Comm.prompt admin
C:
cd C:\oraclexe\app\oracle\product\11.2.0\server\bin
sqlplus hr/hr
sho user
CREATE TABLE ZODIAC (
  ID          NUMBER(10) NOT NULL,
  SIGN        VARCHAR2(11),
  SYMBOL      VARCHAR2(13),
  PLANET      VARCHAR2(7),
  ELEMENT     VARCHAR2(5),
  START_MONTH INTEGER,
  START_DAY   INTEGER,
  END_MONTH   INTEGER,
  END_DAY     INTEGER,
  PRIMARY KEY(ID)
);

CREATE SEQUENCE ZODIAC_SEQ;
CREATE or replace TRIGGER ZODIAC_PREINS_TRIG 
BEFORE INSERT ON ZODIAC 
FOR EACH ROW
BEGIN
  -- PRIOR TO 11G :
  SELECT ZODIAC_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
  -- 11G :
  --:NEW.MSG_ID := ZODIAC_SEQ.NEXTVAL;
END;
/
sho err

DML :
INSERT INTO zodiac VALUES (1,'Aries','Ram','Mars','fire',3,21,4,19);
INSERT INTO zodiac VALUES (2,'Taurus','Bull','Venus','earth',4,20,5,20);
INSERT INTO zodiac VALUES (3,'Gemini','Twins','Mercury','air',5,21,6,21);
INSERT INTO zodiac VALUES (4,'Cancer','Crab','Moon','water',6,22,7,22);
INSERT INTO zodiac VALUES (5,'Leo','Lion','Sun','fire',7,23,8,22);
INSERT INTO zodiac VALUES (6,'Virgo','Virgin','Mercury','earth',8,23,9,22);
INSERT INTO zodiac VALUES (7,'Libra','Scales','Venus','air',9,23,10,23);
INSERT INTO zodiac VALUES (8,'Scorpio','Scorpion','Mars','water',10,24,11,21);
INSERT INTO zodiac VALUES (9,'Sagittarius','Archer','Jupiter','fire',11,22,12,21);
INSERT INTO zodiac VALUES (10,'Capricorn','Goat','Saturn','earth',12,22,1,19);
INSERT INTO zodiac VALUES (11,'Aquarius','Water Carrier','Uranus','air',1,20,2,18);
INSERT INTO zodiac VALUES (12,'Pisces','Fishes','Neptune','water',2,19,3,20);

Scripts directory structure (SPA, MVC domain style)

SPA means scripts are included, only exceptionally URL called. So scripts see all $ variables as own.

In SPA is not posible using relative page adresses because path relative to included script is not relative to includer (SPA) script  – adresses syntax explained here must be used !! To learn dirs science is one of most difficult PHP beginning parts, and allmost NOT EVEN MENTIONED in PHP learning materials.

MVC domain style means Scripts directory structure is “one form (application) one dir (& its subdeirs if needed)”. MVC is basically old structured programming:

  1. initialize (bootstrap, config),
  2. manage (ctr),
  3. input (model),
  4. output (view).

It is interesting that no one MVC promotor mentions this simple truth. Names are most important, but working means not (only) inventing new names but understand+explain.

DDLs are in J:\awww\apl\dev1\zinstalac\ddl\,  eg above  DDL_selfjoin.sql contain also selfjoin DDL & for SQLite.

Global config scripts (.php, .css, .js…most important of all types !) are in J:\awww\apl\dev1\zinc\,  eg  utls.php.

Below zinc are dirs: utl (helpers), slike (img), js…

Three sites (Apache virtual hosts on home PC):

Development URL is http://dev1:8083/ is Windows dir J:\awww\apl\dev1.

Production URL is http://pro1:8083/  is Windows dir J:\awww\apl\pro1.

Simmilar are both test site adresses.

 

After huderts Oracle Forms 6i created from scratch (from existing form ctrl+c,v) in more then 15 years it seems to me, whatever they say :), for PHP & Oracle should be :

CONVENTIONS FOR BETTER SCRIPTS VISIBILITY

  1. No camelcase becouse name higher_lower is (to me) better visible then camelcase higherLower
  2. Scripts sufixes :
    1. controller scripts have no sufix
    2. other scripts :
      1. model scripts: _mdl, _val (validation scripts)
      2. view scripts: _frm, _tbl, _rep
  3. ctr / bootstrap scripts are NOT named index.php, but are named simmilar to DB table name which they (CRUD) manage.Beside script visibility, this enables us to have more/all small tables crud (forms) scripts in one dir.To many dirs is not practical and old principle “one form (application) one dir (& its subdeirs if needed)” is newest fashion (2015 year).
  4. GLOBAL configuration scripts are in $CNFGD=J:\awww\apl\dev1\zinc, eg $CNFGD.$DS.utls.phputls.php (with help of config not static class & namespace) defines PHP $  (adress) variables for all included scripts (SPA !!) (no constants except pi and simmilar). Conf. vars must be defined as $ vars in utls.php and not as concatenation of dirs in all index.php scripts, becouse :
    IF DIR TREE CHANGES -> WE CHANGE ONLY ONE PLACE: utls.php
  5. Some strange names are better for search or for name conflicts (eg zinc instead of includes, chcons instead configclass, this example zodiac…)

 

Example 2: Web server directories listing programs

Model (input data) is DirectoryIterator() dir items listing.

I find them very useful for web development:
J:\awww\apl\dev1\zinc\utl\ls.php          http://dev1:8083/zinc/utl/ls.php  (or with ?dir=J:\awww\apl\dev1)
J:\awww\apl\dev1\zinc\utl\lsweb.php

 Conclusion

I did not see advantages in my testings compared with programming techniques I explained in this article (and in other before):

  1. AngularJS 1.4.3 CRUD with Oracle 11g
  2. Yii 2.0.6 with PHP 7 beta 3
  3. FatFree PHP fw

But frameworks above:

  1. no Oracle DBI example for normal people given
  2. It seems to me they are unfinished – always in development (uncompatible new versions), always new fws appear.
  3. slower ( min ~ 150 kB code with uncertain future included),
  4. more complicated – another (more) programming languages
  5. They do not even mention reporting (php reports from Eustáquio Rangel or similar) or tab key -> enter key which I made with few lines Javascript code (see site_ver1.rar J:\awww\apl\dev1\zinc\key_pressed.js).
  6. I doubt if they are more productive – learn time for programming techniques I explained in this article is ~ as for them  (lot of time 🙂 )
  7. to many incompatibilities uncertain future (yii2, ng 2),

Until authors of fw sw convince us on CRUD examples I give in this article + master-detail example I can not believe their to simple / not clear CRUD examples.


~~~utls.php $test=1 ~~~end script J:\awww\apl\dev1\index.php   source   phpinfo~~~