Apache PHP MySQL 安装

2022-2-20 Sun 15:22:14 ( 580 )

httpd.conf 和 php.ini 分别是:

apache 2.4 64x 安装在 C:\Program Files\Apache Software Foundation\Apache

php 8.01 VS16 x64 安装在 C:\Program Files\php

的设置文件,其中 php 设置编码是 GBK,如要设置为 GBK 改 721 行的 default_charset = "UTF-8",把 721 行最前面的分号“;” 移到 720 行最前即可。

中文字,在GBK编码下,占用2个字节,在UTF-8下,中文占用2-3(绝大部分是3)个字节。UTF-8的好处是,不是中文的操作系统,不作任何设置,网页上UTF-8的中文字可以正常显示(可能会自动下载字体),GBK的则不能。

============ ============ ============ ============ ============ ============

以下最前面有“//”表示注释或者现在不需要修改的

============ ============ ============ ============ ============ ============

安装 php ssl版本

------ ------ ------ ------ ------ ------

下载地址:https://windows.php.net/download

注:以下“D:\My Tools\”、"C:\Program Files\php”需改为你的实际目录。

1、修改 php.ini,

// register_globals = On

// 425

;max_input_vars = 1000

max_input_vars = 3000

// 716

; default_charset = "UTF-8"

default_charset = "GBK"

// 765

;extension_dir = "ext"

extension_dir = "C:\Program Files\php\ext"

// 969

;date.timezone =

date.timezone = "Asia/Shanghai"

// 1357

;session.save_path = "/tmp"

session.save_path = "D:/My Documents/My WebSites/_draft/tmp"

// session.save_path,windows 10 下,非管理员账号不能设置在 C:盘,

// 1770 启用php8.0的jit服务

// 在opcache.enable=1下方添加

opcache.enable=1

opcache.jit_buffer_size = 512M

918+-

  extension=php_mbstring.dll  这不选一般用PHPMYADMIN会出红色提示,故必选

extension=bz2

extension=curl

extension=fileinfo

extension=gd

extension=gettext

extension=mbstring

extension=exif      

extension=mysqli

extension=openssl

extension=pdo_mysql

  

//2、复制 php5ts.dll 和 libmysql.dll 到 C:\WINNT\system32

//3、php.exe、php-win.exe 和 php.ini 三个文件拷到 C:\WINNT 下

//4、php的curl扩展,将php目录下的libssh2.dll 拷贝到 apache的 bin下

5、新建 tmp 文件夹(如果没有)在 session.save_path 文件夹下

=======================================================================

安装 pear (这部分可以忽略)

环境:PHP4.3.10 + Windows XP

安装步骤:

1) 安装前的工作

    安装PHP后所产生的文件夹下面有一个go-pear.bat文件

2) 执行installer

    双击go-pear.bat,有问答时,全部按“Enter”

3) 追加路径

    打开你的php.ini文件,在

    ;;;;;;;;;;;;;;;;;;;;;;;;;

    ; Paths and Directories ;

    ;;;;;;;;;;;;;;;;;;;;;;;;;

   下面看一下有没有"include-path=",没有就追加,有的话就加写

[pear]

include-path=".;D:\My Tools\PHP;D:\My Tools\PHP\smarty\libs; D\:My Tools\php\pear"

4) 查看PHP文件夹

    除了go-pear.bat文件,又多了pear.bat和PEAR_ENV.reg

5) 注册表的修改

    双击PEAR_ENV.reg文件,选择“ok”,即可完成修改

6) 环境参数的自动设定

    双击pear.bat文件即可

7) 确认安装成功与否

    打开prompt command,输入“pear list”看安装在文件夹pear(我的是:D\:My Tools\php\pear)下面library是否都显示出来了

------ ------ ------ ------ ------ ------

http://blog.pear.php.net/2009/07/01/php-53-windows-and-pear/

开启一个命令行窗口,切换目录到php的目录下,然后输入

php -d phar.require_hash=0 PEAR/go-pear.phar

这样就进入安装进程.

接着会询问将安装在系统或是本地,输入local并由yes确认.

===================================================

MySQL安装

------ ------ ------ ------ ------ ------

下载地址:https://dev.mysql.com/downloads/mysql/

初始化数据库

mysqld --initialize --console

A temporary password is generated for root@localhost: m?F!BZDi#0=h

删掉初始化的 datadir 目录,再执行一遍初始化命令,又会重新生成

安装服务

mysqld --install mysql

启动服务

net start mysql

net stop mysql

进入服务

mysql -u root -p

输入临时密码

修改密码,其中的“woopole2014”改为自己的密码

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'woopole2014';

退出服务

quit;

删除mysql

sc delete mysql

List of all MySQL commands:

Note that all text commands must be first on line and end with ';'

