From 6102105a07880d0dafb02c33019e23fe9491ec1c Mon Sep 17 00:00:00 2001 From: mcrane Date: Sun, 20 Dec 2009 07:06:59 -0700 Subject: vHosts web server 0.2 http web server functioning. https support needs a little more work. --- config/vhosts/lighty-vhosts.conf | 179 ----------- config/vhosts/system_advanced_create_certs.tmp | 262 ++++++++++++++++ config/vhosts/vhosts.inc | 402 +++++++++++++++++++------ config/vhosts/vhosts.xml | 15 +- config/vhosts/vhosts_php.tmp | 75 +++-- config/vhosts/vhosts_php_edit.tmp | 154 +++++++--- pkg_config.7.xml | 6 +- 7 files changed, 733 insertions(+), 360 deletions(-) delete mode 100644 config/vhosts/lighty-vhosts.conf create mode 100644 config/vhosts/system_advanced_create_certs.tmp diff --git a/config/vhosts/lighty-vhosts.conf b/config/vhosts/lighty-vhosts.conf deleted file mode 100644 index b3178771..00000000 --- a/config/vhosts/lighty-vhosts.conf +++ /dev/null @@ -1,179 +0,0 @@ -# -# lighttpd configuration file -# -# use a it as base for lighttpd 1.0.0 and above -# -############ Options you really have to take care of #################### - -## FreeBSD! -server.event-handler = "freebsd-kqueue" -server.network-backend = "writev" ## Fixes 7.x upload issues - - - -## modules to load -server.modules = ( - "mod_accesslog", - "mod_access", "mod_accesslog", - "mod_fastcgi", "mod_cgi","mod_rewrite" - ) - -## Unused modules -# "mod_setenv", -# "mod_compress" -# "mod_redirect", -# "mod_rewrite", -# "mod_ssi", -# "mod_usertrack", -# "mod_expire", -# "mod_secdownload", -# "mod_rrdtool", -# "mod_auth", -# "mod_status", -# "mod_alias", -# "mod_proxy", -# "mod_simple_vhost", -# "mod_evhost", -# "mod_userdir", -# "mod_cgi", -# "mod_accesslog" - -## a static document-root, for virtual-hosting take look at the -## server.virtual-* options -server.document-root = "/usr/local/vhosts/" - - -# Maximum idle time with nothing being written (php downloading) -server.max-write-idle = 999 - -## where to send error-messages to -server.errorlog = "/var/log/lighttpd.error.log" - -# files to check for if .../ is requested -server.indexfiles = ( "index.php", "index.html", - "index.htm", "default.htm" ) - -# mimetype mapping -mimetype.assign = ( - ".pdf" => "application/pdf", - ".sig" => "application/pgp-signature", - ".spl" => "application/futuresplash", - ".class" => "application/octet-stream", - ".ps" => "application/postscript", - ".torrent" => "application/x-bittorrent", - ".dvi" => "application/x-dvi", - ".gz" => "application/x-gzip", - ".pac" => "application/x-ns-proxy-autoconfig", - ".swf" => "application/x-shockwave-flash", - ".tar.gz" => "application/x-tgz", - ".tgz" => "application/x-tgz", - ".tar" => "application/x-tar", - ".zip" => "application/zip", - ".mp3" => "audio/mpeg", - ".m3u" => "audio/x-mpegurl", - ".wma" => "audio/x-ms-wma", - ".wax" => "audio/x-ms-wax", - ".ogg" => "audio/x-wav", - ".wav" => "audio/x-wav", - ".gif" => "image/gif", - ".jpg" => "image/jpeg", - ".jpeg" => "image/jpeg", - ".png" => "image/png", - ".xbm" => "image/x-xbitmap", - ".xpm" => "image/x-xpixmap", - ".xwd" => "image/x-xwindowdump", - ".css" => "text/css", - ".html" => "text/html", - ".htm" => "text/html", - ".js" => "text/javascript", - ".asc" => "text/plain", - ".c" => "text/plain", - ".conf" => "text/plain", - ".text" => "text/plain", - ".txt" => "text/plain", - ".dtd" => "text/xml", - ".xml" => "text/xml", - ".mpeg" => "video/mpeg", - ".mpg" => "video/mpeg", - ".mov" => "video/quicktime", - ".qt" => "video/quicktime", - ".avi" => "video/x-msvideo", - ".asf" => "video/x-ms-asf", - ".asx" => "video/x-ms-asf", - ".wmv" => "video/x-ms-wmv", - ".bz2" => "application/x-bzip", - ".tbz" => "application/x-bzip-compressed-tar", - ".tar.bz2" => "application/x-bzip-compressed-tar" - ) - -# Use the "Content-Type" extended attribute to obtain mime type if possible -#mimetypes.use-xattr = "enable" - -#### accesslog module -#accesslog.filename = "/dev/null" - -## deny access the file-extensions -# -# ~ is for backupfiles from vi, emacs, joe, ... -# .inc is often used for code includes which should in general not be part -# of the document-root -url.access-deny = ( "~", ".db" ) - - -######### Options that are good to be but not neccesary to be changed ####### - -## bind to port (default: 80) -server.port = 8001 - -## error-handler for status 404 -#server.error-handler-404 = "/error-handler.html" -#server.error-handler-404 = "/error-handler.php" - -## to help the rc.scripts -server.pid-file = "/var/run/lighty-vhosts.pid" - -## virtual directory listings -server.dir-listing = "disable" - -## enable debugging -debug.log-request-header = "disable" -debug.log-response-header = "disable" -debug.log-request-handling = "disable" -debug.log-file-not-found = "disable" - -#### compress module -#compress.cache-dir = "/tmp/lighttpd/cache/compress/" -#compress.filetype = ("text/plain", "text/html") - -#server.network-backend = "writev" - -server.upload-dirs = ( "/root/", "/tmp/", "/var/" ) - - -server.max-request-size = 2097152 - -#### fastcgi module -## read fastcgi.txt for more info -fastcgi.server = ( ".php" => - ( "localhost" => - ( - "socket" => "/tmp/php5-fastcgi.socket", - "min-procs" => 1, - "max-procs" => 1, - "idle-timeout" => 0, - "bin-environment" => ( - "PHP_FCGI_MAX_REQUESTS" => "500", - "PHP_FCGI_CHILDREN" => "1" - ), - "bin-path" => "/usr/local/php5/php-cgi" - ) - ) -) - -#### CGI module -cgi.assign = ( ".cgi" => "" ) - - - - - diff --git a/config/vhosts/system_advanced_create_certs.tmp b/config/vhosts/system_advanced_create_certs.tmp new file mode 100644 index 00000000..2b0b2229 --- /dev/null +++ b/config/vhosts/system_advanced_create_certs.tmp @@ -0,0 +1,262 @@ + + + +

