logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Building & Member Downloads View previous topic :: View next topic
Reply to topic   Topic: Automated Build of Apache2.2.17 PHP5.3.3 OpenSSL1.0.0a Zlib
Author
Street



Joined: 12 Oct 2010
Posts: 2

PostPosted: Sun 31 Oct '10 3:29    Post subject: Automated Build of Apache2.2.17 PHP5.3.3 OpenSSL1.0.0a Zlib Reply with quote

Some of the Prerequsites:

At least visual studio 2008 c++ express which this was built with. Should work just fine with full VS
MS Platform SDK
GNUWIN tools that are needed for normal compile of Apache Web Server
Perl for windows
7zip or some other compression software
Your system paths set properly to use these tools
Also system paths for MSVisual STudio C++ directory path values set
MIght be a few other things but that should cover it
You can get the build requirements directly from Apache.org if there needs to be more or others can fill in the blanks


What this is.
This is a automated build process for building Apache 2.2.17 Php 5.3.3 OpenSSL 1.0.0a zlib 1.2.3.
Two fundamentals apply here.
1) You need to review the code and supply your own paths where they belong.
If you do so correctly all will work just as stated.
You will need to edit the batch file and the vbs file to set your paths correctly. Use A real text editor not Notepad.

If you do not have 7zip installed then you will need to change the environment variables. To use for your decompression.

2) Files to use
Apache source files from there site in there zip archive
PHP Win32 VC6 x86 from there site in there zip archive
Openssl 1.0.0a from there stie in there tar gz archive
Zlib 1.2.3 from there site in there tar gz archive
Create a index.php -- this will be used for the manual folder of the Apache server Code below to include in file
Create a test.php -- this file will be used to test your server Code below to include in file
You need to create a server.crt and server.pem file using openssl
create a favicon.ico file for your server
create a text file called mofify.httpd.conf.vbs Code below. This file makes changes to the configuration files of your server
All of the above files need to be put into a archive just as is. Call the archive build.Apache2217.zip

Last but not least you need to creat the batch file to auto mate everything code below. "Call it what ever you want .bat"
Once this is all done you will have a directory structure something like this
Your path what ever drive you are using. -- Make sure you edit the files to reflect your actual paths you use.
D:\buil.Apache2217.zip
D:\callitwhateveryouwant.bat

A:) Open up visual studio C++ command prompt
B:) Point it to as in example above to the d:\ drive
C:) At the command prompt type the name of the bat file. No need to type the .bat extention the name should do just fine.

D:) Advantages of automating the prepare compile build of the Apache PHP OpenSSL server
1) Once you have all your paths straight. You can recompile your server at anytime. Due to drive CRashes
What ever the need be. Testing out new things. Its a type once and forget it process
2) If you choose to use this as a major back up of your server which it would have advantages of doing so.
All you would need to do is add to the batch file the process to archive your htdocs folder.
Then add the process of decompressing it back into your htdocs folder.
The only things you would to do is edit the batch file and add the new archive to the main archive.
3) If your constantly worried about loosing your drive or your data. Take the archive and batch file and put it on a pen drive
Take it where ever you want.
4) All of your Apache Server configuration is done automatically. No need to edit files as this process does it for you.
Compile and build then start the server if all works right all you need to do is exactly that Start the Server.
No editing invloved its all done via the batch and vbs file automatically.
E) The only thing i have not included into this process is installing the server as a service.
Thats easy enough for you to do on your own if you choose. Some do not want HTTPD to run as a service.

So essentially what you have once all is done is Two files the archive and the batch file thats it.
Ok here is the coding for the files i told you about.

index.php file
Code:

<?php
$varri = "http://httpd.apache.org/docs/2.2/";
?>

  <iframe src=<?php print $varri; ?> scrolling="auto" width=100% height=100% frameborder="0"> </iframe>


test.php
Code:

<?php
if (!isset($_POST['action']))
{
//If not isset -> set with dumy value
$_POST['action'] = "undefine";
}
// Set error reporting to display all errors and notices
error_reporting(E_ALL);

// Start a session
session_start();

// Check for the existence of a known session variable
if ( $_SESSION['test_value'] ) {
  echo 'Found a session';
} else {
  echo 'No session exists - writing to test_value';
  $_SESSION['test_value'] = true;
}