?         (\?) Synonym for `help'.

clear     (\c) Clear the current input statement.

connect   (\r) Reconnect to the server. Optional arguments are db and host.

delimiter (\d) Set statement delimiter.

ego       (\G) Send command to mysql server, display result vertically.

exit      (\q) Exit mysql. Same as quit.

go        (\g) Send command to mysql server.

help      (\h) Display this help.

notee     (\t) Don't write into outfile.

print     (\p) Print current command.

prompt    (\R) Change your mysql prompt.

quit      (\q) Quit mysql.

rehash    (\#) Rebuild completion hash.

source    (\.) Execute an SQL script file. Takes a file name as an argument.

status    (\s) Get status information from the server.

tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.

use       (\u) Use another database. Takes database name as argument.

charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.

warnings  (\W) Show warnings after every statement.

nowarning (\w) Don't show warnings after every statement.

resetconnection(\x) Clean session context.

=======================================================================

apache安装

------ ------ ------ ------ ------ ------

配置apache里的httpd.conf

用notepad打开 C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf

C:\Program Files\Apache Software Foundation\Apache2.4\conf\httpd.conf

1、修改

Define SRVROOT "c:/Apache24"

Define SRVROOT  "C:/Program Files/Apache Software Foundation/Apache"

2、找到

// AddDefaultCharset ISO-8859-1 将其改为

// AddDefaultCharset GBK or GB2312(让默认语言编码为简体中文)

3、找到

DocumentRoot "D:/My Documents/My WebSites"

将其改为你的WEB目录,

4、找到

#

# This should be changed to whatever you set DocumentRoot to.

#

改为你的WEB目录

5、找到

a,

扩展模块前加上 php 目录:

PHPIniDir "C:/Program Files/php"

b,

#LoadModule xml2enc_module modules/mod_xml2enc.so

在此行后加入一行

LoadModule php5_module c:/php/php5apache2.dll (apache 2.0 + php5)

LoadModule php5_module "D:/My Tools/php/php5apache2_2.dll" (apache 2.2 + php5)

LoadModule php7_module "C:/Program Files/php/php7apache2_4.dll" (apache 2.4 + php7)

LoadModule php_module "C:/Program Files/php/php8apache2_4.dll"

(apache 2.4 + php8)

其中D:/My Tools/php/php5apache2_2.dll(php5apache2_2.dll) 为你php目录中php5apache2.dll(php5apache2_2.dll)所在的位置

6、找到

DirectoryIndex index.html

// 在后面加入

// index.html.var index.htm index.php (默认index.php为首页文件)

改为:

DirectoryIndex index.php index.html index.htm

7、找到

AddType application/x-gzip .gz .tgz

在此行后加入一行

AddType application/x-httpd-php .php

(5、6,可以直接加在httpd.conf文件的最后面)

8、如果 cpu 占用高,可以修改:

ThreadsPerChild 250

MaxRequestsPerChild  0

为:

ThreadsPerChild 3

MaxRequestsPerChild  3

9、找到

#ServerName www.example.com:80

后面添加

ServerName localhost:80

0、../Apache Software Foundation/Apache24/conf/extra/httpd-ahssl.conf

CustomLog (line 135, 149)

SSLCertificateFile

SSLCertificateKeyFile

DocumentRoot

修改为实际路径

------ ------ ------ ------ ------ ------

下载地址:http://httpd.apache.org/download.cgi

准备工作:

安装之前需要检查80端口、3306端口是否被其它程序占用,如果有,则需要删除相应的软件

检查配置文件有无语法错误:

httpd -t

httpd -k uninstall -n Apache

httpd -k install -n Apache

httpd -k stop -n Apache

httpd -k start -n apache

httpd -k restart -n apache

net start apache

=======================================================================

Usage: httpd [-D name] [-d directory] [-f file]

             [-C "directive"] [-c "directive"]

             [-w] [-k start|restart|stop|shutdown] [-n service_name]

             [-k install|config|uninstall] [-n service_name]

             [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X]

Options:

  -D name            : define a name for use in directives

  -d directory       : specify an alternate initial ServerRoot

  -f file            : specify an alternate ServerConfigFile

  -C "directive"     : process directive before reading config files

  -c "directive"     : process directive after reading config files

  -n name            : set service name and use its ServerConfigFile and ServerRoot

  -k start           : tell Apache to start

  -k restart         : tell running Apache to do a graceful restart

  -k stop|shutdown   : tell running Apache to shutdown

  -k install         : install an Apache service

  -k config          : change startup Options of an Apache service

  -k uninstall       : uninstall an Apache service

  -w                 : hold open the console window on error

  -e level           : show startup errors of level (see LogLevel)

  -E file            : log startup errors to file

  -v                 : show version number

  -V                 : show compile settings

  -h                 : list available command line options (this page)

  -l                 : list compiled in modules

  -L                 : list available configuration directives

  -t -D DUMP_VHOSTS  : show parsed vhost settings

  -t -D DUMP_RUN_CFG : show parsed run settings

  -S                 : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG

  -t -D DUMP_MODULES : show all loaded modules

  -M                 : a synonym for -t -D DUMP_MODULES

  -t -D DUMP_INCLUDES: show all included configuration files

  -t                 : run syntax check for config files

  -T                 : start without DocumentRoot(s) check

  -X                 : debug mode (only one worker, do not detach)

C:\Program Files\Apache Software Foundation\Apache\bin>

=======================================================================

  Apache缺省配置是专业的高性能Http服务器,它在运行时的服务进程自动占据相当的资源。 

  操作系统的进程和线程管理功能越强,则Apache还给其它较大的应用程序留有资源。象win98这种系统上装有Apache,其它的大型程序可能就来不起了。 

  当然,计算机硬件系统也不要太差,但如果不是真地在充当互联网上流量和请求量极大的服务器,一般的intel赛扬+128M+7200rpm+win2000就可很流畅地运行Apache 

   

  另外:在非互联网服务器上调试网站时,可以修改$Apache_Root\conf\httpd.conf里面的相关参数以降低Apache在空闲或低负荷时的资源消耗

===================================================

    DocumentRoot "E:\workspace\cakephp"

    ServerName www.cakephp.com

   

        Options Indexes FollowSymLinks

        AllowOverride All

        Order allow,deny

        Allow from all

   


Name
Title
Title Color
Words
1
0.013200998306274/6