apache2 + php5 in ubuntu

 检查语法,重启web服务

谨慎起见,我们在重启服务前先检查下语法:

sudo apache2ctl configtest

sudo /etc/init.d/apache2 restart

* Restarting web server apache2
apache2: Could not reliably determine the server’s fully qualified domain name, using 10.119.170.45 for ServerName
… waiting apache2: Could not reliably determine the server’s fully qualified domain name, using 10.119.170.45 for ServerName
…done.

在 /etc/apache2/sites-enabled/000-default中,里面有这样的内容:

NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/
……

ubuntu apache2配置详解(含虚拟主机配置方法)

it’s not problem of the DNS, it’s about finding the location of Internet source files. Change the path after ‘DocumentRoot’, for example:

DocumentRoot /home/username/public_html

  •  /etc/apache2下还有一个sites-available目录,这里面才是真正的配置文件,而sites- enabled目录存放的只是一些指向这里的文件的符号链接
  • 如果apache上配置了多个虚拟主机,每个虚拟主机的配置文件都放在 sites-available下,
  • 对于虚拟主机的停用、启用就非常方便:当在sites-enabled下建立一个指向某个虚拟主机配置文件的链 接时,即启用了它;若要关闭某个虚拟主机,只需删除相应的链接即可,根本不用去改配置文件。
  • mods-available、mods-enabled 两个目录:是存放apache功能模块的配置文件和链接的。当我用apt-get install php5 安装了PHP模块后,在这两个目录里就有了 php5.load、php5.conf和指向这两个文件的链接。这种目录结果对于启用、停用某个 Apache模块是非常方便的。
  • ports.conf 设置了Apache使用的端口
  •  Virtual Hosting(虚拟主机)
    简单说就是同一台服务器可以同时处理超过一个域名(domain)

Apache2 + mod_userdir PHP as plaintext problem

Your /etc/apache2/mods-enabled/php5.conf  file should look like this:

1 <IfModule mod_php5.c>
2     <FilesMatch "\.ph(p3?|tml)$">
3         SetHandler application/x-httpd-php
4     </FilesMatch>
5     <FilesMatch "\.phps$">
6         SetHandler application/x-httpd-php-source
7         </FilesMatch>
8     # To re-enable php in user directories comment the following lines
9     # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
10     # prevents .htaccess files from disabling it.
11     #<IfModule mod_userdir.c>
12     #   <Directory /home/*/public_html>
13     #       php_admin_value engine Off
14     #   </Directory>
15     #</IfModule>
16 </IfModule>

Now just restart Apache and everything should work correctly. Type this command as root user:

1 # /etc/init.d/apache2 restart
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

生活在西班牙

自己动手丰衣足食

BlueAsteroid

Just another WordPress.com site

Jing's Blog

Just another WordPress.com site

Start from here......

我的心情魔方

天才遠私廚

希望能做一個分享各種資訊的好地方

语义噪声

西瓜大丸子汤的博客

笑对人生,傲立寰宇

Just another WordPress.com site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision

datarazzi

Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness

槑烎

1,2,∞

Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web

%d bloggers like this: