Maison > php教程 > php手册 > le corps du texte

debian Squeeze配置apache php mysql环境,debian中apache目录结

WBOY
Libérer: 2016-06-06 19:59:03
original
1050 Les gens l'ont consulté

1:安装apache 2.X版本 apt-get install apache2 打开apache重写 a2enmod rewrite 安装mysql apt-get install mysql-server 输入密码,确认密码 安装php apt-get install php5 php-pear php5-suhosin php5-gd php5-snmp php5-cgi php5-cli php5-curl libjpeg8

1:安装apache 2.X版本

apt-get install apache2
Copier après la connexion

打开apache重写
a2enmod rewrite
Copier après la connexion

安装mysql
apt-get install mysql-server
Copier après la connexion

输入密码,确认密码

安装php

apt-get install php5 php-pear php5-suhosin php5-gd php5-snmp php5-cgi php5-cli php5-curl libjpeg8-dev php5-imap php5-ldap php5-odbc php5-mcrypt libmcrypt* libmcrypt-dev php5-common php5-xmlrpc php5-memcache php5-memcached php5-xdebug php5-idn php5-ming php5-ps php5-pspell php5-tidy php5-xsl php5-dev
Copier après la connexion
让mysql支持php5
apt-get install php5-mysql libapache2-mod-php5
Copier après la connexion

重启
/etc/init.d/apache2 restart
Copier après la connexion

提示:
No apache MPM package installed
需要安装一个apache的mpm模块:

#apt-get install apache2-mpm-* 

可供安装的模块有四种:
  apache2-mpm-event: Conflicts: apache2-mpm
  apache2-mpm-itk: Conflicts: apache2-mpm
  apache2-mpm-prefork: Conflicts: apache2-mpm
  apache2-mpm-worker: Conflicts: apache2-mpm

就安装mpm-prefork:

#apt-get install apache2-mpm-prefork

2:debian中apache的目录结构
#cd /var/www
#ls -la

root@debian:/etc/apache2# ls -la
total 76
drwxr-xr-x   7 root root  4096 Dec  9 11:09 .
drwxr-xr-x 111 root root  4096 Dec  9 10:41 ..
-rw-r--r--   1 root root  8023 Dec  9 11:09 apache2.conf
drwxr-xr-x   2 root root  4096 Dec  4 09:38 conf.d
-rw-r--r--   1 root root  1169 Sep 29 13:58 envvars
-rw-r--r--   1 root root     0 Dec  4 09:38 httpd.conf
-rw-r--r--   1 root root 31063 Sep 29 13:58 magic
drwxr-xr-x   2 root root  4096 Dec  8 15:07 mods-available
drwxr-xr-x   2 root root  4096 Dec  9 10:21 mods-enabled
-rw-r--r--   1 root root   750 Sep 29 13:58 ports.conf
drwxr-xr-x   2 root root  4096 Dec  4 09:38 sites-available
drwxr-xr-x   2 root root  4096 Dec  4 09:38 sites-enabled
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion

apache2.conf为服务器的主配置文件,其中有 Include什么的,是这个配置文件的分割文件,这样方便管理

比如

#Include module configuration:

Include /etc/apache2/mods-enabled/*.load

Include /etc/apache2/mods-enabled/*.conf

#Include all the user configuration:

Include /etc/apache2/httpd.conf

#Include generic snippets of statements

Include /etc/apache2/conf.d/[^.#]*

conf.d  为配置文件的一部分,仅仅提供了charset也就是编码

AddDefaultCharset UTF-8 如果要修改默认编码GB2312 直接修改了就是.

httpd.conf 什么都木有

magic 包含的是mod_mime_magic模块的数据,一般不需要修改它.

ports.conf 服务器监听IP和端口的配置文件

NameVirtualHost *:80Listen 80

    Listen 443

mods-availlable 是一些.conf和.load文件,而mods-enabled目录下则是指向这些配置文件的软链接,而配置文件apache2.conf中是通过mods-enabled来加载这些模块的,即系统是通过mods-available的软链接mods-enable来加载模块. 同时还有2个命令 a2enmod  a2dismod 来使用和禁用这些软链接.这两个命令在apache2-common里面.

命令格式: a2enmod [module]  或者 a2dismod [module]

3.修改www目录为自定义的文件夹地址 比如我要放到 /home/rainysia/www

如果要修改默认的 网站文件所在的文件夹,需要修改这个文件,为了以防万一我们备份一个

root@debian:/etc/apache2#cd sites-enabled
root@debian:/etc/apache2/sites-enabled# cp 000-default 000-default-bak
root@debian:/etc/apache2/sites-enable#vi 000-default
Copier après la connexion

修改 apache2.conf 里面的

# Include module configuration:
Include mods-enabled/*.load
Include mods-enabled/*.conf

# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf

修改最大连接数为1000

MaxKeepAliveRequests 1000

在最后加入

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

保存apache2.conf

打开000-default

修改两行内容, DocumentRoot 后面跟的是你指定的www文件地址, 同Directory  注意一个有斜线 /

DocumentRoot /home/rainysia/www

保存

重启apache

/etc/ init.d/apache2 restart
Copier après la connexion


4:修改php.ini

vim /etc/php5/apache2/php.ini

找到error_reporting = E_ALL & ~E_DEPRECATED 大约在514行

修改为 error_reporting = E_ALL & E_STRICT 

(这里是开发环境,我们用严厉点儿的,如果是要上线,可以在www里面写一个配置文件,来定义 error_reporting = E_ALL & ~E_NOTICE )

下面同理修改

display_errors = On

display_startup_errors = On

track_errors = On

html_errors = On

error_log = /var/log/php.log

session.bug_compat_42 = On

session.bug_compat_warn = On





5:重启的时候 /etc/init.d/apache2 restart 如果报错 说Could not reliably determine the server's fully qualified domain name, using xxx.xxx.xxx.xxx for ServerName

打开httpd.conf

#vim /etc/apache2/httpd.conf

加入一行

ServerName 127.0.0.1


6:phpmyadmin提示缺少mcrypt文件

#apt-get install mcrypt* mhash*

#/etc/init.d/apache2 restart


提示缺少mysqli

在php.ini (/etc/php5/apache2/php.ini) 中找到extension_dir="./" 修改为mysqli.so 所在目录


7:如果需要限制对网站根目录的访问,直接在 Indexes前面加 - 修改下面的


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all


Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all

8:禁止显示服务器名字 

cd /etc/apache2/conf.d/

vim security

编辑security

加入

ServerTokens Prod

禁止显示apache版本

ServerSignature Off

同时注销掉本身的 用#

保存


然后重启apache即可

Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion
Copier après la connexion


Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Recommandations populaires
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!