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

<VirtualHost *:80>

DocumentRoot /media/data/workspace/phpapp

<Directory /media/data/workspace/phpapp/>

Options Indexes FollowSymLinks MultiViews

AllowOverride all

Order allow,deny

allow from all

</Directory>

加入

<Directory "/media/program/workspace/neusoft/">

Options Indexes FollowSymLinks

AllowOverride All

Order allow,deny

Allow from all

</Directory>

sudo vim localxk

<VirtualHost *:80>

DocumentRoot /media/data/workspace/neusoft/xikang_web

ServerName localxk

</VirtualHost>

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

<VirtualHost *:80>

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

ServerName localxknew

</VirtualHost>

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

<VirtualHost *:80>

DocumentRoot /media/data/workspace/khn3apps

ServerName khn3apps

<Directory "/media/program/workspace/khn3apps/">

Options Indexes FollowSymLinks

AllowOverride All

Order allow,deny

Allow from all

</Directory>

</VirtualHost>

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

<VirtualHost *:80>

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

ServerName www.number1g.com

<Directory "/media/program/workspace/khn3apps/">

Options Indexes FollowSymLinks

AllowOverride All

Order allow,deny

Allow from all

</Directory>

</VirtualHost>

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

<VirtualHost *:80>

#ServerName www.example.com

ServerName localhost:80

加入:

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

<VirtualHost *:80>

ServerName phpcms_ubuntu.com:80

DocumentRoot /home/tboqi/phpcms

ErrorLog ${APACHE_LOG_DIR}/phpcms-error.log

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

<Directory /home/tboqi/phpcms/>

Options Indexes FollowSymLinks

AllowOverride All

Require all granted

</Directory>

</VirtualHost>

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

需要修改: /etc/apache2/envvars

export APACHE_RUN_USER=

export APACHE_RUN_GROUP=

启动rewrite模块

a2enmod

rewrite

相关推荐
不想起昵称9298 分钟前
Linux SHELL脚本中的变量与运算
linux
s甜甜的学习之旅11 分钟前
Apache POI练习代码
apache
是小崔啊13 分钟前
开源轮子 - Apache Common
java·开源·apache
the丶only37 分钟前
单点登录平台Casdoor搭建与使用,集成gitlab同步创建删除账号
linux·运维·服务器·docker·gitlab
ccubee1 小时前
docker 安装 ftp
运维·docker·容器
枫叶红花1 小时前
【Linux系统编程】:信号(2)——信号的产生
linux·运维·服务器
yaosheng_VALVE2 小时前
探究全金属硬密封蝶阀的奥秘-耀圣控制
运维·eclipse·自动化·pyqt·1024程序员节
_微风轻起2 小时前
linux下网络编程socket&select&epoll的底层实现原理
linux·网络
dami_king2 小时前
SSH特性|组成|SSH是什么?
运维·ssh·1024程序员节