linux环境apache多端口配置虚拟主机的方法深入介绍_PHP教程
默认情况下,linux上apache使用的
默认文档目录是:/var/www
默认端口是:80
如果想发布自己的一个系统资源目录,可以使用下面的方法,执行如下命令:
(1)添加监听端口
#cd /etc/apache2
#vim ports.conf
文件添加:
NameVirtualHost *:8000
Listen 8000
(2)配置虚拟目录
#cd /etc/apache2/sites-available
#cp default default-me
#vim default-me
文件内容如下:
ServerAdmin webmaster@localhost
DocumentRoot /wwwroot
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
粗体部分是关键点。
(3)发布站点
# ln -s /etc/apache2/sites-available/default-me /etc/apache2/sites-enabled/001-default
(4)重启服务
#/etc/init.d/apache2 restart
(5)测试
http://localhost:8000/
如果能够正常访问就说明配置正确了。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
#
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:81
NameVirtualHost *:82
NameVirtualHost *:83
NameVirtualHost *:84
NameVirtualHost *:85
NameVirtualHost *:86
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any
#
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/AppServ/www/www-nongye
ServerName www.dede.com
ErrorLog D:/AppServ/www/www-nongye/errornongye.log
CustomLog logs/dummy-host2.appservnetwork.com-access_log common
Options FollowSymLinks
#Deny from all
Allow from all
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/AppServ/www-chinaec
ServerName www.dede.com
DirectoryIndex index.php index.html
ErrorLog D:/AppServ/www-chinaec/errornongjiale.log
CustomLog logs/dummy-host2.appservnetwork.com-access_log common
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/AppServ/www/www-05110
ServerName www.dede.com
ErrorLog D:/AppServ/www/www-05110/errornong05110.log
CustomLog logs/dummy-host2.appservnetwork.com-access_log common
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/AppServ/www/wordpress
ServerName www.dede.com
ErrorLog D:/AppServ/www/wordpress/errornongwordpress.log
CustomLog logs/dummy-host2.appservnetwork.com-access_log common
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/AppServ/www/magento
ServerName www.dede.com
ErrorLog D:/AppServ/www/magento/errormagento.log
CustomLog logs/dummy-host2.appservnetwork.com-access_log common
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/AppServ/www/magento1322
ServerName www.dede.com
ErrorLog D:/AppServ/www/magento1322/errormagento1322.log
CustomLog logs/dummy-host2.appservnetwork.com-access_log common
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/AppServ/www/www-nongjiale
ServerName www.dede.com
ErrorLog D:/AppServ/www/www-nongjiale/errornongjiale.log
CustomLog logs/dummy-host2.appservnetwork.com-access_log common
ServerAdmin webmaster@dummy-host2.x
DocumentRoot "C:/Apache2.2/docs/dummy-host2.x"
ServerName dummy-host2.x
ErrorLog "logs/dummy-host2.x-error.log"
CustomLog "logs/dummy-host2.x-access.log" common
1、单域名单端口设置
如:www.abc.com 默认用80访问
特别说明,apache的配置默认都在安装目录下的conf目录里面
或者是/etc/apache2
不过一定要注意,listen.conf文件中端口监听是否开启
如下图,表示已经开启80端口监听
直接默认
1、单域名单端口设置
如:www.abc.com 默认用80访问
特别说明,apache的配置默认都在安装目录下的conf目录里面
或者是/etc/apache2
不过一定要注意,listen.conf文件中端口监听是否开启
如下图,表示已经开启80端口监听
直接默认修改default-server.conf
这个配置最好简单
安装好了,之后,默认已经能够使用了,只是要把它修改成你需要的域名及访问路径罢了。
给一个标准配置吧
DocumentRoot "/srv/www/htdocs"
#
# Configure the DocumentRoot
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs-2.2/mod/core.html#options
# for more information.
Options None
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
AllowOverride None
# Controls who can get stuff from this server.
Order allow,deny
Allow from all
2、单域名多端口设置
Options None
AllowOverride None
Order allow,deny
Allow from all
Options None
AllowOverride None
Order allow,deny
Allow from all
NameVirtualHost *:80
NameVirtualHost *:81
DirectoryIndex index.html index.php
ServerName "www.abc.com "
DocumentRoot "/srv/www/htdocs/"
DirectoryIndex index.php
ServerName "www.abc.com:81 "
DocumentRoot "/srv/www/htdocs/bbs/"
3、多域名多端口设置
Options None
AllowOverride None
Order allow,deny
Allow from all
Options None
AllowOverride None
Order allow,deny
Allow from all
Options None
AllowOverride None
Order allow,deny
Allow from all
NameVirtualHost *:80
NameVirtualHost *:81
DirectoryIndex index.html index.php
ServerName "www.abc.com "
DocumentRoot "/srv/www/htdocs/"
DirectoryIndex index.html index.php
ServerName "www.btc.com "
DocumentRoot "/srv/www/htdocs/btc"
DirectoryIndex index.php
ServerName "www.abc.com:81 "
DocumentRoot "/srv/www/htdocs/bbs/"
需要注意的问题是,多端口监听,一定要注意listen.conf文件,是否开启了相应端口。

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

