iT邦幫忙

0

請問在dreamwaver中使用php,程式碼不想放在C:\AppServ\www,應該怎麼設定?

我記得以前php上課時,老師教的時候是使用dreamwaver,而且他是在c碟根目錄設一個資
料夾,而不是設在C:\AppServ\www,日前重新溫習時,忘了怎麼設定,請問要如何設定?

看更多先前的討論...收起先前的討論...
dreamweaver表示:關我屁事?
然後其實我不太建議使用AppServ,尤其如果你用的還是2.5.10之類的舊版本的話……
建議你乖乖的裝WAMP或是XAMPP
最後就是……放在C:\Appserv\www有啥不好?
還是你想看看xampp的……
C:\Xampp\xamppfiles\htdocs ?
或是linux的:
\var\www\html ???
晨勤 iT邦新手 4 級 ‧ 2017-07-26 14:57:13 檢舉
謝謝指教,因為C:\Appserv\www是安裝就會出現的目錄,我希望網頁的檔案可以歸類在一起,還是wamp可以,appserv卻不行??因為我看到書上的範例是使用wamp,不是應該可以改設定就可以嗎??
晨勤 iT邦新手 4 級 ‧ 2017-07-26 14:59:16 檢舉
對了, 我忘了說"不行"的意思,就是php檔放在C:\Appserv\www時,可以用http://localhost/*.php順利執行,但是放在別的目錄,就會出現找不的訊息
justin iT邦新手 5 級 ‧ 2017-07-26 16:54:13 檢舉
更改網頁存放路徑
httpd.conf
DocumentRoot "C:/AppServ/www"
我覺得你需要了解二個東西:
一個是hosts的設定
另一個是virtualhost的說定。
你這樣改,也只是改掉了根目錄。沒有改掉不同專業的對應目錄。
你網站的執行目錄鎖定是Appserv\www當然就只有那邊能跑啊!
不然隨便亂放隨便都能執行不就很危險?
但你現在的問題出在我覺得你連server的管理都不熟……
怕你亂改等會整個都不能用。
晨勤 iT邦新手 4 級 ‧ 2017-07-26 22:31:51 檢舉
首先感謝justin的回答,因為我問前也改過,但是沒效....,我以為我記錯了,看到你的解答後,我重試之下,突然想起上課時老師是叫我們直接在瀏覽器上用localhost/*.php,如果改程式,直接用更新,而不是在dreamwaver上執行。
justin iT邦新手 5 級 ‧ 2017-07-27 09:59:14 檢舉
看一下
http://blog.xuite.net/andy19890411/Orz/18358441-%E3%80%90PHP%26MySql%E3%80%91AppServ+%E5%AE%89%E8%A3%9D+%E5%8F%8A+Dreamweaver%E8%A8%AD%E5%AE%9A%E3%80%82
justin,請不要再把「過時」的東西拿出來好嗎?
Appserv 2.5.10之類的東西真的不應該再次出現了。
如果是Appserv 8.x以上還勉強說得過去
而且我現在教他的做法,是讓他一個伺服器可以同時做多個專案目錄不打架。
晨勤 iT邦新手 4 級 ‧ 2017-07-27 12:47:40 檢舉
不要這麼說,justin把完整的操作方法找出來,很感謝的說。
那是因為你對此了解不深……認為有答案就是好。
問題是整個時間都大推移超過十年以上了。
不光說他回答你的東西舊,我連你老師教你用那麼舊的東西也大感搖頭。
萬一你看到了別人用的新作法,新方法,結果你一拿到範例就error……豈不更自找麻煩?我還是會建議你該更新就更新。該換就要換。別撐著。
justin iT邦新手 5 級 ‧ 2017-07-27 14:33:49 檢舉
這整篇也沒談到使用的版本啊
只是盡微薄的力去幫忙而已
就算已經是過時的東西
但修改 httpd.conf 確實是一個方向
不需要說話這麼不友善
所以說,說話友善了……就能夠讓你把過時的東西拋棄嗎?
不管到那都有這種說話友不友善論………
但看起來像是在討論友不友善,往往底下事實上看到的就是願不願意改變和進步的原動力,我寧願講錯被人罵,也不想誇對方態度好。
justin iT邦新手 5 級 ‧ 2017-07-27 14:52:57 檢舉
那你加油吧
本來想了一堆,但覺得都廢話。
只有四個字送你:有容乃大。
什麼都要管別人態度好不好,那就什麼事都不要做了。
justin iT邦新手 5 級 ‧ 2017-07-27 15:08:30 檢舉
送甚麼都好啦~謝謝你
既然你誠心誠意的道謝,那我就不客氣的收下了。
danielp2 iT邦新手 4 級 ‧ 2017-08-02 10:59:21 檢舉
關於上課的問題問同學不是更好嗎? 考試的問題找書本的答案才是正確答案。 如果現實, 直接用記事本(notepad++)寫PHP更好, 之後, 直接上傳server, 不用理本地設定。
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

1

我在想,你該不會不止一個專案目錄。
然後你想說跑不同的專案時能將localhost去對應不同的目錄?
基本上這樣搞雖然沒有說不行,但換個專案就要改一次對應目錄絕對不是可行的方法。
我給你的建議最好就是使用virtualhost來處理。
去找到你的httpd.conf這隻檔案
然後改成如下(加在檔案最後面,其實還有一種是另外建立vhosts.conf,不過除非你熟整個設定
基本上還是先用加在檔尾的方式加如下的內容):

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot C:\Appserv\www
</VirtualHost>

<VirtualHost *:80>
    ServerName project1.localhost
    DocumentRoot C:\Appserv\www\project1
</Virtualhost>    

為什麼原本的也要設?因為原本的你不設會因為vhost導掉的關係可能找不到目錄。
然後下面的就是我建議你切專案的作法。
用project1.localhost(project1你可以自己用自己喜歡的名稱代替)
來對應你想對應的專案的目錄,這邊要注意的事,用這個方法的話,DocumentRoot就可以
設置任何你想放置檔案的目錄位置,而不限於C:\Appserv\www底下
(改完之後要記得重啟apache,建議改之前務必先備份檔案)

不過如果你光是改這隻是沒用的。因為你的瀏覽器根本就找不到你設定的位置。
你要去C:\windows\system32\drivers\etc\下找到hosts這隻檔案(對!沒副檔名)
然後要用管理員權限去開這隻檔案(因為預設是唯讀)
進去後加上這行:

127.0.0.1    project1.localhost

加上去存檔之後就行了,不用做任何重開的動作。

會覺得太複雜???就耐心一動一動做做看吧。

看更多先前的回應...收起先前的回應...
晨勤 iT邦新手 4 級 ‧ 2017-07-26 22:38:56 檢舉

想請教 Samと可樂快跑大師,您的方法我試了還是不行...

你所謂的不行,是你做了那些事然後不行?

基本上照設定改不行,一個是你改完httpd.conf後你沒有重啟apache
。另一個是你改完hosts之後,你在網址第一次沒有加上http://
。(第一次有加的話,第二次應該瀏覽器自己就分辯得出來了。)

再來,我提到的project1只是「範例」。
你應該不會整個就照抄吧?

晨勤 iT邦新手 4 級 ‧ 2017-07-27 09:06:46 檢舉

如果在瀏覽器列輸入http://localhost/chap4.php
會出現下列訊息....
Not Found
The requested URL /chap4.php was not found on this server.

我沒有整個抄,雖然我弱...., 麻煩大師解惑,謝謝!!

你不把你目前寫的設定檔貼上來,我也不知道你寫成什麼狀況啊!
記著:發問時,貼上你編輯的內容結果很重要,除非有帳號密碼,請自行屏蔽掉!

晨勤 iT邦新手 4 級 ‧ 2017-07-27 13:00:41 檢舉

不好意思,我發現是C:\windows\system32\drivers\etc\hosts無法修改,可是我點那個檔按滑鼠右鍵,找不到管理員權限....我的電腦是win10,晚點我上網查查怎麼改,先謝謝您了。

用管理員權限開記事本,再去開那個檔案應該就可以。

晨勤 iT邦新手 4 級 ‧ 2017-07-27 19:41:54 檢舉

可是改完後,不管我資料是放在C:\AppServ\www\appproject1或是C:\appproject1,在瀏覽器列打入http://localhost/chap4.php
皆會出現
Not Found
The requested URL /chap4.php was not found on this server.
又要麻煩您了,TKS。

C:\AppServ\Apache24\conf\httpd.conf的內容如下....

This is the main Apache HTTP server configuration file. It contains the

configuration directives that give the server its instructions.

See URL:http://httpd.apache.org/docs/2.4/ for detailed information.

In particular, see

URL:http://httpd.apache.org/docs/2.4/mod/directives.html

for a discussion of each configuration directive.

Do NOT simply read the instructions in here without understanding

what they do. They're here only as hints or reminders. If you are unsure

consult the online docs. You have been warned.

Configuration and logfile names: If the filenames you specify for many

of the server's control files begin with "/" (or "drive:/" for Win32), the

server will use that explicit path. If the filenames do not begin

with "/", the value of ServerRoot is prepended -- so "logs/access_log"

with ServerRoot set to "/usr/local/apache2" will be interpreted by the

server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log"

will be interpreted as '/logs/access_log'.

NOTE: Where filenames are specified, you must use forward slashes

instead of backslashes (e.g., "c:/apache" instead of "c:\apache").

If a drive letter is omitted, the drive on which httpd.exe is located

will be used by default. It is recommended that you always supply

an explicit drive letter in absolute paths to avoid confusion.

ServerRoot: The top of the directory tree under which the server's

configuration, error, and log files are kept.

Do not add a slash at the end of the directory path. If you point

ServerRoot at a non-local disk, be sure to specify a local disk on the

Mutex directive, if file-based mutexes are used. If you wish to share the

same ServerRoot for multiple httpd daemons, you will need to change at

least PidFile.

Define SRVROOT "C:/AppServ/Apache24"
ServerRoot "${SRVROOT}"

Mutex: Allows you to set the mutex mechanism and mutex file directory

for individual mutexes, or change the global defaults

Uncomment and change the directory if mutexes are file-based and the default

mutex file directory is not on a local disk or is not appropriate for some

other reason.

Mutex default:logs

Listen: Allows you to bind Apache to specific IP addresses and/or

ports, instead of the default. See also the

directive.

Change this to Listen on specific IP addresses as shown below to

prevent Apache from glomming onto all bound IP addresses.

#Listen 12.34.56.78:80
Listen 80

Dynamic Shared Object (DSO) Support

To be able to use the functionality of a module which was built as a DSO you

have to place corresponding `LoadModule' lines at this location so the

directives contained in it are actually available before they are used.

Statically compiled modules (those listed by `httpd -l') do not need

to be loaded here.

Example:

LoadModule foo_module modules/mod_foo.so

LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule auth_form_module modules/mod_auth_form.so
#LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_core_module modules/mod_authn_core.so
#LoadModule authn_dbd_module modules/mod_authn_dbd.so
#LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_file_module modules/mod_authn_file.so
#LoadModule authn_socache_module modules/mod_authn_socache.so
#LoadModule authnz_fcgi_module modules/mod_authnz_fcgi.so
#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule authz_core_module modules/mod_authz_core.so
#LoadModule authz_dbd_module modules/mod_authz_dbd.so
#LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
#LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule buffer_module modules/mod_buffer.so
#LoadModule cache_module modules/mod_cache.so
#LoadModule cache_disk_module modules/mod_cache_disk.so
#LoadModule cache_socache_module modules/mod_cache_socache.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
LoadModule cgi_module modules/mod_cgi.so
#LoadModule charset_lite_module modules/mod_charset_lite.so
#LoadModule data_module modules/mod_data.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule dav_lock_module modules/mod_dav_lock.so
#LoadModule dbd_module modules/mod_dbd.so
#LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
#LoadModule dumpio_module modules/mod_dumpio.so
LoadModule env_module modules/mod_env.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule ext_filter_module modules/mod_ext_filter.so
#LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule filter_module modules/mod_filter.so
#LoadModule headers_module modules/mod_headers.so
#LoadModule heartbeat_module modules/mod_heartbeat.so
#LoadModule heartmonitor_module modules/mod_heartmonitor.so
#LoadModule http2_module modules/mod_http2.so
#LoadModule ident_module modules/mod_ident.so
#LoadModule imagemap_module modules/mod_imagemap.so
LoadModule include_module modules/mod_include.so
LoadModule info_module modules/mod_info.so
LoadModule isapi_module modules/mod_isapi.so
#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
#LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
#LoadModule ldap_module modules/mod_ldap.so
#LoadModule logio_module modules/mod_logio.so
LoadModule log_config_module modules/mod_log_config.so
#LoadModule log_debug_module modules/mod_log_debug.so
#LoadModule log_forensic_module modules/mod_log_forensic.so
#LoadModule lua_module modules/mod_lua.so
#LoadModule macro_module modules/mod_macro.so
LoadModule mime_module modules/mod_mime.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule negotiation_module modules/mod_negotiation.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_express_module modules/mod_proxy_express.so
#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_html_module modules/mod_proxy_html.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
#LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
#LoadModule ratelimit_module modules/mod_ratelimit.so
#LoadModule reflector_module modules/mod_reflector.so
#LoadModule remoteip_module modules/mod_remoteip.so
#LoadModule request_module modules/mod_request.so
#LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule rewrite_module modules/mod_rewrite.so
#LoadModule sed_module modules/mod_sed.so
#LoadModule session_module modules/mod_session.so
#LoadModule session_cookie_module modules/mod_session_cookie.so
#LoadModule session_crypto_module modules/mod_session_crypto.so
#LoadModule session_dbd_module modules/mod_session_dbd.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule slotmem_plain_module modules/mod_slotmem_plain.so
#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
#LoadModule socache_dbm_module modules/mod_socache_dbm.so
#LoadModule socache_memcache_module modules/mod_socache_memcache.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
#LoadModule speling_module modules/mod_speling.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule status_module modules/mod_status.so
#LoadModule substitute_module modules/mod_substitute.so
#LoadModule unique_id_module modules/mod_unique_id.so
#LoadModule userdir_module modules/mod_userdir.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule version_module modules/mod_version.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule watchdog_module modules/mod_watchdog.so
#LoadModule xml2enc_module modules/mod_xml2enc.so
LoadModule php5_module C:/AppServ/php5/php5apache2_4.dll

PHPIniDir "C:/AppServ/php5/"

'Main' server configuration

The directives in this section set up the values used by the 'main'

server, which responds to any requests that aren't handled by a

definition. These values also provide defaults for

any containers you may define later in the file.

All of these directives may appear inside containers,

in which case these default settings will be overridden for the

virtual host being defined.

ServerAdmin: Your address, where problems with the server should be

e-mailed. This address appears on some server-generated pages, such

as error documents. e.g. admin@your-domain.com

ServerAdmin admin@example.com

ServerName gives the name and port that the server uses to identify itself.

This can often be determined automatically, but we recommend you specify

it explicitly to prevent problems during startup.

If your host doesn't have a registered DNS name, enter its IP address here.

ServerName localhost:80

Deny access to the entirety of your server's filesystem. You must

explicitly permit access to web content directories in other

blocks below.

Note that from this point forward you must specifically allow

particular features to be enabled - so if something's not working as

you might expect, make sure that you have specifically enabled it

below.

DocumentRoot: The directory out of which you will serve your

documents. By default, all requests are taken from this directory, but

symbolic links and aliases may be used to point to other locations.

DocumentRoot "C:/AppServ/www"
<Directory "C:/AppServ/www">

#
# 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.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#
# 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 All

#
# Controls who can get stuff from this server.
#
Require all granted

DirectoryIndex: sets the file that Apache will serve if a directory

is requested.

The following lines prevent .htaccess and .htpasswd files from being

viewed by Web clients.

<Files ".ht*">
Require all denied

ErrorLog: The location of the error log file.

If you do not specify an ErrorLog directive within a

container, error messages relating to that virtual host will be

logged here. If you do define an error logfile for a

container, that host's errors will be logged there and not here.

ErrorLog "logs/error.log"

LogLevel: Control the number of messages logged to the error_log.

Possible values include: debug, info, notice, warn, error, crit,

alert, emerg.

LogLevel warn

<IfModule logio_module>
  # You need to enable mod_logio.c to use %I and %O
  LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>

#
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a <VirtualHost>
# container, they will be logged here.  Contrariwise, if you *do*
# define per-<VirtualHost> access logfiles, transactions will be
# logged therein and *not* in this file.
#
CustomLog "logs/access.log" common

#
# If you prefer a logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#
#CustomLog "logs/access.log" combined
#
# Alias: Maps web paths into filesystem paths and is used to
# access content that does not live under the DocumentRoot.
# Example:
# Alias /webpath /full/filesystem/path
#
# If you include a trailing / on /webpath then the server will
# require it to be present in the URL.  You will also likely
# need to provide a <Directory> section to allow access to
# the filesystem path.

#
# ScriptAlias: This controls which directories contain server scripts. 
# ScriptAliases are essentially the same as Aliases, except that
# documents in the target directory are treated as applications and
# run by the server when requested rather than as documents sent to the
# client.  The same rules about trailing "/" apply to ScriptAlias
# directives as to Alias.
#
ScriptAlias /cgi-bin/ "${SRVROOT}/cgi-bin/"

"${SRVROOT}/cgi-bin" should be changed to whatever your ScriptAliased

CGI directory exists, if you have that configured.

<Directory "${SRVROOT}/cgi-bin">
AllowOverride None
Options None
Require all granted

#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
#AddHandler cgi-script .cgi .pl

# For type maps (negotiated resources):
#AddHandler type-map var

#
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
#AddType text/html .shtml
#AddOutputFilter INCLUDES .shtml

The mod_mime_magic module allows the server to use various hints from the

contents of the file itself to determine its type. The MIMEMagicFile

directive tells the module where the hint definitions are located.

#MIMEMagicFile conf/magic

Customizable error responses come in three flavors:

1) plain text 2) local redirects 3) external redirects

Some examples:

#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html

MaxRanges: Maximum number of Ranges in a request before

returning the entire resource, or one of the special

values 'default', 'none' or 'unlimited'.

Default setting is to accept 200 Ranges.

#MaxRanges unlimited

EnableMMAP and EnableSendfile: On systems that support it,

memory-mapping or the sendfile syscall may be used to deliver

files. This usually improves server performance, but must

be turned off when serving from networked-mounted

filesystems or if support for these functions is otherwise

broken on your system.

Defaults: EnableMMAP On, EnableSendfile Off

#EnableMMAP off
#EnableSendfile on

#AcceptFilter http none
#AcceptFilter https none

Supplemental configuration

The configuration files in the conf/extra/ directory can be

included to add extra features or to modify the default configuration of

the server, or you may simply copy their contents here and change as

necessary.

Server-pool management (MPM specific)

#Include conf/extra/httpd-mpm.conf

Multi-language error messages

#Include conf/extra/httpd-multilang-errordoc.conf

Fancy directory listings

Include conf/extra/httpd-autoindex.conf

Language settings

#Include conf/extra/httpd-languages.conf

User home directories

#Include conf/extra/httpd-userdir.conf

Real-time info on requests and configuration

Include conf/extra/httpd-info.conf

Virtual hosts

Include conf/extra/httpd-vhosts.conf

Local access to the Apache HTTP Server Manual

#Include conf/extra/httpd-manual.conf

Distributed authoring and versioning (WebDAV)

#Include conf/extra/httpd-dav.conf

Various default settings

#Include conf/extra/httpd-default.conf

Configure mod_proxy_html to understand HTML4/XHTML1

Secure (SSL/TLS) connections

Note: The following must must be present to support

starting without SSL on platforms with no /dev/random equivalent

but a statically compiled-in mod_ssl.

<VirtualHost *:80>
ServerName localhost
DocumentRoot C:\Appserv\www

<VirtualHost *:80>
ServerName Appproject1.localhost
DocumentRoot C:\Appproject1

C:\Windows\System32\drivers\etc\hosts的內容如下....

Copyright (c) 1993-2009 Microsoft Corp.

This is a sample HOSTS file used by Microsoft TCP/IP for Windows.

This file contains the mappings of IP addresses to host names. Each

entry should be kept on an individual line. The IP address should

be placed in the first column followed by the corresponding host name.

The IP address and the host name should be separated by at least one

space.

Additionally, comments (such as these) may be inserted on individual

lines or following the machine name denoted by a '#' symbol.

For example:

102.54.94.97 rhino.acme.com # source server

38.25.63.10 x.acme.com # x client host

localhost name resolution is handled within DNS itself.

127.0.0.1 localhost

::1 localhost

127.0.0.1 3dns-2.adobe.com #192.150.22.22
127.0.0.1 3dns-3.adobe.com #192.150.14.21
127.0.0.1 3dns-4.adobe.com #192.150.18.247
127.0.0.1 3dns-5.adobe.com #192.150.22.46
127.0.0.1 adobe-dns.adobe.com #192.150.11.30
127.0.0.1 adobe-dns-2.adobe.com #192.150.11.247
127.0.0.1 adobe-dns-3.adobe.com #192.150.22.30
127.0.0.1 adobe.activate.com #69.175.22.26
127.0.0.1 activate.adobe.com #192.150.22.40
127.0.0.1 activate.wip3.adobe.com #192.150.22.40
127.0.0.1 activate.wip4.adobe.com #192.150.22.40
127.0.0.1 activate-sea.adobe.com #192.150.22.40
127.0.0.1 activate-sjc0.adobe.com #192.150.14.69
127.0.0.1 ereg.adobe.com #192.150.18.103
127.0.0.1 ereg.wip3.adobe.com #192.150.18.63
127.0.0.1 ereg.wip4.adobe.com #192.150.18.103
127.0.0.1 practivate.adobe.com #192.150.18.54
127.0.0.1 www.wip3.adobe.com #192.150.8.60
127.0.0.1 www.wip4.adobe.com #192.150.18.200
127.0.0.1 www.adobeereg.com #75.125.24.83
127.0.0.1 adobeereg.com #207.66.2.10
127.0.0.1 hl2rcv.adobe.com #192.150.14.174
127.0.0.1 wwis-dubc1-vip30.adobe.com #192.150.8.30
127.0.0.1 wwis-dubc1-vip31.adobe.com #192.150.8.31
127.0.0.1 wwis-dubc1-vip32.adobe.com #192.150.8.32
127.0.0.1 wwis-dubc1-vip33.adobe.com #192.150.8.33
127.0.0.1 wwis-dubc1-vip34.adobe.com #192.150.8.34
127.0.0.1 wwis-dubc1-vip35.adobe.com #192.150.8.35
127.0.0.1 wwis-dubc1-vip36.adobe.com #192.150.8.36
127.0.0.1 wwis-dubc1-vip37.adobe.com #192.150.8.37
127.0.0.1 wwis-dubc1-vip38.adobe.com #192.150.8.38
127.0.0.1 wwis-dubc1-vip39.adobe.com #192.150.8.39
127.0.0.1 wwis-dubc1-vip40.adobe.com #192.150.8.30
127.0.0.1 wwis-dubc1-vip41.adobe.com #192.150.8.41
127.0.0.1 wwis-dubc1-vip42.adobe.com #192.150.8.42
127.0.0.1 wwis-dubc1-vip43.adobe.com #192.150.8.43
127.0.0.1 wwis-dubc1-vip44.adobe.com #192.150.8.44
127.0.0.1 wwis-dubc1-vip45.adobe.com #192.150.8.45
127.0.0.1 wwis-dubc1-vip46.adobe.com #192.150.8.46
127.0.0.1 wwis-dubc1-vip47.adobe.com #192.150.8.47
127.0.0.1 wwis-dubc1-vip48.adobe.com #192.150.8.48
127.0.0.1 wwis-dubc1-vip49.adobe.com #192.150.8.49
127.0.0.1 wwis-dubc1-vip50.adobe.com #192.150.8.50
127.0.0.1 wwis-dubc1-vip51.adobe.com #192.150.8.51
127.0.0.1 wwis-dubc1-vip52.adobe.com #192.150.8.52
127.0.0.1 wwis-dubc1-vip53.adobe.com #192.150.8.53
127.0.0.1 wwis-dubc1-vip54.adobe.com #192.150.8.54
127.0.0.1 wwis-dubc1-vip55.adobe.com #192.150.8.55
127.0.0.1 wwis-dubc1-vip56.adobe.com #192.150.8.56
127.0.0.1 wwis-dubc1-vip57.adobe.com #192.150.8.57
127.0.0.1 wwis-dubc1-vip58.adobe.com #192.150.8.58
127.0.0.1 wwis-dubc1-vip59.adobe.com #192.150.8.59
127.0.0.1 wwis-dubc1-vip60.adobe.com #192.150.8.60
127.0.0.1 wwis-dubc1-vip61.adobe.com #192.150.8.61
127.0.0.1 wwis-dubc1-vip62.adobe.com #192.150.8.62
127.0.0.1 wwis-dubc1-vip63.adobe.com #192.150.8.63
127.0.0.1 wwis-dubc1-vip64.adobe.com #192.150.8.64
127.0.0.1 wwis-dubc1-vip65.adobe.com #192.150.8.65
127.0.0.1 wwis-dubc1-vip66.adobe.com #192.150.8.66
127.0.0.1 wwis-dubc1-vip67.adobe.com #192.150.8.67
127.0.0.1 wwis-dubc1-vip68.adobe.com #192.150.8.68
127.0.0.1 wwis-dubc1-vip69.adobe.com #192.150.8.69
127.0.0.1 wwis-dubc1-vip70.adobe.com #192.150.8.70
127.0.0.1 wwis-dubc1-vip71.adobe.com #192.150.8.71
127.0.0.1 wwis-dubc1-vip72.adobe.com #192.150.8.72
127.0.0.1 wwis-dubc1-vip73.adobe.com #192.150.8.73
127.0.0.1 wwis-dubc1-vip74.adobe.com #192.150.8.74
127.0.0.1 wwis-dubc1-vip75.adobe.com #192.150.8.75
127.0.0.1 wwis-dubc1-vip76.adobe.com #192.150.8.76
127.0.0.1 wwis-dubc1-vip77.adobe.com #192.150.8.77
127.0.0.1 wwis-dubc1-vip78.adobe.com #192.150.8.78
127.0.0.1 wwis-dubc1-vip79.adobe.com #192.150.8.79
127.0.0.1 wwis-dubc1-vip80.adobe.com #192.150.8.80
127.0.0.1 wwis-dubc1-vip81.adobe.com #192.150.8.81
127.0.0.1 wwis-dubc1-vip82.adobe.com #192.150.8.82
127.0.0.1 wwis-dubc1-vip83.adobe.com #192.150.8.83
127.0.0.1 wwis-dubc1-vip84.adobe.com #192.150.8.84
127.0.0.1 wwis-dubc1-vip85.adobe.com #192.150.8.85
127.0.0.1 wwis-dubc1-vip86.adobe.com #192.150.8.86
127.0.0.1 wwis-dubc1-vip87.adobe.com #192.150.8.87
127.0.0.1 wwis-dubc1-vip88.adobe.com #192.150.8.88
127.0.0.1 wwis-dubc1-vip89.adobe.com #192.150.8.89
127.0.0.1 wwis-dubc1-vip90.adobe.com #192.150.8.90
127.0.0.1 wwis-dubc1-vip91.adobe.com #192.150.8.91
127.0.0.1 wwis-dubc1-vip92.adobe.com #192.150.8.92
127.0.0.1 wwis-dubc1-vip93.adobe.com #192.150.8.93
127.0.0.1 wwis-dubc1-vip94.adobe.com #192.150.8.94
127.0.0.1 wwis-dubc1-vip95.adobe.com #192.150.8.95
127.0.0.1 wwis-dubc1-vip96.adobe.com #192.150.8.96
127.0.0.1 wwis-dubc1-vip97.adobe.com #192.150.8.97
127.0.0.1 wwis-dubc1-vip98.adobe.com #192.150.8.98
127.0.0.1 wwis-dubc1-vip99.adobe.com #192.150.8.99
127.0.0.1 wwis-dubc1-vip100.adobe.com #192.150.8.100
127.0.0.1 wwis-dubc1-vip101.adobe.com #192.150.8.101
127.0.0.1 wwis-dubc1-vip102.adobe.com #192.150.8.102
127.0.0.1 wwis-dubc1-vip103.adobe.com #192.150.8.103
127.0.0.1 wwis-dubc1-vip104.adobe.com #192.150.8.104
127.0.0.1 wwis-dubc1-vip105.adobe.com #192.150.8.105
127.0.0.1 wwis-dubc1-vip106.adobe.com #192.150.8.106
127.0.0.1 wwis-dubc1-vip107.adobe.com #192.150.8.107
127.0.0.1 wwis-dubc1-vip108.adobe.com #192.150.8.108
127.0.0.1 wwis-dubc1-vip109.adobe.com #192.150.8.109
127.0.0.1 wwis-dubc1-vip110.adobe.com #192.150.8.110
127.0.0.1 wwis-dubc1-vip111.adobe.com #192.150.8.111
127.0.0.1 wwis-dubc1-vip112.adobe.com #192.150.8.112
127.0.0.1 wwis-dubc1-vip113.adobe.com #192.150.8.113
127.0.0.1 wwis-dubc1-vip114.adobe.com #192.150.8.114
127.0.0.1 wwis-dubc1-vip115.adobe.com #192.150.8.115
127.0.0.1 wwis-dubc1-vip116.adobe.com #192.150.8.116
127.0.0.1 wwis-dubc1-vip117.adobe.com #192.150.8.117
127.0.0.1 wwis-dubc1-vip118.adobe.com #192.150.8.118
127.0.0.1 wwis-dubc1-vip119.adobe.com #192.150.8.119
127.0.0.1 wwis-dubc1-vip120.adobe.com #192.150.8.120
127.0.0.1 wwis-dubc1-vip121.adobe.com #192.150.8.121
127.0.0.1 wwis-dubc1-vip122.adobe.com #192.150.8.122
127.0.0.1 wwis-dubc1-vip123.adobe.com #192.150.8.123
127.0.0.1 wwis-dubc1-vip124.adobe.com #192.150.8.124
127.0.0.1 wwis-dubc1-vip125.adobe.com #192.150.8.125
127.0.0.1 appproject1.localhost

...
我說你貼這一大串……
你只要貼你的hosts跟你加在httpd.conf中的我給你的VirtualHost的範例就可以了。
我主要要看就這二個東西……
希望你待會的回應,是確實給我這二樣東西。
其他的東西不必要的請先不要貼。

好吧!我還真的好不容易才大海撈針撈到…

<VirtualHost *:80>
ServerName localhost
DocumentRoot C:\Appserv\www
<VirtualHost *:80>
ServerName Appproject1.localhost
DocumentRoot C:\Appproject1

你這樣改……照理說你應該連AppServ都開不起來吧!
雖然我不確定是你的問題還是站方編輯器過濾的問題
完整應該如下:

<VirtualHost *:80>
ServerName localhost
DocumentRoot C:\Appserv\www
</VirtualHost>

<VirtualHost *:80>
ServerName appproject1.localhost
DocumentRoot C:\Appproject1
</VirtualHost>

你確定沒有少掉?
另外改完後你有重開apache嗎?
另外就是我不確定windows的大小寫會不會有分就是了…
建議大小寫也統一一下。
(我沒辦法幫你確認,因為我是用mac os)

記住,改完設定一定要重開apache是基本課題,很多人都常常忘記。

晨勤 iT邦新手 4 級 ‧ 2017-07-31 10:22:06 檢舉

sorry...讓您費眼力了,報告一下,其實我設的跟您上述的一樣,但是後來我發現,如果槓掉第一個設定,

<VirtualHost *:80>
ServerName localhost
DocumentRoot C:\Appserv\www

就可以正常運作,如果加上,就會出現如下

Forbidden

You don't have permission to access / on this server.

晨勤 iT邦新手 4 級 ‧ 2017-07-31 10:23:26 檢舉

上面我有加上,奇怪,貼的時候它會自動不見了....

你要用程式碼標籤標注,才不會消失。不然會被留言功能給濾掉。
另外我想你的問題就是權限了。
但是你原本貼的太亂,可以用程式碼標籤再貼一次?

還有,為什麼你的hosts中的

#127.0.0.1  localhost

為什麼是被註解的??

晨勤 iT邦新手 4 級 ‧ 2017-07-31 22:27:26 檢舉

我也不知道,它本來就這樣了,我改後好像也不行,我再貼一次檔好了,再麻煩您了。

我要發表回答

立即登入回答