+
+ + +

One moment please... + + + + + + + + + + + +

System: Advanced - Create Certificates

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Country Code (2 Letters) + + +
State or Province name + + +
City name + + +
Organization name + + +
Organization department + + +
Common Name (Your name) + + +
  + +
+ + + + + diff --git a/config/vhosts/vhosts.inc b/config/vhosts/vhosts.inc index 0cb88064..8e013f4b 100644 --- a/config/vhosts/vhosts.inc +++ b/config/vhosts/vhosts.inc @@ -33,148 +33,365 @@ function pkg_is_service_running($servicename) { - exec("/bin/ps ax | awk '{ print $5 }'", $psout); - array_shift($psout); - foreach($psout as $line) { - $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line))))); - } - if(is_service_running($servicename, $ps) or is_process_running($servicename) ) { - return true; - } - else { - return false; - } + exec("/bin/ps ax | awk '{ print $5 }'", $psout); + array_shift($psout); + foreach($psout as $line) { + $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line))))); + } + if(is_service_running($servicename, $ps) or is_process_running($servicename) ) { + return true; + } + else { + return false; + } } function byte_convert( $bytes ) { + if ($bytes<=0) + return '0 Byte'; - if ($bytes<=0) - return '0 Byte'; - - $convention=1000; //[1000->10^x|1024->2^x] - $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); - $e=floor(log($bytes,$convention)); - return round($bytes/pow($convention,$e),2).' '.$s[$e]; + $convention=1000; //[1000->10^x|1024->2^x] + $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); + $e=floor(log($bytes,$convention)); + return round($bytes/pow($convention,$e),2).' '.$s[$e]; } - + +//sort array + function sort_host($a, $b){ + return strcmp($a["host"], $b["host"]); + } + + function sort_port($a, $b){ + return strcmp($a["port"], $b["port"]); + } + + function sort_ip_address($a, $b){ + return natsort($a["ipaddress"], $b["ipaddress"]); + } + + function vhosts_sync_package_php() { + global $config; + if($config['installedpackages']['vhosts']['config'] != "") { - global $config; - if($config['installedpackages']['vhosts']['config'] != "") { + conf_mount_rw(); + config_unlock(); - conf_mount_rw(); - config_unlock(); - - $tmp = "\\n\";\n"; - $tmp .= " } else {\n"; - $tmp .= " fwrite(\$fp, \$syslogmsg);\n"; - $tmp .= " fclose(\$fp);\n"; - $tmp .= " }\n"; + $tmp .= "# files to check for if .../ is requested\n"; + $tmp .= "server.indexfiles = ( \"index.php\", \"index.html\",\n"; + $tmp .= " \"index.htm\", \"default.htm\" )\n"; $tmp .= "\n"; - $tmp .= "}\n"; + $tmp .= "# mimetype mapping\n"; + $tmp .= "mimetype.assign = (\n"; + $tmp .= " \".pdf\" => \"application/pdf\",\n"; + $tmp .= " \".sig\" => \"application/pgp-signature\",\n"; + $tmp .= " \".spl\" => \"application/futuresplash\",\n"; + $tmp .= " \".class\" => \"application/octet-stream\",\n"; + $tmp .= " \".ps\" => \"application/postscript\",\n"; + $tmp .= " \".torrent\" => \"application/x-bittorrent\",\n"; + $tmp .= " \".dvi\" => \"application/x-dvi\",\n"; + $tmp .= " \".gz\" => \"application/x-gzip\",\n"; + $tmp .= " \".pac\" => \"application/x-ns-proxy-autoconfig\",\n"; + $tmp .= " \".swf\" => \"application/x-shockwave-flash\",\n"; + $tmp .= " \".tar.gz\" => \"application/x-tgz\",\n"; + $tmp .= " \".tgz\" => \"application/x-tgz\",\n"; + $tmp .= " \".tar\" => \"application/x-tar\",\n"; + $tmp .= " \".zip\" => \"application/zip\",\n"; + $tmp .= " \".mp3\" => \"audio/mpeg\",\n"; + $tmp .= " \".m3u\" => \"audio/x-mpegurl\",\n"; + $tmp .= " \".wma\" => \"audio/x-ms-wma\",\n"; + $tmp .= " \".wax\" => \"audio/x-ms-wax\",\n"; + $tmp .= " \".ogg\" => \"audio/x-wav\",\n"; + $tmp .= " \".wav\" => \"audio/x-wav\",\n"; + $tmp .= " \".gif\" => \"image/gif\",\n"; + $tmp .= " \".jpg\" => \"image/jpeg\",\n"; + $tmp .= " \".jpeg\" => \"image/jpeg\",\n"; + $tmp .= " \".png\" => \"image/png\",\n"; + $tmp .= " \".xbm\" => \"image/x-xbitmap\",\n"; + $tmp .= " \".xpm\" => \"image/x-xpixmap\",\n"; + $tmp .= " \".xwd\" => \"image/x-xwindowdump\",\n"; + $tmp .= " \".css\" => \"text/css\",\n"; + $tmp .= " \".html\" => \"text/html\",\n"; + $tmp .= " \".htm\" => \"text/html\",\n"; + $tmp .= " \".js\" => \"text/javascript\",\n"; + $tmp .= " \".asc\" => \"text/plain\",\n"; + $tmp .= " \".c\" => \"text/plain\",\n"; + $tmp .= " \".conf\" => \"text/plain\",\n"; + $tmp .= " \".text\" => \"text/plain\",\n"; + $tmp .= " \".txt\" => \"text/plain\",\n"; + $tmp .= " \".dtd\" => \"text/xml\",\n"; + $tmp .= " \".xml\" => \"text/xml\",\n"; + $tmp .= " \".mpeg\" => \"video/mpeg\",\n"; + $tmp .= " \".mpg\" => \"video/mpeg\",\n"; + $tmp .= " \".mov\" => \"video/quicktime\",\n"; + $tmp .= " \".qt\" => \"video/quicktime\",\n"; + $tmp .= " \".avi\" => \"video/x-msvideo\",\n"; + $tmp .= " \".asf\" => \"video/x-ms-asf\",\n"; + $tmp .= " \".asx\" => \"video/x-ms-asf\",\n"; + $tmp .= " \".wmv\" => \"video/x-ms-wmv\",\n"; + $tmp .= " \".bz2\" => \"application/x-bzip\",\n"; + $tmp .= " \".tbz\" => \"application/x-bzip-compressed-tar\",\n"; + $tmp .= " \".tar.bz2\" => \"application/x-bzip-compressed-tar\"\n"; + $tmp .= " )\n"; $tmp .= "\n"; + $tmp .= "# Use the \"Content-Type\" extended attribute to obtain mime type if possible\n"; + $tmp .= "#mimetypes.use-xattr = \"enable\"\n"; $tmp .= "\n"; - $tmp .= "//\$msg = \"1.begin loop. \".date('r').\"\\n\";\n"; - $tmp .= "//\$fp = fopen('/tmp/phpmonitor.txt', 'a');\n"; - $tmp .= "//fwrite(\$fp, \$msg.\"\\n\");\n"; - $tmp .= "//fclose(\$fp);\n"; + $tmp .= "#### accesslog module\n"; + $tmp .= "#accesslog.filename = \"/dev/null\"\n"; $tmp .= "\n"; - $tmp .= "\$x = 0;\n"; - $tmp .= "while(\$x == 0) {\n"; + $tmp .= "## deny access the file-extensions\n"; + $tmp .= "#\n"; + $tmp .= "# ~ is for backupfiles from vi, emacs, joe, ...\n"; + $tmp .= "# .inc is often used for code includes which should in general not be part\n"; + $tmp .= "# of the document-root\n"; + $tmp .= "url.access-deny = ( \"~\", \".db\" )\n"; $tmp .= "\n"; $tmp .= "\n"; - $tmp .= " if(!file_exists('/tmp/phpmonitor.pid')) {\n"; - $tmp .= " //if the file does not exist then close the program.\n"; - $tmp .= " echo \"program closing\\n\";\n"; - $tmp .= " return;\n"; - $tmp .= " }\n"; + $tmp .= "######### Options that are good to be but not neccesary to be changed #######\n"; $tmp .= "\n"; + $tmp .= "## bind to port (default: 80)\n"; + $tmp .= "server.port = 8001\n"; $tmp .= "\n"; + $tmp .= "#the regex method isn't working\n"; + $tmp .= "#\$HTTP[\"host\"] =~ \"(^|\\.)host01\\.com\$\" {\n"; + $tmp .= "# server.document-root = \"/usr/local/vhosts/host01\"\n"; + $tmp .= "#}\n"; $tmp .= "\n"; - - foreach($config['installedpackages']['vhosts']['config'] as $rowhelper) { + + $vhostarray = $config['installedpackages']['vhosts']['config']; + if (count(vhostarray) > 1) { + usort($vhostarray, 'sort_ipaddress'); + usort($vhostarray, 'sort_host'); + usort($vhostarray, 'sort_port'); + } + $ipaddress_previous_value = ''; + $host_previous_value = ''; + $port_previous_value = ''; + $ipaddress_and_port_previous_value = ''; + $x=1; + foreach($vhostarray as $rowhelper) { if ($rowhelper['enabled'] != "false") { - $tmp_php = base64_decode($rowhelper['php']); - if (strlen($tmp_php) > 0) { - $tmp .= "// name: ".$rowhelper['name']." \n"; - $tmp .= "// description: ".$rowhelper['description']." \n\n"; - $tmp .= base64_decode($rowhelper['php']); - $tmp .= "\n"; + + $host = $rowhelper['host']; + $ipaddress = $rowhelper['ipaddress']; + $port = $rowhelper['port']; + $directory = $rowhelper['directory']; + if (strlen($rowhelper['certificate']) > 0) { + $certificate = base64_decode($rowhelper['certificate']); } - } + if (strlen($rowhelper['privatekey']) > 0) { + $privatekey = base64_decode($rowhelper['privatekey']); + } + + //set directory default to the host + if (strlen($directory) == 0) { $directory = $host; } + + //if the vhost directory doesn't exist then create it + //echo '/usr/local/vhosts/'.$directory.'
'; + if (!is_dir('/usr/local/vhosts/'.$directory)) { + exec("mkdir /usr/local/vhosts/".$directory); + } + + //set the default port + if (strlen($port) == 0) { $port = '8001'; } + if ($ipaddress.':'.$port != $ipaddress_and_port_previous_value) { + if ($x > 1) { $tmp .= "}\n\n"; } + $tmp .= "\$SERVER[\"socket\"] == \"".$ipaddress.":".$port."\" {\n"; + } + + if (strlen($rowhelper['description']) > 0) { + $tmp .= "# ".$rowhelper['description']." \n\n"; + } + $tmp .= " \$HTTP[\"host\"] == \"".$host."\" {\n"; + $tmp .= " server.document-root = \"/usr/local/vhosts/".$directory."\"\n"; + + //enable ssl if the cert and key were both provided + if (strlen($rowhelper['certificate']) > 0 && strlen($rowhelper['privatekey']) > 0) { + $pem_file = "/var/etc/cert-vhosts-".$ipaddress."-".$port.".pem"; + $fout = fopen($pem_file,"w"); + fwrite($fout, $certificate.$privatekey); + fclose($fout); + $tmp .= " ssl.pemfile = \"".$pem_file."\"\n"; + $tmp .= " ssl.engine = \"enable\"\n"; + unset($pem_file); + } + if (count(vhostarray) > 0) { + $tmp .= " }\n"; + } + + $ipaddress_previous_value = $ipaddress; + $host_previous_value = $host; + $port_previous_value = $port; + $ipaddress_and_port_previous_value = $ipaddress.':'.$port; + $x++; + } } + $tmp .= "}\n"; + + /* + $tmp .= "\$SERVER[\"socket\"] == \"10.7.0.1:8001\" {\n"; + $tmp .= " \$HTTP[\"host\"] == \"vhost01.com\" {\n"; + $tmp .= " #ssl.pemfile = \"/var/www/certs/localhost.pem\"\n"; + $tmp .= " #ssl.engine = \"enable\"\n"; + $tmp .= " server.document-root = \"/usr/local/vhosts/host01\"\n"; + $tmp .= " #server.errorlog = \"/var/log/lighttpd/nixcraft/error.log\"\n"; + $tmp .= " #accesslog.filename = \"/var/log/lighttpd/nixcraft/access.log\"\n"; + $tmp .= " #server.error-handler-404 = \"/e404.php\"\n"; + $tmp .= " }\n"; $tmp .= "\n"; + $tmp .= " \$HTTP[\"host\"] == \"vhost03.com\" {\n"; + $tmp .= " #ssl.pemfile = \"/var/www/certs/localhost.pem\"\n"; + $tmp .= " #ssl.engine = \"enable\"\n"; + $tmp .= " server.document-root = \"/usr/local/vhosts/host03\"\n"; + $tmp .= " #server.errorlog = \"/var/log/lighttpd/nixcraft/error.log\"\n"; + $tmp .= " #accesslog.filename = \"/var/log/lighttpd/nixcraft/access.log\"\n"; + $tmp .= " #server.error-handler-404 = \"/e404.php\"\n"; + $tmp .= " }\n"; + $tmp .= "}\n"; + $tmp .= "\n"; + $tmp .= "\$SERVER[\"socket\"] == \"10.7.0.1:8002\" {\n"; + $tmp .= " \$HTTP[\"host\"] == \"vhost02.com\" {\n"; + $tmp .= " #ssl.pemfile = \"/var/www/certs/localhost.pem\"\n"; + $tmp .= " #ssl.engine = \"enable\"\n"; + $tmp .= " server.document-root = \"/usr/local/vhosts/host02\"\n"; + $tmp .= " #server.errorlog = \"/var/log/lighttpd/nixcraft/error.log\"\n"; + $tmp .= " #accesslog.filename = \"/var/log/lighttpd/nixcraft/access.log\"\n"; + $tmp .= " #server.error-handler-404 = \"/e404.php\"\n"; + $tmp .= " }\n"; + $tmp .= "}\n"; + */ $tmp .= "\n"; - $tmp .= " //usleep(100000); //micro seconds //2 seconds 2000000\n"; - $tmp .= " sleep(1); //in seconds\n"; - $tmp .= " //if (\$x > 60){ exit; } //exit after 60 seconds for testing\n"; - $tmp .= "} //emd while\n"; + $tmp .= "## error-handler for status 404\n"; + $tmp .= "#server.error-handler-404 = \"/error-handler.html\"\n"; + $tmp .= "#server.error-handler-404 = \"/error-handler.php\"\n"; $tmp .= "\n"; + $tmp .= "## to help the rc.scripts\n"; + $tmp .= "server.pid-file = \"/var/run/lighty-vhosts.pid\"\n"; $tmp .= "\n"; - $tmp .= "?>"; + $tmp .= "## virtual directory listings\n"; + $tmp .= "server.dir-listing = \"disable\"\n"; + $tmp .= "\n"; + $tmp .= "## enable debugging\n"; + $tmp .= "debug.log-request-header = \"disable\"\n"; + $tmp .= "debug.log-response-header = \"disable\"\n"; + $tmp .= "debug.log-request-handling = \"disable\"\n"; + $tmp .= "debug.log-file-not-found = \"disable\"\n"; + $tmp .= "\n"; + $tmp .= "#### compress module\n"; + $tmp .= "#compress.cache-dir = \"/tmp/lighttpd/cache/compress/\"\n"; + $tmp .= "#compress.filetype = (\"text/plain\", \"text/html\")\n"; + $tmp .= "\n"; + $tmp .= "#server.network-backend = \"writev\"\n"; + $tmp .= "server.upload-dirs = ( \"/root/\", \"/tmp/\", \"/var/\" )\n"; + $tmp .= "server.max-request-size = 2097152\n"; + $tmp .= "\n"; + $tmp .= "#### fastcgi module\n"; + $tmp .= "## read fastcgi.txt for more info\n"; + $tmp .= "fastcgi.server = ( \".php\" =>\n"; + $tmp .= " ( \"localhost\" =>\n"; + $tmp .= " (\n"; + $tmp .= " \"socket\" => \"/tmp/php5-fastcgi.socket\",\n"; + $tmp .= " \"min-procs\" => 1,\n"; + $tmp .= " \"max-procs\" => 1,\n"; + $tmp .= " \"idle-timeout\" => 0,\n"; + $tmp .= " \"bin-environment\" => (\n"; + $tmp .= " \"PHP_FCGI_MAX_REQUESTS\" => \"500\",\n"; + $tmp .= " \"PHP_FCGI_CHILDREN\" => \"1\"\n"; + $tmp .= " ),\n"; + $tmp .= " \"bin-path\" => \"/usr/local/php5/php-cgi\"\n"; + $tmp .= " )\n"; + $tmp .= " )\n"; + $tmp .= ")\n"; + $tmp .= "\n"; + $tmp .= "#### CGI module\n"; + $tmp .= "cgi.assign = ( \".cgi\" => \"\" )\n"; - $fout = fopen("/usr/local/pkg/vhosts.php","w"); + $fout = fopen("/var/etc/lighty-vhosts.conf","w"); fwrite($fout, $tmp); unset($tmp); fclose($fout); - + conf_mount_ro(); - } + } } -function php_sync_package() -{ - +function php_sync_package() { global $config; vhosts_sync_package_php(); - } - -function php_install_command() -{ + +function php_install_command() { global $config; conf_mount_rw(); config_lock(); if (!is_dir('/usr/local/www/packages/')) { - exec("mkdir /usr/local/www/packages/"); + exec("mkdir /usr/local/www/packages/"); } - + if (!is_dir('/usr/local/www/packages/vhosts/')) { - exec("mkdir /usr/local/www/packages/vhosts/"); + exec("mkdir /usr/local/www/packages/vhosts/"); + } + + if (!is_dir('/usr/local/vhosts/')) { + exec("mkdir /usr/local/vhosts/"); } //rename PHP files from .tmp to .php @@ -184,8 +401,12 @@ function php_install_command() exec("cp /tmp/vhosts_php_edit.tmp /usr/local/www/packages/vhosts/vhosts_php_edit.php"); unlink_if_exists("/tmp/vhosts_php_edit.tmp"); + exec("cp /tmp/system_advanced_create_certs.tmp /usr/local/www/packages/vhosts/system_advanced_create_certs.php"); + unlink_if_exists("/tmp/system_advanced_create_certs.tmp"); + //extract php5 - exec("cp /tmp/vhosts_php_edit.tmp /usr/local/www/packages/vhosts/vhosts_php_edit.php"); + chdir('/tmp'); + exec("tar zxvf /tmp/php5.tar.gz -C /usr/local/"); unlink_if_exists("/tmp/php5.tar.gz"); //write_config(); @@ -193,14 +414,13 @@ function php_install_command() write_rcfile(array( "file" => "vhosts.sh", "start" => "/usr/local/sbin/lighttpd -f /var/etc/lighty-vhosts.conf", - "stop" => "rm /tmp/phpmonitor.pid" + "stop" => "kill `cat /var/run/lighty-vhosts.pid`" ) ); php_sync_package(); - //$handle = popen("/usr/local/etc/rc.d/vhosts.sh start", "r"); - //pclose($handle); - + + //if (pkg_is_service_running('vhosts')) { //documentation purposes //} diff --git a/config/vhosts/vhosts.xml b/config/vhosts/vhosts.xml index cbb01582..b3903470 100644 --- a/config/vhosts/vhosts.xml +++ b/config/vhosts/vhosts.xml @@ -37,25 +37,25 @@ /* ========================================================================== */ ]]> - PHP Service + vHosts Describe your package requirements here Currently there are no FAQ items provided. vHosts Settings - 0.1 + 0.2 Settings /usr/local/pkg/vhosts.inc - vhosts + vHosts vHosts Service settings.
Services
vhosts.xml /packages/vhosts/vhosts_php.php
- vhosts + vHosts vhosts.sh vhosts - Lighttpd web server service. + LigHTTPD web server service. Uses PHP5 with fast cgi. @@ -95,6 +95,11 @@ 0755 http://www.pfsense.com/packages/config/vhosts/lighty-vhosts.conf + + /var/etc/ + 0755 + http://www.pfsense.com/packages/config/vhosts/system_advanced_create_certs.tmp + /tmp/ 0755 diff --git a/config/vhosts/vhosts_php.tmp b/config/vhosts/vhosts_php.tmp index c77d50a3..41ccf11f 100644 --- a/config/vhosts/vhosts_php.tmp +++ b/config/vhosts/vhosts_php.tmp @@ -51,7 +51,7 @@ include("head.inc"); -

vHosts Service:

+

vHosts:

@@ -88,8 +88,7 @@ include("head.inc");
@@ -99,7 +98,7 @@ include("head.inc");

- Is command line PHP designed to run PHP as a Service. The custom PHP code that is defined below is run over and over again inside a continuous loop. There are many possible uses such as monitoring CPU, Memory, File System Space, interacting with Snort, and many others uses that are yet to be discovered. - It can send events to the sylog that will can be viewed from the system log or remote syslog server. example: exec("logger This is a test"); + vHosts is a web server package that can host HTML, Javascript, CSS, and PHP. It uses the lighttpd web server that is already installed. It uses PHP5 in FastCGI mode and has access to PHP Data Ojbects and PDO SQLite.

For more information see: http://doc.pfsense.org/index.php/vhosts

- + - 0) { - - foreach ($a_vhosts as $ent) { - - ?> - - - - - - - 1) { + // usort($a_vhosts, 'sort_host'); + //} + foreach ($a_vhosts as $ent) { + $host = $ent['host']; + $port = $ent['port']; + if (strlen($ent['certificate']) == 0) { $http_protocol = 'http'; } else { $http_protocol = 'https'; } + if ($http_protocol == 'http' && $port == '80') { $port = ''; } + if ($http_protocol == 'https' && $port == '443') { $port = ''; } + if (strlen($port) > 0) { $port = ':'.$port; } + $vhost_url = $http_protocol.'://'.$host.$port; + ?> + + + + + + + diff --git a/config/vhosts/vhosts_php_edit.tmp b/config/vhosts/vhosts_php_edit.tmp index db3235d6..3e5c477c 100644 --- a/config/vhosts/vhosts_php_edit.tmp +++ b/config/vhosts/vhosts_php_edit.tmp @@ -31,7 +31,6 @@ require("guiconfig.inc"); require("/usr/local/pkg/vhosts.inc"); - $a_vhosts = &$config['installedpackages']['vhosts']['config']; $id = $_GET['id']; @@ -52,13 +51,18 @@ if ($_GET['act'] == "del") { } if (isset($id) && $a_vhosts[$id]) { - $pconfig['name'] = $a_vhosts[$id]['name']; $pconfig['host'] = $a_vhosts[$id]['host']; $pconfig['ipaddress'] = $a_vhosts[$id]['ipaddress']; $pconfig['port'] = $a_vhosts[$id]['port']; + $pconfig['directory'] = $a_vhosts[$id]['directory']; + if (strlen($a_vhosts[$id]['certificate']) > 0) { + $pconfig['certificate'] = base64_decode($a_vhosts[$id]['certificate']); + } + if (strlen($a_vhosts[$id]['privatekey']) > 0) { + $pconfig['privatekey'] = base64_decode($a_vhosts[$id]['privatekey']); + } $pconfig['enabled'] = $a_vhosts[$id]['enabled']; $pconfig['description'] = $a_vhosts[$id]['description']; - } if ($_POST) { @@ -69,10 +73,23 @@ if ($_POST) { if (!$input_errors) { $ent = array(); - $ent['name'] = $_POST['name']; $ent['host'] = $_POST['host']; $ent['ipaddress'] = $_POST['ipaddress']; $ent['port'] = $_POST['port']; + $ent['directory'] = $_POST['directory']; + + if (strlen($_POST['certificate']) > 0) { + $ent['certificate'] = base64_encode($_POST['certificate']); + } + else { + $ent['certificate'] = ''; + } + if (strlen($_POST['privatekey']) > 0) { + $ent['privatekey'] = base64_encode($_POST['privatekey']); + } + else { + $ent['privatekey'] = ''; + } $ent['enabled'] = $_POST['enabled']; $ent['description'] = $_POST['description']; @@ -104,10 +121,19 @@ function show_advanced_config() { aodiv = document.getElementById('showadvanced'); aodiv.style.display = "block"; - - + + -

PHP Service: Edit

+

vHosts: Edit

@@ -124,8 +150,8 @@ function show_advanced_config() {
NameHost Enabled Description @@ -114,37 +113,49 @@ include("head.inc");
-   - -   - -   - - - - - - -
-
+   + +   + +   + + + + + + +
+
- - + - - + + - - + + - - + +
+
Enabled + Enabled \n"; echo " \n"; @@ -191,37 +245,37 @@ function show_advanced_config() { } echo " \n"; ?> -
Description - -
Enter the description here.
-
Description + +
Enter the description here.
+
  - - - - -   + + + + +
-
-
-
-
-
-
+
+
+
+
+
+
- - + +
diff --git a/pkg_config.7.xml b/pkg_config.7.xml index 3ac0c1c4..ee2b1f92 100755 --- a/pkg_config.7.xml +++ b/pkg_config.7.xml @@ -292,13 +292,13 @@ vHosts - Web server package that can host html, javascript, php files. It uses the lighttpd web server that is already installed. Supports PHP5, PHP PDO and PDO SQLite. + It is a web server package that can host HTML, Javascript, CSS, and PHP. It uses the lighttpd web server that is already installed. It uses PHP5 in FastCGI mode and has access to PHP Data Ojbects and PDO SQLite. Services http://doc.pfsense.org/index.php/vhosts http://www.pfsense.com/packages/config/vhosts/vhosts.xml http://files.pfsense.org/packages/7/All/ - 0.1 - Alpha + 0.2 + Beta 1.2.3 markjcrane@gmail.com vhosts.xml -- cgit v1.2.3