运行 H5 项目需要以下步骤:安装 Web 服务器、Node.js、开发工具等必要工具。搭建开发环境,创建项目文件夹、初始化项目、编写代码。启动开发服务器,使用命令行运行命令。在浏览器中预览项目,输入开发服务器 URL。发布项目,优化代码、部署项目、设置 Web 服务器配置。

无法以 root 身份登录 MySQL 的原因主要在于权限问题、配置文件错误、密码不符、socket 文件问题或防火墙拦截。解决方法包括:检查配置文件中 bind-address 参数是否正确配置。查看 root 用户权限是否被修改或删除,并进行重置。验证密码是否准确无误,包括大小写和特殊字符。检查 socket 文件权限设置和路径。检查防火墙是否阻止了 MySQL 服务器的连接。

Linux的五个基本组件是:1.内核,管理硬件资源;2.系统库,提供函数和服务;3.Shell,用户与系统交互的接口;4.文件系统,存储和组织数据;5.应用程序,利用系统资源实现功能。

MySQL安装报错的解决方法是:1.仔细检查系统环境,确保满足MySQL的依赖库要求,不同操作系统和版本需求不同;2.认真阅读报错信息,根据提示(例如缺少库文件或权限不足)采取对应措施,例如安装依赖或使用sudo命令;3.必要时,可尝试源码安装并仔细检查编译日志,但这需要一定的Linux知识和经验。最终解决问题的关键在于仔细检查系统环境和报错信息,并参考官方文档。

MySQL启动失败的原因有多种,可以通过检查错误日志进行诊断。常见原因包括端口冲突(检查端口占用情况并修改配置)、权限问题(检查服务运行用户权限)、配置文件错误(检查参数设置)、数据目录损坏(恢复数据或重建表空间)、InnoDB表空间问题(检查ibdata1文件)、插件加载失败(检查错误日志)。解决问题时应根据错误日志进行分析,找到问题的根源,并养成定期备份数据的习惯,以预防和解决问题。

MySQL安装失败的原因主要有:1.权限问题,需以管理员身份运行或使用sudo命令;2.依赖项缺失,需安装相关开发包;3.端口冲突,需关闭占用3306端口的程序或修改配置文件;4.安装包损坏,需重新下载并验证完整性;5.环境变量配置错误,需根据操作系统正确配置环境变量。解决这些问题,仔细检查每个步骤,就能顺利安装MySQL。

MySQL无法直接在Android上运行,但可以通过以下方法间接实现:使用轻量级数据库SQLite,由Android系统自带,无需单独服务器,资源占用小,非常适合移动设备应用。远程连接MySQL服务器,通过网络连接到远程服务器上的MySQL数据库进行数据读写,但存在网络依赖性强、安全性问题和服务器成本等缺点。

MySQL拒启动?别慌,咱来排查!很多朋友安装完MySQL后,发现服务死活启动不了,心里那个急啊!别急,这篇文章带你从容应对,揪出幕后黑手!读完后,你不仅能解决这个问题,还能提升对MySQL服务的理解,以及排查问题的思路,成为一名更强大的数据库管理员!MySQL服务启动失败,原因五花八门,从简单的配置错误到复杂的系统问题都有可能。咱们先从最常见的几个方面入手。基础知识:服务启动流程简述MySQL服务启动,简单来说,就是操作系统加载MySQL相关的文件,然后启动MySQL守护进程。这其中涉及到配置
