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 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

Linux 시스템의 5 가지 기본 구성 요소는 다음과 같습니다. 1. Kernel, 2. System Library, 3. System Utilities, 4. 그래픽 사용자 인터페이스, 5. 응용 프로그램. 커널은 하드웨어 리소스를 관리하고 시스템 라이브러리는 사전 컴파일 된 기능을 제공하며 시스템 유틸리티는 시스템 관리에 사용되며 GUI는 시각적 상호 작용을 제공하며 응용 프로그램은 이러한 구성 요소를 사용하여 기능을 구현합니다.

git 저장소 주소를 보려면 다음 단계를 수행하십시오. 1. 명령 줄을 열고 리포지토리 디렉토리로 이동하십시오. 2. "git remote -v"명령을 실행하십시오. 3. 출력 및 해당 주소에서 저장소 이름을 봅니다.

메모장은 Java 코드를 직접 실행할 수는 없지만 다른 도구를 사용하여 명령 줄 컴파일러 (Javac)를 사용하여 Bytecode 파일 (filename.class)을 생성하면 달성 할 수 있습니다. Java Interpreter (Java)를 사용하여 바이트 코드를 해석하고 코드를 실행하고 결과를 출력하십시오.

Sublime에서 코드를 실행하는 6 가지 방법이 있습니다. 핫키, 메뉴, 빌드 시스템, 명령 줄, 기본 빌드 시스템 설정 및 사용자 정의 빌드 명령, 프로젝트/파일을 마우스 오른쪽 단추로 클릭하여 개별 파일/프로젝트를 실행합니다. 빌드 시스템 가용성은 숭고한 텍스트 설치에 따라 다릅니다.

Laravel을 설치하려면 다음 단계를 순서대로 수행하십시오. Composer 설치 (MacOS/Linux 및 Windows) 설치 LARAVEL 설치 프로그램 새 프로젝트 시작 서비스 액세스 애플리케이션 (URL : http://127.0.1:8000) 데이터베이스 연결 (필요한 경우)을 설정하십시오.

GIT 소프트웨어 설치 단계는 다음 단계가 포함됩니다. 설치 패키지를 다운로드하고 설치 패키지를 실행하여 설치 구성 GIT 설치 GIT BASH (Windows 만)를 확인하십시오.

개발 환경을 사용자 정의하는 방법에는 여러 가지가 있지만 글로벌 GIT 구성 파일은 사용자 이름, 이메일, 우선 텍스트 편집기 및 원격 분기와 같은 사용자 정의 설정에 가장 많이 사용되는 파일입니다. 글로벌 git 구성 파일에 대해 알아야 할 주요 사항은 다음과 같습니다.

Linux는 풍부한 도구와 커뮤니티 지원을 제공하는 기본 플랫폼이기 때문에 Docker는 Linux에서 중요합니다. 1. Docker 설치 : Sudoapt-Getupdate 및 Sudoapt-GetInstalldocker-Cedocker-Ce-clicotainerd.io를 사용하십시오. 2. 컨테이너 생성 및 관리 : Dockerrun-D-Namemynginx-P80 : 80nginx와 같은 Dockerrun 명령을 사용하십시오. 3. Dockerfile 쓰기 : 이미지 크기를 최적화하고 다단계 구성을 사용하십시오. 4. 최적화 및 디버깅 : DockerLogs 및 Dockerex를 사용하십시오
