Вы находитесь на странице: 1из 30

IMPORTANT!!!

ARTICOLUL WEB SERVERA APPCAHE POD


WINDOWA__PHP_MYSQL.DOC

:
PHP
invatarea cum sa utilizam serverul MySQL,
Web- ,
.. ,
.
Apache+PHP+MySQL
.

Apache PHP
.
UNIX Windows -
. UNIX
"/", /usr/bin/perl, Windows ,
, c:Apachein. , Apache
PHP : (/)
(), Apache PHP UNIX, "" ,
.
(httpd.conf php.ini)
UNIX "/". :
ScriptAlias "/php_dir/" "c:/php/"
Apache
Web-

.
().
Apache
httpd.conf conf.
httpd.conf
.

Apache PHP
.
UNIX Windows -
. UNIX

"/", /usr/bin/perl, Windows , ,


c:Apachein. , Apache PHP
: (/)
(), Apache PHP UNIX, "" ,
.
(httpd.conf php.ini)
UNIX "/". :
ScriptAlias "/php_dir/" "c:/php/"
httpd.conf
Port
Port 80
TCP, Apache
. 80 .


.
, , 8080
, :
http://localhost:8080/.
ServerAdmin
ServerAdmin mymail@yandex.ru
e-mail- web-,
.
ServerName
ServerName myserver
.
ServerRoot
ServerRoot "C:/Apache2"
, WEB- Apache.

ServerRoot DocumentRoot,
WEB-.
DocumentRoot
DocumentRoot "C:/Apache2/htdocs"
, WEB-.
<Directory />


DocumentRoot.

<Directory />
Options FollowSymLinks Includes Indexes
AllowOverride All
</Directory>
AllowOverride All

httpd.conf .htaccess.
Options FollowSymLinks Apache
.
Options Includes
SSI (Server Side Includes) web-.
Options Indexes ,
,
.
DirectoryIndex
DirectoryIndex index.html index.phtml index.php
,

