在Linux上安裝XAMPP並配置虛擬主機備忘
阿新 • • 發佈:2018-11-12
1. 到https://www.apachefriends.org/zh_cn/index.html去下載最新版本,注意x86還是x64
預設資訊如下:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/opt/lampp/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
修改域名等配置資訊,然後增加目錄訪問許可權,增加許可權時只需要到httpd.conf中找到<Directory "/opt/lampp/htdocs"></Directory>
把這個標籤連帶內容拷貝過來,同時修改一下目錄即可
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/opt/webdocs/test"
ServerName aa.test.com
ErrorLog "logs/aa.test.com-error_log"
CustomLog "logs/aa.test.com-access_log" common
<Directory "/opt/webdocs/test">
#
# 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/trunk/mod/core.html#options
# for more information.
#
#Options Indexes FollowSymLinks
# XAMPP
Options Indexes FollowSymLinks ExecCGI Includes
#
# 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
# since XAMPP 1.4:
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
</VirtualHost>
2. 下載存放到任意位置,我這裡存到 /home下,接下來修改安裝檔案許可權,為方便直接賦予777 chmod 777 xampp-linux-x64-5.6.32-0-installer.run
3. 執行./xampp-linux-x64-5.6.32-0-installer.run,預設安裝即可
4. 這裡要注意,我原本想安裝到一塊外掛的SSD硬碟目錄,結果查了很多資料都沒有找到方法,只好把/opt目錄mount到SSD硬碟了
5. 安裝完畢後配置一下/opt/lampp/etc/httpd.conf, 去掉Include etc/extra/httpd-vhosts.conf之前的#,使虛擬配置檔案生效
6. 編輯/opt/lampp/etc/extra/httpd-vhosts.conf檔案
預設資訊如下:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/opt/lampp/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
修改域名等配置資訊,然後增加目錄訪問許可權,增加許可權時只需要到httpd.conf中找到<Directory "/opt/lampp/htdocs"></Directory>
把這個標籤連帶內容拷貝過來,同時修改一下目錄即可
<VirtualHost *:80>
DocumentRoot "/opt/webdocs/test"
ServerName aa.test.com
ErrorLog "logs/aa.test.com-error_log"
CustomLog "logs/aa.test.com-access_log" common
<Directory "/opt/webdocs/test">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#
# 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/trunk/mod/core.html#options
# for more information.
#
#Options Indexes FollowSymLinks
# XAMPP
Options Indexes FollowSymLinks ExecCGI Includes
#
# 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
# since XAMPP 1.4:
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
</VirtualHost>