linux apache安装及虚拟主机配置

centos 安装apache,

yum install httpd

将httpd.conf中的ServerName 前面的 # 去掉。
 apache 2.2 的虚拟机的配置放置在conf/extra/httpd-vhosts.conf 中

apache 虚拟主机设置

a2enmod

rewrite

sudo vim 000-default

修改

ServerName *:80

DocumentRoot /media/data/workspace/phpapp

                Options Indexes FollowSymLinks MultiViews

                AllowOverride all

                Order allow,deny

                allow from all

        

加入

        Options Indexes FollowSymLinks

        AllowOverride All

        Order allow,deny

        Allow from all

sudo vim localxk

DocumentRoot /media/data/workspace/neusoft/xikang_web

ServerName localxk

/etc/apache2/sites-enabled$ sudo vim localxknew

DocumentRoot /media/data/workspace/neusoft/xikang_new/xikang_new/

ServerName localxknew

sudo vim /etc/apache2/sites-enabled/khn3apps

DocumentRoot /media/data/workspace/khn3apps

ServerName khn3apps

        Options Indexes FollowSymLinks

        AllowOverride All

        Order allow,deny

        Allow from all

sudo vim /etc/apache2/sites-enabled/www.number1g.com

DocumentRoot /media/data/workspace/phpapp/number1g.com_wp

ServerName www.number1g.com

    Options Indexes FollowSymLinks

    AllowOverride All

    Order allow,deny

    Allow from all

ubuntu+apache2.4+php+phpcms

安装php环境:

sudo apt-get install apache2 php5 mysql-server php5-common php5-mysql  php5-curl  php5-gd php5-cli php5-ldap php5-mhash libtool libmcrypt-dev php5-mcrypt php5-ldap php-soap php5-sqlite php5-xsl

配置虚拟主机

/etc/apache2/sites-enabled/000-default.conf 中加入

ServerName 127.0.0.1:80

        #ServerName www.example.com

ServerName localhost:80

加入:

/etc/apache2/sites-enabled/phpcms.conf

        ServerName phpcms_ubuntu.com:80

        DocumentRoot /home/tboqi/phpcms

        ErrorLog ${APACHE_LOG_DIR}/phpcms-error.log

        CustomLog ${APACHE_LOG_DIR}/phpcms-access.log combined

        Options Indexes FollowSymLinks

        AllowOverride All

        Require all granted

由于使用我当前的登录用户运行php

需要修改: /etc/apache2/envvars

export APACHE_RUN_USER=

export APACHE_RUN_GROUP=

启动rewrite模块

a2enmod

rewrite

你可能感兴趣的:(linux,apache,运维,虚拟主机,centos,ubuntu,debian)