(, http://localhost/test/).
AddDefaultCharset
AddDefaultCharset windows-1251
,
HTML-.
KOI8-R.

WEB- Apache WEB. .
.

httpd.conf.
IP-
.
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
#
</VirtualHost>
<VirtualHost>,
.
httpd.conf. <VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerAdmin webmaster@may_domain.ru
DocumentRoot c:/www/mysite

ServerName www.mysite.ru
ServerAlias www.site.ru www.host2.ru
ErrorLog logs/mysite-error.log
CustomLog logs/mysite-access.log common
</VirtualHost>
:
DocumentRoot ,
() (WEB-)
ServerName ,
. ,
http://www.mysite.ru/.
ServerAlias .
,
: http://www.site.ru/ http://www.host2.ru/.
ErrorLog CustomLog
.

httpd.conf.
httpd.conf.
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
# 1
</VirtualHost>
<VirtualHost 127.0.0.1:80>
# 2
</VirtualHost>
<VirtualHost 127.0.0.1:80>
# 3
</VirtualHost>

, httpd.conf,
Apache .
,
DNS-.
Apache
,
hosts. Windows 2000 XP
C:Window\System32\Driversets. hosts
:
hosts

127.0.0.1
127.0.0.1
127.0.0.1

www.mysite.ru
www.site.ru
www.host2.ru

PHP
PHP c:/php
zip- .
php.ini-dist php.ini
Windows.
, Web-
PHP. PHP
:
Apache
CGI-.
.
PHP
PHP
, PHP
Web-

PHP php.ini
Web-.
php.ini Apache
, .
PHP
Apache httpd.conf
,
:
httpd.conf. PHP Apache
AddType application/x-httpd-php phtml php
LoadModule php5_module c:/php/php5apache2.dll

c:/php
PHP.
PHP, CGI-
PHP, CGI- PHP
PHP-.
, , . PHP
, CGI, php.ini
Apache ,

PHP-. PHP
CGI PHP,
WEB-.

PHP, CGI
, ,
PHP.
Apache
.htaccess.
PHP
httpd.conf ,
PHP
:
httpd.conf. PHP CGI
AddType application/x-httpd-php phtml php
<Directory "c:/php">
Options ExecCGI
</Directory>
ScriptAlias "/php_dir/" "c:/php/"
Action application/x-httpd-php "/php_dir/php-cgi.exe"

c:/php
PHP.
PHP ( php.ini)
, ,
Web-,
php.ini.
error_reporting
:
error_reporting = E_ALL & ~E_NOTICE
PHP , PHP , ""
. ,
display_errors, :
display_errors = On
(Off),


.

, variables_order
:
variables_order = "EGPCS"
:
E -
G - GET (G)
P - POST (P)
C - Cookies
S -
-
.
,
register_globals.
register_globals = On
GET, POST, cookies
PHP-,
$someone.

register_globals = Off

($_POST, $_GET ..).
register_long_arrays
("" $HTTP_GET_VARS, $HTTP_POST_VARS ..)
register_long_arrays = On
.
http://localhost/,
http://localhost/index.html.
index.html,
,
. http.conf, ,
Web- Apache
index.php. httpd.conf
DirectoryIndex :
DirectoryIndex index.html index.html.var index.php
Apache,
("C:/www/scripts")
PHP (index.php):
<?php
phpinfo();
?>

,
http://localhost/index.php
PHP,
phpinfo().
, Apache PHP
MySQL
MySQL
PHP MySQL
: " PHP
MySQL".
MySQL ,
PHP
MySQL.
php.ini Windows.
MySQL
;( ) :
extension=php_mysql.dll
extension_dir
extension_dir ="c:/php-5.0/ext"
, PHP.
UNIX (/)
. , ,
extension_dir,
php_mysql.dll C:/php-5.0/
- .
PHP ,
libmysql.dll
PHP
C:/Windows/System32.
Apache.
MySQL Apache
:
<?php
$dblocation = "127.0.0.1";
$dbname = "test";
$dbuser = "root";
$dbpasswd = "";
$dbcnx = @mysql_connect($dblocation, $dbuser, $dbpasswd);
if (!$dbcnx)

{
echo "<p> , mySQL</p>";
exit();
}
if (!@mysql_select_db($dbname,$dbcnx) )
{
echo "<p> , </p>";
exit();
}
$ver = mysql_query("SELECT VERSION()");
if(!$ver)
{
echo "<p> </p>";
exit();
}
echo mysql_result($ver, 0);
?>
MySQL Apache PHP,

MySQL.
MySQL ( 4.1.0)
,

'????????' . ,
PHP-,
, :
<?php
mysql_query ("set character_set_client='cp1251'");
mysql_query ("set character_set_results='cp1251'");
mysql_query ("set collation_connection='cp1251_general_ci'");
?>
PHP

PHP, MySQL.
,
GDLib php.ini :
extension=php_gd2.dll

c:phpext. php.ini
. :
phpinfo(). , ,

phpinfo(),
"gd". GDLib2
.
PHP "Mcrypt
Encryption",
, ,
php.ini
extension=php_mcrypt.dll
:/WINDOWS/
libmcrypt.dll

Internal Server Error PHP
, PHP
httpd.conf.
httpd.conf. PHP CGI
AddType application/x-httpd-php phtml php
<Directory "c:/php">
Options ExecCGI
</Directory>
ScriptAlias "/php_dir/" "c:/php/"
Action application/x-httpd-php "/php_dir/php-cgi.exe"
: phpcgi.exe. , httpd.conf,
Apache .
php.exe,
php-cgi.exe
:
403 Forbidden You don't have permission to access /__php_dir__/ph
p.exe/test.php on this server
HTML- , PHP-
PHP
php, : http:/localohost/index.php

.
,
php. httpd.conf
:
AddType application/x-httpd-php phtml php
Notice: Undefined variable...
, , PHP
:
Notice: Undefined variable: msg in C:/Main/addrec.php on line 7
,
.
php.ini.
error_reporting :
error_reporting = E_ALL & ~E_NOTICE
MySQL
MySQL.
MySQL
.
:
| | |
|
MySQL - .

"" -
" " "".
Apache

php_mysql.dll.
PHP startup: Unable to load dynamic library c:/php/ext/php_
mysql.dll -
,
PHP MySQL.
"" php_mysql.dll (

PHP, )?
php_mysql.dll
PHP, .
libmysql.dll
PHP C:/Windows/System32?

,
MySQL+PHP:
www.softtime.ru/forum/read.php?id_forum=1&id_theme=455,
www.softtime.ru/forum/read.php?id_forum=1&id_theme=195
www.softtime.ru/forum/read.php?id_forum=1&id_theme=287
mysql.exe:
www.softtime.ru/forum/read.php?id_forum=1&id_theme=354

Apache, PHP MySQL ,
:

httpd.conf php.ini.

.
, .
Windows
( ): c:apache/bin.
UNIX ( ),
: c:/apache/bin.
php.ini
, . php.ini
Windows.
,
.
Apache+PHP+MySQL

Apache, PHP
http://www.softtime.ru/forum/index.php?id_forum=5

ARTICOLUL LEARN HOW TO INSTALL APACHE_LAST.DOC


Este articolul de baza!!!
ARTICOLUL HOW TO SET UP APACHE. DOC
Step 3 - Install Php
Let it install in the default folder C:\PHP\ Just click "Next".
Now, since the php installer did not automatically configure apache to
use php, we will do it manually.
Edit the Apache httpd.conf Configuration File. Go to: Start ->
Programs -> Apache HTTP Server -> Configure Apache Server
-> Edit the Apache httpd.conf Configuration File
Now add the following lines to the bottom of the httpd.conf file: (Be
sure to change C:\PHP to the folder where you installed to, if you
installed somewhere else.)
Add this if you installed php4
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php.exe"
Or add this if you installed php5
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi.exe"
Now, if you specified another directory other than C:\PHP for the
installation, Specify it here. Add this as the fourth line, changing
C:\PHP to the directory where you installed Php.
SetEnv PHPRC C:/php
Now, the last thing to change in the configuration file is to add the
index.php as a valid default document to serve if the user requests a
directory. To do this use the (CONTROL + F) Find function of Notepad
to find the line that looks like the following:
DirectoryIndex index.html index.html.var
Add a space and index.php to the end of this line so it looks like this:
DirectoryIndex index.html index.html.var index.php
Wait! You're not done yet. After adding the above lines to
httpd.conf,
Save the file (File -> Save), close it and Restart Apache for this
to have any effect.
To Restart Apache, Double-click on the Apache icon in the system
tray and click "Restart" or Or look in the programs menu and click
Restart Apache Start -> Programs -> Apache HTTP Server -> Control
Apache Server -> Restart.

Let's check and see if Apache and Php are getting along
Go to C:\Program Files\Apache Group\Apache2\htdocs\ and
create a new file called phpinfo.php that contains the following
code:
<?php
echo phpinfo();
?>
Now you go to localhost/phpinfo.php (or
localhost:8080/phpinfo.php) in your web browser. You should see a
whole lot of information about the Php installation. If you don't see
see anything, something must have gone wrong in the setup.
If you want you can add a link to the php info from you new main
page above. The new code would look like this:
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<a href="apache">Apache "It Worked" Page<a><br />
<a href="phpinfo.php">Information about
Php<a><br />
</body>
</html>
Step 5 - Install PhpMyAdmin
After unzipping, look for the file called config.inc.php, open it and
look for the following lines:
$cfg['PmaAbsoluteUri'] = '';
$cfg['blowfish_secret'] = '';
$cfg['Servers'][$i]['auth_type']
= 'config'; //
Authentication method (config, http or cookie based)?
Change the three lines above to:
$cfg['PmaAbsoluteUri'] = 'http://localhost/pma'; // This
can be something other than pma if you want.

$cfg['blowfish_secret'] = 'mycatisblue';
// Any phrase
you want will do (it's for encrypting your password)
$cfg['Servers'][$i]['auth_type']
= 'cookie'; //
Authentication method (config, http or cookie based)?
Now save and close the file
Now create a new folder in your Apache Document root called pma
(The document root would be C:\Program Files\Apache
Group\Apache2\htdocs\ unless you have changed it) In the previous
step, if you used another folder name instead of pma, create that
folder instead.
Move all the files, scripts and folders that you unzipped (including the
newly-modified config.inc.php) to the pma folder that you just
created.
ARTICOLUL PHP
MYSQL.DOC
,
PHP
MySQL.
CUM AU FOST REALIZATE CELELALTE MOMENTE VEZI
Apache2.2 PHP-5.1.4
Apache, PHP, MySQL
1. , MySQL
( php_mysql.dll) PHP
.

php.ini
c:/windows/system32.
2. PHP (Apache) php.ini (
Apache 2.x)
Apache 2 ,
Apache (httpd.conf)
PHPIniDir,
php.ini.
Apache ,
.
PHPIniDir c:/php

,
/, Windows,
\\. , Apache PHP
unix-,
.
-
Apache PHP
unix-.
,
php.ini c:/php.
, Apache
php.ini phpinfo().
PHP
<?php
echo phpinfo();
?>

Configuration File (php.ini) Path.
php.ini, .
, ,
Apache php.ini.
C:/php/php.ini
// php.ini

C:/windows/
// php.ini
, , Apache
php.ini
MySQL
3. PHP.INI extension_dir
extension_dir ,
php,
php_mysql.dll. php
c:/php, , ,
ext (c:/php/ext).

extension_dir.
extension_dir = "c:/php/ext"
4. MySQL
php.ini :
;extension=php_mysql.dll
.
extension=php_mysql.dll

5. libmysql.dll
c:/windows
PHP Apache ,
MySQL
libmysql.dll c:/php
c:/windows/system32. php
Apache, CGI-,
.
6. Apache

Apache.
7.
, MySQL
PHP phpinfo().

MySQL. , ,
.
PHP C MYSQL
1. MySQL.
, PHP c
MySQL , MySQL .
, Windows: |
CONTROL PANEL | |
ADMINISTRATION TOOLS SERVISES.
MySQL ,
( ).
, MySQL :
Crtl + Alt + Del
mysqld.exe. mysqld.exe
: mysqld-nt.exe, mysqld-max-nt.exe,
mysqld-debug.exe.
2. php-
PHP-, PHP
MySQL
<?php
$dblocation = "127.0.0.1";
$dbname = "test";
$dbuser = "root";
$dbpasswd = "";

$dbcnx = mysql_connect($dblocation, $dbuser, $dbpasswd);


if (!$dbcnx)
{
echo "<p> , mySQL</p>";
exit();
}
if (!mysql_select_db($dbname,$dbcnx) )
{
echo "<p> , </p>";
exit();
}
$ver = mysql_query("SELECT VERSION()");
if(!$ver)
{
echo "<p> </p>";
exit();
}
echo mysql_result($ver, 0);
?>
,
MySQL. ,
.
MySQL
: Call to undefined function
Call to undefined function
, PHP.
MySQL, ,
PHP MySQL
php_mysql.dll
:
Fatal error: Call to undefined function mysql_connect()
in C:\www\panel\htdocs\test.php on line 7
.
MySQL phpinfo()
, MySQL
MySQL
phpinfo(),
libmysql.dll, c:/windows/system32.
1. libmysql.dll,
c:/windows/system32 ,
PHP. .

2. libmysql.dll c:/windows
.
,
c:/php.

libmysql.dll
MySQL. ,
c:/windows/system32
MySQL, PHP
. libmysql.dll
c:/windows/system32
MySQL.
PHP .

PHP c MySQL
,
. php-,
, @
mysql_connect() mysql_select_db().
.

,
, ..
.
PHP-, PHP
MySQL
<?php
$dblocation = "127.0.0.1";
$dbname = "test";
$dbuser = "root";
$dbpasswd = "";
$dbcnx = @mysql_connect($dblocation, $dbuser, $dbpasswd);
if (!$dbcnx)
{
echo "<p> , mySQL</p>";
exit();
}
if (!@mysql_select_db($dbname,$dbcnx) )
{
echo "<p> , </p>";

exit();
}
$ver = mysql_query("SELECT VERSION()");
if(!$ver)
{
echo "<p> </p>";
exit();
}
echo mysql_result($ver, 0);
?>

, , , , PHP
php_mysql.dll.
.
1. , PHP-,
MySQL.
2. @ mysql_connect
mysql_select,
.
,
.
: Can't connect to MySQL server on '127.0.0.1'
(10061)
php-
:
Warning: mysql_connect() [function.mysql-connect]:
Can't connect to MySQL server on '127.0.0.1' (10061)
in C:\www\panel\htdocs\test.php on line 7
,
MySQL.
1 PHP c MySQL.
: Access denied for user 'root'@'localhost' (using
password: YES)
:
Warning: mysql_connect() [function.mysql-connect]:
Access denied for user 'root'@'localhost' (using password: YES)
in C:\www\panel\htdocs\test.php on line 7
,
MySQL c .
$dbpasswd .
MySQL
root. root

, $dbpasswd
.
PHP

Apache, PHP
http://www.softtime.ru/forum/index.php?id_forum=5 .
ARTICOLUL APACHE 2.DOC
httpd.conf,
:
"C:\USR\Apache2\conf\httpd.conf".
"DirectoryIndex index.html index.html.var",
"DirectoryIndex index.html index.htm index.html.var
index.pl index.cgi index.shtm index.shtml".
, .
"index.php index.php4",
PHP .
"AddDefaultCharset ISO-8859-1",
"AddDefaultCharset WINDOWS-1251".
. ,
Win-1251 , , .
"#AddType text/html .shtml", "AddType
text/html .shtm .shtml .htm .html". mime
html . ,
, .
"#AddOutputFilter INCLUDES .shtml",
"AddOutputFilter INCLUDES .shtml .shtm .htm .html .sht".

SSI.
, "<Directory />"
"</Directory>".
:
<Directory />
Options Indexes Includes
AllowOverride All
</Directory>

"<Directory ":/usr/apache/htdocs">
</Directory>".
, .
:
<Directory ":/usr/apache/htdocs">
Options Indexes Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
, Unix
.
"<Directory "D:/USR/apache/cgi-bin">
</Directory>" :
<Directory "D:/USR/apache/cgi-bin">
AllowOverride All
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
, "#AddHandler cgi-script .cgi"
"AddHandler cgi-script .cgi .pl .bat".
.
, , .
"Notepad" (""),
,
Perl SSI.
.
.
,
Perl.

-
(C:\Perl, ) installer.bat .
,
- C:\USR. Perl
, Unix-,
! ,
, "y" (Yes).
Perl 3-5 .
"Press return to exit". Enter,
.
Perl
: "C:\USR\BIN\perl.exe".
, Perl .
Perl.
test.pl, Perl :
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "It works!";
, ,
, ..
Perl . ,
.
"C:\USR\apache2\cgi-bin\".
URL
"http://localhost/cgi-bin/test.pl". "It
works!", Perl . "Internal
Server Error", - .
apache
"apache2\logs\error.log".
"couldn't create child process"
, Perl .
Perl
.
"Premature end of script headers"
. . ,
,

mime (text/html) .
, ,
.pl .
,
PHP 4.2
Apache, PHP .
Apache,
C:\USR\PHP4\.
php.ini, php.ini-recommended .
php.ini Windows (c:\windows,
). c:\windows\system32
php4ts.dll
httpd.conf,
:
LoadModule php4_module
C:/USR/PHP4/sapi/php4apache2.dll
AddType application/x-httpd-php .php .php3 .php4 .htm .html
PHP
php.ini. php.ini
PHP Windows,
.
PHP , :
<?
phpinfo();
?>
ARTICOLUL APACHE2.2 PHP-5.1.4.DOC

Apache
,

.

,
.

Apache- (, , )

Windows, httpd.exe
.

,
c:/Apache2.2/htdocs.
index.html localhost.

DocumentRoot c:/Apache2.2/conf/httpd.conf.
DocumentRoot "C:/Apache2.2/htdocs"

.
,
httpd.conf. ,
Apache ,

,
C:/Apache2.2/htdocs.
,
,
403 Forbidden , .

,
Apache
,
.
:/Apache2.2/conf/httpd.conf :
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Satisfy all
</Directory>
Deny from all.
,
.
Apache 403 Forbidden.
Allow from all.
Deny from all.
Allow from all
,
( )
Deny from all .
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
# Deny from all
Satisfy all
</Directory>
Apache.
.

httpd.conf PHP
php, ,
3 httpd.conf
PHP httpd.conf
LoadModule php5_module c:/php-5.1.4/php5apache2_2.dll
AddType application/x-httpd-php phtml php
PHPIniDir "c:/php-5.1.4/"

httpd.conf, , LoadModule.

, ,
httpd.conf.
PHP,
php5apache2_2.dll

php mime- application/x-httpd-php,
PHP.

php.ini.

PHP. httpd.conf PHPIniDir
php
c:/php-5.1.4.
php.ini
c:/php-5.1.4
.
c:/php-5.1.4/php.ini-recommended
php.ini. , PHP (php.ini)
c:/php-5.1.4
PHP.
httpd.conf php.ini
Apache.
php- phpinfo.php,

c:/Apache2.2/htdocs.
phpinfo.php
<?php
echo phpinfo();

// ,

// php-. <?php <?


?>

phpinfo.php PHP-
. PHP
.

short_open_tag php.ini.
On.

http://localhost/phpinfo.php.

, php .

" " - php


Apache-.

Apache , " "
.
:
? ..:


<?php
echo phpinfo();
?>

<?
echo phpinfo();
?>
ARTICOLUL XAMP_ APACHE
WINDOWS.DOC inclusive si sub WINDOWS VISTA
!
,
, ,

. ip
.
,
,
, ,
windows.
,

. .
apache
windows ,
VISTA (32 64).
ATENTIE!!!!!!!
.
, XAMPP -
. PORTABLE ADICA NU
AFECTEAZA NU SE LEAGA DE REGISTRUL COMPULUI, NU SE PRINDE
DE PC!!!
XAMPP . apache,
php, mysql, ftp , sendmail, perl .
(
), XAMPP ,
.
, ,
.

ARTICOLUL APACHE
WINDOWS.DOC ESTE PROPUS DUPA INSTALAREA XAMPP!!!!
DE MAI SUS PENTRU A PROTEGA PC-ul SI SERVERUL
ATENTIE!!!!
freebsd, linux, ..