// Close and write session
session_write_close();
?>
<?php
// Connecting, selecting database
$link = mysql_connect('localhost', 'database user', 'db user pass')
    or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('testdb') or die('Could not select database');
?>


<?php
phpinfo();
?>



modify.httpd.conf.vbs
Code:

sKey1 = "#LoadModule deflate_module modules/mod_deflate.so"
sKey2 = "#LoadModule ssl_module modules/mod_ssl.so"
sKey3 = "#LoadModule vhost_alias_module modules/mod_vhost_alias.so"
sKey4 = "    DirectoryIndex index.html"
skey5 = "#Include conf/extra/httpd-ssl.conf"
skey6 = "#Include conf/extra/httpd-manual.conf"
sNewLine = "LoadModule deflate_module modules/mod_deflate.so"
sNewLine1 = "LoadModule ssl_module modules/mod_ssl.so"
sNewLine2 = " I know a good life when i see it"
sNewLine3 ="#LoadModule vhost_alias_module modules/mod_vhost_alias.so"
sNewLine4 ="# PHP directives to allow PHP to run in server"
sNewLine5 ="LoadModule php5_module D:/Apache.Webserver/Apache2.2.17.test/php/php5apache2_2.dll"
sNewLine6 ="# add file type handlers for executing php scripts in type file example as below adding .html will now process php within a html file"
sNewLine7 ="AddHandler application/x-httpd-php .php .html"
sNewLine8 =""
sNewLine9 ="#create an .htaccess file and add this line to it:"
sNewLine10 ="#AddType application/x-httpd-php .php .html .htm"
sNewLine11 =""
sNewLine12 ="#The above configuration will enable PHP handling of any file that has a .php extension, even if there are other file extensions."
sNewLine13 ="#For example, a file named example.php.txt will be executed by the PHP handler."
sNewLine14 ="#To ensure that only files that end in  .php are executed, use the following configuration instead:"
sNewLine15 ="#<FilesMatch \.php$>"
sNewLine16 ="#      SetHandler application/x-httpd-php"
sNewLine17 ="#</FilesMatch>"
sNewLine18 =""
sNewLine19 ="# configure the path to php.ini"
sNewLine20 ="PHPIniDir D:/Apache.Webserver/Apache2.2.17.test/php"
sNewLine21 ="    DirectoryIndex index.html index.php"
sNewLine22 ="Include conf/extra/httpd-ssl.conf"
sNewLine23 ="Include conf/extra/httpd-manual.conf"
sFileName = "D:\Apache.Webserver\Apache2.2.17.test\conf\httpd.conf"

Set objFS = CreateObject("Scripting.FileSystemObject")
aContents = Split(objFS.OpenTextFile(sFileName).ReadAll, vbNewLine)
Set objTS = objFS.OpenTextFile(sFileName, 2)
For Each sLine In aContents
    bFound = False
    If InStr(1, sLine, sKey1, 1) = 1 Then
       wscript.echo "1: sLine=" & sLine
        bFound = True
        objTS.WriteLine sNewLine
'        objTS.WriteLine sNewLine1
    End If
    If InStr(1, sLine, sKey2, 1) = 1 Then
       wscript.echo "2: sLine=" & sLine
        bFound = True
        objTS.WriteLine sNewLine1
'        objTS.WriteLine sNewLine3
    End If
    If InStr(1, sLine, sKey3, 1) = 1 Then
       wscript.echo "3: sLine=" & sLine
        bFound = True
        objTS.WriteLine sNewLine3
        objTS.WriteLine sNewLine4
        objTS.WriteLine sNewLine5
        objTS.WriteLine sNewLine6
        objTS.WriteLine sNewLine7
        objTS.WriteLine sNewLine8
        objTS.WriteLine sNewLine9
        objTS.WriteLine sNewLine10
        objTS.WriteLine sNewLine11
        objTS.WriteLine sNewLine12
        objTS.WriteLine sNewLine13
        objTS.WriteLine sNewLine14
        objTS.WriteLine sNewLine15
        objTS.WriteLine sNewLine16
        objTS.WriteLine sNewLine17
        objTS.WriteLine sNewLine18
        objTS.WriteLine sNewLine19
        objTS.WriteLine sNewLine20
'        objTS.WriteLine sNewLine3
    End If
    If InStr(1, sLine, sKey4, 1) = 1 Then
       wscript.echo "4: sLine=" & sLine
        bFound = True
        objTS.WriteLine sNewLine21
'        objTS.WriteLine sNewLine3
    End If
    If InStr(1, sLine, sKey5, 1) = 1 Then
       wscript.echo "5: sLine=" & sLine
        bFound = True
        objTS.WriteLine sNewLine22
'        objTS.WriteLine sNewLine3
    End If
    If InStr(1, sLine, sKey6, 1) = 1 Then
       wscript.echo "6: sLine=" & sLine
        bFound = True
        objTS.WriteLine sNewLine23
'        objTS.WriteLine sNewLine3
    End If   
    if not bFound then
      wscript.echo "7: sLine=" & sLine
      objTS.WriteLine sLine
    End If
Next
objTS.Close
'Set objTS = Nothing
'Set objFS = Nothing
fKey1 = "display_errors = Off"
fKey2 = "doc_root ="
fKey3 = "; extension_dir = ""ext"""
fKey4 = ";extension=php_mysql.dll"
fKey5 = "mysql.default_port ="
fKey6 = ";session.save_path = ""/tmp"""
fKey7 = "session.cookie_lifetime = 0"
sNewLine1 = "display_errors = On"
sNewLine2 = "doc_root = D:\Apache.Webserver\Apache2.2.17.test\htdocs"
sNewLine3 = "extension_dir = ""D:\Apache.Webserver\Apache2.2.17.test\php\ext"""
sNewLine4 = "extension=php_mysql.dll"
sNewLine5 = "mysql.default_port = 3309"
sNewLine6 = "session.save_path = ""D:\Apache.Webserver\Apache2.2.17.test\htdocs\sessions"""
sNewLine7 = "session.cookie_lifetime = 1"
sFileName = "D:\Apache.Webserver\Apache2.2.17.test\php\php.ini"
Set objFS = CreateObject("Scripting.FileSystemObject")
aContents = Split(objFS.OpenTextFile(sFileName).ReadAll, vbNewLine)
Set objTS = objFS.OpenTextFile(sFileName, 2)
For Each sLine In aContents
    bFound = False
    If InStr(1, sLine, fKey1, 1) = 1 Then
       wscript.echo "1: sLine=" & sLine
        bFound = True
        objTS.WriteLine sNewLine1
'        objTS.WriteLine sNewLine1
    End If
    If InStr(1, sLine, fKey2, 1) = 1 Then
       wscript.echo "2: sLine=" & sLine
        bFound = True
        objTS.WriteLine sNewLine2
'        objTS.WriteLine sNewLine1
    End If
    If InStr(1, sLine, fKey3, 1) = 1 Then
       wscript.echo "3: sLine=" & sLine
        bFound = True
        objTS.WriteLine sNewLine3
'        objTS.WriteLine sNewLine1
    End If
    If InStr(1, sLine, fKey4, 1) = 1 Then
       wscript.echo "4: sLine=" & sLine
        bFound = True
        objTS.WriteLine sNewLine4
'        objTS.WriteLine sNewLine1
    End If
    If InStr(1, sLine, fKey5, 1) = 1 Then
       wscript.echo "5: sLine=" & sLine
        bFound = True
        objTS.WriteLine sNewLine5
'        objTS.WriteLine sNewLine1
    End If
    If InStr(1, sLine, fKey6, 1) = 1 Then
       wscript.echo "6: sLine=" & sLine
        bFound = True
        objTS.WriteLine sNewLine6
'        objTS.WriteLine sNewLine1
    End If
    If InStr(1, sLine, fKey7, 1) = 1 Then
       wscript.echo "7: sLine=" & sLine
        bFound = True
        objTS.WriteLine sNewLine7
'        objTS.WriteLine sNewLine1
    End If   
    if not bFound then
      wscript.echo "8: sLine=" & sLine
      objTS.WriteLine sLine
    End If
Next
objTS.Close
sslKey1 = "SSLCertificateKeyFile ""D:/Apache.Webserver/Apache2.2.17.test/conf/server.key"""
sNewLine = "SSLCertificateKeyFile ""D:/Apache.Webserver/Apache2.2.17.test/conf/server.pem"""
sFileName = "D:\Apache.Webserver\Apache2.2.17.test\conf\extra\httpd-ssl.conf"
Set objFS = CreateObject("Scripting.FileSystemObject")
aContents = Split(objFS.OpenTextFile(sFileName).ReadAll, vbNewLine)
Set objTS = objFS.OpenTextFile(sFileName, 2)
For Each sLine In aContents
    bFound = False
    If InStr(1, sLine, sslKey1, 1) = 1 Then
       wscript.echo "1: sLine=" & sLine
        bFound = True
        objTS.WriteLine sNewLine
