Home php教程 php手册 debian Squeeze配置apache php mysql环境,debian中apache目录结

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

Jun 06, 2016 pm 07:59 PM
apache debian m php Configuration

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
Copy after login

打开apache重写
a2enmod rewrite
Copy after login

安装mysql
apt-get install mysql-server
Copy after login

输入密码,确认密码

安装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
Copy after login
让mysql支持php5
apt-get install php5-mysql libapache2-mod-php5
Copy after login

重启
/etc/init.d/apache2 restart
Copy after login

提示:
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
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login

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
Copy after login

修改 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
Copy after login


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即可

Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login
Copy after login


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1255
24
PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their History PHP and Python: A Deep Dive into Their History Apr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

The Continued Use of PHP: Reasons for Its Endurance The Continued Use of PHP: Reasons for Its Endurance Apr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

The Compatibility of IIS and PHP: A Deep Dive The Compatibility of IIS and PHP: A Deep Dive Apr 22, 2025 am 12:01 AM

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

What happens if session_start() is called multiple times? What happens if session_start() is called multiple times? Apr 25, 2025 am 12:06 AM

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

NGINX and Apache: Understanding the Key Differences NGINX and Apache: Understanding the Key Differences Apr 26, 2025 am 12:01 AM

NGINX and Apache each have their own advantages and disadvantages, and the choice should be based on specific needs. 1.NGINX is suitable for high concurrency scenarios because of its asynchronous non-blocking architecture. 2. Apache is suitable for low-concurrency scenarios that require complex configurations, because of its modular design.

Using Laravel: Streamlining Web Development with PHP Using Laravel: Streamlining Web Development with PHP Apr 19, 2025 am 12:18 AM

Laravel optimizes the web development process including: 1. Use the routing system to manage the URL structure; 2. Use the Blade template engine to simplify view development; 3. Handle time-consuming tasks through queues; 4. Use EloquentORM to simplify database operations; 5. Follow best practices to improve code quality and maintainability.

Composer: Aiding PHP Development Through AI Composer: Aiding PHP Development Through AI Apr 29, 2025 am 12:27 AM

AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

See all articles