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

相关推荐
安於宿命1 分钟前
【Linux】简易版shell
linux·运维·服务器
追梦不止~9 分钟前
Docker常用命令+详解
运维·docker·容器
黑龙江亿林等保12 分钟前
深入探索哈尔滨二级等保下的负载均衡SLB及其核心算法
运维·算法·负载均衡
黄小耶@13 分钟前
linux常见命令
linux·运维·服务器
叫我龙翔14 分钟前
【计网】实现reactor反应堆模型 --- 框架搭建
linux·运维·网络
古驿幽情16 分钟前
CentOS AppStream 8 手动更新 yum源
linux·运维·centos·yum
BillKu17 分钟前
Linux(CentOS)安装 Nginx
linux·运维·nginx·centos
BillKu21 分钟前
Linux(CentOS)yum update -y 事故
linux·运维·centos
a2663789626 分钟前
解决yum命令报错“Could not resolve host: mirrorlist.centos.org
linux·运维·centos
上海文顺负载箱39 分钟前
如何评估焊机测试负载均衡性能
运维·负载均衡