'        objTS.WriteLine sNewLine1
    End If
    if not bFound then
      wscript.echo "8: sLine=" & sLine
      objTS.WriteLine sLine
    End If
Next
objTS.Close



What ever you call it batch file .bat
Code:


c:\7-zip\7z.exe x D:\build.Apache2217.zip -oD:\buildApache2217
RMDIR D:\Apache.Webserver\Apache2.2.17.test /S /Q
RMDIR D:\test111 /S /Q
RMDIR D:\php533 /S /Q /Q
RMDIR D:\opensslsrc /S /Q
c:\7-zip\7z.exe x D:\buildApache2217\php-5.3.3-Win32-VC6-x86.zip -oD:\php533
c:\7-zip\7z.exe x D:\buildApache2217\httpd-2.2.17-win32-src.zip -oD:\test111
c:\7-zip\7z.exe x D:\buildApache2217\zlib-1.2.3.tar.gz -oD:\test111
c:\7-zip\7z.exe x D:\test111\zlib-1.2.3.tar -oD:\test111
mkdir D:\test111\httpd-2.2.17\srclib\zlib
xcopy D:\test111\zlib-1.2.3\*.* /E D:\test111\httpd-2.2.17\srclib\zlib
RMDIR D:\test111\zlib-1.2.3 /S /Q
DEL   D:\test111\zlib-1.2.3.tar /Q
cd test111\httpd-2.2.17
:: Enter Zlib Folder in the Apache Folder to get ready to compile Zlib
cd srclib\zlib
:: Compile zlib
nmake -f win32\Makefile.msc
:: Go back to root of folder
cd ../../../../
:: Decompress OpenSSL
c:\7-zip\7z.exe x D:\buildApache2217\openssl-1.0.0a.tar.gz -oD:\opensslsrc
c:\7-zip\7z.exe x D:\opensslsrc\openssl-1.0.0a.tar -oD:\opensslsrc
:: Rename the folder for OpenSSL
RENAME D:\opensslsrc\openssl-1.0.0a openssl
:: Delete the OpenSSL Tar archive
DEL    D:\opensslsrc\openssl-1.0.0a.tar /Q
:: compile OpenSSL and go back to root of drive you started with
echo nmake -f ms\ntdll.mak install  >> D:\opensslsrc\openssl\ms\do_ms.bat
cd ../../
::  Move compiles Openssl to the httpd srclib folder
echo xcopy D:\opensslsrc\*.* /E D:\test111\httpd-2.2.17\srclib  >> D:\opensslsrc\openssl\ms\do_ms.bat
:: Enter the httpd Apache Folders to get ready to compile Apache
echo cd D:\test111\httpd-2.2.17 >> D:\opensslsrc\openssl\ms\do_ms.bat
:: Compile Apache Web Server
echo nmake /f Makefile.win SERVERNAME="localhost" PORT=80 SSLPORT=8088 INSTDIR="D:\Apache.Webserver\Apache2.2.17.test" installr >> D:\opensslsrc\openssl\ms\do_ms.bat
:: Delete files that are not needed to run Apache such as the debug fules *.pdb and the manual files which you do not need all the updated information will always be at apache.org
echo DEL /S /Q D:\Apache.Webserver\Apache2.2.17.test\*.pdb >> D:\opensslsrc\openssl\ms\do_ms.bat
echo RMDIR /S /Q D:\Apache.Webserver\Apache2.2.17.test\manual\ >> D:\opensslsrc\openssl\ms\do_ms.bat
:: Go back to root of start drive
echo cd ../../ >> D:\opensslsrc\openssl\ms\do_ms.bat
:: Make directory for the php folder
echo md D:\Apache.Webserver\Apache2.2.17.test\php >> D:\opensslsrc\openssl\ms\do_ms.bat
:: Copy the php files to the directory you just created
echo xcopy D:\php533\*.* /E D:\Apache.Webserver\Apache2.2.17.test\php >> D:\opensslsrc\openssl\ms\do_ms.bat
:: Rename the php.ini file to be used by the apache server
echo RENAME D:\Apache.Webserver\Apache2.2.17.test\php\php.ini-production php.ini >> D:\opensslsrc\openssl\ms\do_ms.bat
:: copy a test file over to the Apache root doc directory so you can see your server working. This is a phpinfo directive along with a mysql test Modify the file to suit your mysql server
echo xcopy D:\buildApache2217\test.php D:\Apache.Webserver\Apache2.2.17.test\htdocs >> D:\opensslsrc\openssl\ms\do_ms.bat
:: A visual basic script to modify text in the httpd.conf file along with ssl.conf file for https along with modifying the php.ini file Make changes in the script to automate the work
echo Cscript D:\BuildApache2217\modify.httpd.conf.vbs >> D:\opensslsrc\openssl\ms\do_ms.bat
:: Move your already acreated self signed ssl server keys and certificates to the apache conf folder
echo xcopy D:\buildApache2217\server.pem D:\Apache.Webserver\Apache2.2.17.test\conf >> D:\opensslsrc\openssl\ms\do_ms.bat
echo xcopy D:\buildApache2217\server.crt D:\Apache.Webserver\Apache2.2.17.test\conf >> D:\opensslsrc\openssl\ms\do_ms.bat
echo cd ../../ >> D:\opensslsrc\openssl\ms\do_ms.bat
:: Remake the manual folder for the httpd apache server This could be useful if you decided to make a manual for your site maybe a FAQ area Could be anything really you put in here
echo MD D:\Apache.Webserver\Apache2.2.17.test\manual >> D:\opensslsrc\openssl\ms\do_ms.bat
:: Make the directory for sessions where you specified in the php.ini file
echo MD D:\Apache.Webserver\Apache2.2.17.test\htdocs\sessions >> D:\opensslsrc\openssl\ms\do_ms.bat
:: move favicon.ico to root of server docs aka htdocs folder
echo xcopy D:\buildApache2217\favicon.ico D:\Apache.Webserver\Apache2.2.17.test\htdocs >> D:\opensslsrc\openssl\ms\do_ms.bat
:: Add a file to the recreated manual folder this file has a header redirect to the apache.org document page no need to have local manual when updated online will be better from the source Apache.org
echo xcopy D:\buildApache2217\index.php D:\Apache.Webserver\Apache2.2.17.test\manual >> D:\opensslsrc\openssl\ms\do_ms.bat
echo RMDIR D:\test111 /S /Q >> D:\opensslsrc\openssl\ms\do_ms.bat
:: Remove the directories you started to work with kinda redundant but cleans things up a bit
echo RMDIR D:\php533 /S /Q >> D:\opensslsrc\openssl\ms\do_ms.bat
echo RMDIR D:\buildApache2217 /S /Q >> D:\opensslsrc\openssl\ms\do_ms.bat
echo RMDIR D:\opensslsrc /S /Q >> D:\opensslsrc\openssl\ms\do_ms.bat
:: STart the automated compile build configure Apache process
cd D:\opensslsrc\openssl
perl Configure --openssldir=N:/opensslsrc/openssl VC-WIN32
ms\do_ms


