設定檔位置:/etc/apache2/
啟動檔:/etc/init.d/apache2
啟動使用者網站與PHP功能
sudo a2enmod userdir
cd /etc/apache2/mods-available/
sudo vi php5.conf(把以下的設定comment起來)
#<IfModule mod_userdir.c>
# <Directory /home/*/public_html>
# php_admin_value engine Off
# </Directory>
#</IfModule>
sudo /etc/init.d/apache2 restart
測試:
mkdir ~/public_html
cd public_html
echo "<?php phpinfo();?>" > info.php
2011年10月15日 星期六
2011年1月24日 星期一
使用者啟動php
vi php5.conf
<IfModule mod_php5.c>
<FilesMatch "\.ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
#註解掉
# <IfModule mod_userdir.c>
# <Directory /home/*/public_html>
# php_admin_value engine Off
# </Directory>
# </IfModule>
</IfModule>
/etc/init.d/apache2 restart
<IfModule mod_php5.c>
<FilesMatch "\.ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
#註解掉
# <IfModule mod_userdir.c>
# <Directory /home/*/public_html>
# php_admin_value engine Off
# </Directory>
# </IfModule>
</IfModule>
/etc/init.d/apache2 restart
2011年1月22日 星期六
ubuntu環境apache設定
apt-get install apache2 libapache2-mod-php5 php5-cli php5-common php5-cgi
--------------------------------------------
/etc/apache2/apache2.conf 這是apache 的全域設定
/etc/apache2/httpd.conf 內容為空,傳統的設定檔,為相容於其它版本的設定
/etc/apache2/ports.conf 監聽 port 的設定
/etc/apache2/mods-available/ 所有可用的模組( module)
/etc/apache2/mods-enabled/ 已啟用的模組 (可用指令 a2enmod、a2dismod 來啟用、停用模組)
/etc/apache2/sites-available/ 所有可用虛擬站台
/etc/apache2/sites-enabled/ 己啟用的虛擬站台 (指令 a2ensite、a2dissite 可啟用、停用虛擬站台)
/etc/apache2/httpd.conf 內容為空,傳統的設定檔,為相容於其它版本的設定
/etc/apache2/ports.conf 監聽 port 的設定
/etc/apache2/mods-available/ 所有可用的模組( module)
/etc/apache2/mods-enabled/ 已啟用的模組 (可用指令 a2enmod、a2dismod 來啟用、停用模組)
/etc/apache2/sites-available/ 所有可用虛擬站台
/etc/apache2/sites-enabled/ 己啟用的虛擬站台 (指令 a2ensite、a2dissite 可啟用、停用虛擬站台)
-----------
啟動、停止、重啟 apache 等指令
/etc/init.d/apache2 start | stop | restart
apache 設定檔測試指令 (apache 設定檔的語法若寫錯,會使apache無法啟動,可用此指令測試)
apache2ctl configtest
/etc/init.d/apache2 start | stop | restart
apache 設定檔測試指令 (apache 設定檔的語法若寫錯,會使apache無法啟動,可用此指令測試)
apache2ctl configtest
/etc/rc.d/init.d/httpd start | stop | restart
---------------
開機就啟動的設定在
/etc/default/apache2
預設是開機啟動 (NO_START=0),不想開機啟動請改成 1
/etc/default/apache2
預設是開機啟動 (NO_START=0),不想開機啟動請改成 1
--------------------
位置 /etc/apache2/apache2.conf
Listen 80 port的設定
在apache2.conf 有一行 Include /etc/apache2/ports.conf
vim /etc/apache2/ports.conf 加入你要監聽的port
預設的使用者與群組
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
debian環境apache 啟動的身份與群組皆為 www-data
-----------------------------
目錄加密碼
有兩種方法,一設定在 apache 檔內。二目錄底下設定一個 .htaccess 檔。
a.編輯 apache 設定檔
vim /etc/apache2/apache2.conf
vim /etc/apache2/apache2.conf
例如,我們有兩個目錄要加密碼保護,分別為 /mydata1和 /mytada2
apache 設定檔內加入
#受密碼保護的目錄
<Directory "/mydata1">
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
<Directory "/mydata2">
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
<Directory "/mydata1">
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
<Directory "/mydata2">
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
-----------------------------------
檢查 apache2.conf 設定檔內是否還有同一目錄的設定,
若有請把它加#號,否則密碼保護無法成功。
例如: /mydata1 是對應到 /var/www/84/mydata1/wwwroot 這目錄,
但這目錄也有針對它的設定必須將其取消
否則密碼保護不會設定成功。
#<Directory "/var/www/84/mydata1/wwwroot">
# Options None
# AllowOverride None
# Order allow,deny
# Allow from all
#</Directory>
設完之後重啟 apache
/etc/init.d/apache2 restart
------------------
建密碼檔
建一密碼檔名為apache.passwd 存放在 /home/backup
htpasswd -c /home/backup/apache.passwd user1
接著輸入密碼 xxxxxxxx
密碼檔內建第二個使用者 (不加 -c 參數了)
htpasswd /home/backup/apache.passwd user2
註:user1和user2為你自訂的使用者帳號,xxxxx為你自訂的密碼
改變檔案屬性
chown www /home/backup/apache.passwd
chgrp users /home/backup/apache.passwd
在要被保護的目錄下建.htaccess檔
先進到你要密碼保護的目錄底下
cd /var/www/84/mydata1/wwwroot/
vim .htaccess
=====加入以下內容==================
AuthName "This is Private directory"
Authtype Basic
AuthUserFile /home/backup/apache.passwd
require user user1 user2
#require:後面接可以使用的帳號。
#如果要讓該密碼檔內的使用者都能夠登入,就改成『require valid-user』即可
===================================
改變檔案屬性
chown www .htaccess
chgrp users .htaccess
然後再把此檔copy到你要密碼保護的 另一個目錄底下去
cp .htaccess /usr/share/mydata2/site
否則密碼保護不會設定成功。
#<Directory "/var/www/84/mydata1/wwwroot">
# Options None
# AllowOverride None
# Order allow,deny
# Allow from all
#</Directory>
設完之後重啟 apache
/etc/init.d/apache2 restart
------------------
建密碼檔
建一密碼檔名為apache.passwd 存放在 /home/backup
htpasswd -c /home/backup/apache.passwd user1
接著輸入密碼 xxxxxxxx
密碼檔內建第二個使用者 (不加 -c 參數了)
htpasswd /home/backup/apache.passwd user2
註:user1和user2為你自訂的使用者帳號,xxxxx為你自訂的密碼
改變檔案屬性
chown www /home/backup/apache.passwd
chgrp users /home/backup/apache.passwd
在要被保護的目錄下建.htaccess檔
先進到你要密碼保護的目錄底下
cd /var/www/84/mydata1/wwwroot/
vim .htaccess
=====加入以下內容==================
AuthName "This is Private directory"
Authtype Basic
AuthUserFile /home/backup/apache.passwd
require user user1 user2
#require:後面接可以使用的帳號。
#如果要讓該密碼檔內的使用者都能夠登入,就改成『require valid-user』即可
===================================
改變檔案屬性
chown www .htaccess
chgrp users .htaccess
然後再把此檔copy到你要密碼保護的 另一個目錄底下去
cp .htaccess /usr/share/mydata2/site
2011年1月21日 星期五
Ubuntu支援asp
安裝mono
sudo apt-get install mono-gmcs mono-xsp2 libapache2-mod-mono mono-apache-server2
sudo a2enmod mod_mono
sudo a2enmod mod_mono
sudo dpkg --configure -a
sudo vi /etc/apache2/mods-available/mod_mono.conf
Include /etc/mono-server2/mono-server2-hosts.conf
sudo /etc/init.d/apache2 restart
-------------
查看mono版本
mono -V
訂閱:
文章 (Atom)