Last but not least.
Using this code from the forum page you might wind up with some lines of code that span two lines or so
Remember all batch file cmds are on a single line so just edit it if need be to reflect that each process is one line only

Good luck and good codeing to you

Created by TheTinkeringToad @ 2010 admin@ajumbledbox.net
Back to top
admin
Site Admin


Joined: 15 Oct 2005
Posts: 679

PostPosted: Sun 31 Oct '10 9:00    Post subject: Reply with quote

Thanks for sharing.

Steffen
Back to top
Street



Joined: 12 Oct 2010
Posts: 2

PostPosted: Sun 31 Oct '10 12:43    Post subject: Reply with quote

NP
Glad to share. I did this same thing some years back with a older version of apache.
Though i have updated my server since then i did not update the process.
It is good to share with others. It is also good to know how easy it would be to set up my server again on a new drive, new computer or what ever.
I think one of the best advantages of this is the ability to use it as a complete server backup and restore process.
You could always set the batch file up to ask questions like.
Do you want to install a new server.
If not you say no and it goes on to the next question.
Do you want to backup your server.
So on and so on.
All that would need to be done is edit the batch file to do this.
Back to top


Reply to topic   Topic: Automated Build of Apache2.2.17 PHP5.3.3 OpenSSL1.0.0a Zlib View previous topic :: View next topic
Post new topic   Forum Index -> Building & Member Downloads