Powered By Blogger
Showing posts with label apache. Show all posts
Showing posts with label apache. Show all posts

16 September 2014

Apache Web Server : การซ่อนไฟล์บางไฟล์จาก Web Folder ด้วย .htaccess


ป้องกัน ไม่ให้แสดง file *.php และ รูปภาพบางอย่าง 











จะแสดงทั้งข้อมูล ใน Folder ทั้งหมด ยกเว้น File นามสกุล .gif , .png และ .php 
ส่วนไฟล์อื่นๆเช่น  file .txt จะแสดงรายการไว้  

(แม้ไม่แสดงชื่อไฟล์แต่จะยังเข้าถึงไฟล์นี้ผ่าน url ได้อยู่ นะครับ )


ตัวอย่างเช่นสร้าง File ดังนี้  ใน Folder 













จะเห็น   ใน Browser ดังนี้



















นั่นคือ จะเห็นได้ว่า  Web Sever จะแสดงเฉพาะไฟล์ที่ไม่อยู่ในรายการ
โดย ไฟล์ .htaccess จะอยู่เพียง ใน Folder myinfo
แล้ว Folder  myinfo\folder1 จะ สืบทอดการตั้งค่าแสดงผลของ .htaccess มาด้วย

ดังนั้นทั้ง 2 folder จะเห็นเพียง file .txt เท่านั้นทั้งๆที่มีทั้ง ไฟล์ .txt และ .php

แต่นี่ไม่ใช่การป้องกันการเข้าถึงไฟล์ a1.php นะครับ  ยังสามารถเรียกใช้ได้ตามปกติ 
เพียงแค่ไม่ให้แสดงใน Index เท่านั้น 



04 April 2011

apache mod_rewrite

เอกสารภาษาไทย
http://httpd.apache.org/docs/current/mod/mod_rewrite.html

http://www.scriptdd.com/webtip/apache-mod-rewrite-easy-url.html

http://forum.datatan.net/index.php/topic,377.0.html

http://www.thaiseoboard.com/index.php?topic=3675.0

http://www.dek-ac.com/d-sign2u/knowledge24-%E0%B8%97%E0%B8%B3-SEO-%E0%B9%83%E0%B8%AB%E0%B9%89-URL-%E0%B9%82%E0%B8%94%E0%B8%A2%E0%B9%83%E0%B8%8A%E0%B9%89-Mod_Rewrite.html

http://www.siamfocus.com/content.php?slide=1&content=160


mod_rewrite สำหรับ CakePHP Framework
http://www.cakephp.in.th/index.php?topic=9.0

สำหรับ joomla
http://www.joomlathaiclub.com/joomla/basic/basic/648-test-mod-rewrite

บน Ubuntu
http://kiterminal.com/blog/content/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%97%E0%B8%B3%E0%B9%83%E0%B8%AB%E0%B9%89-apache2-%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%87%E0%B8%B2%E0%B8%99-modrewrite-%E0%B8%9A%E0%B8%99-ubuntu-810

Debug Mode
http://kiterminal.com/blog/content/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%97%E0%B8%B3%E0%B9%83%E0%B8%AB%E0%B9%89-apache2-%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%87%E0%B8%B2%E0%B8%99-modrewrite-%E0%B8%9A%E0%B8%99-ubuntu-810

ตัวอย่าง .htaccess
http://www.narongrit.net/download-free-mod-rewrite-code-of-narongrit-dot-net.html

บน IIS
http://www.narisa.com/forums/index.php?showtopic=24116


WordPress
http://www.autthapon.in.th/tag/mod_rewrite/

เอกสารของ Apache Httpd Server
http://httpd.apache.org/docs/current/mod/mod_rewrite.html

01 April 2011

Link วิธีติดตั้ง PHP 5.3 ให้กับ Apache Web Server (on windows)

พบปัญหาการใช้งาน AppServe ( http://www.appservnetwork.com )  บน Windows

คือไม่มี Package PHP5.3 พบแต่  PHP 5.2

บาง PHP Framework รองรับการทำงานเฉพาะ PHP5.3 ขึ้นไป

จึงต้องหา Solution ในการติดตั้ง PHP5.3 บน Apache ที่ได้ติดตั้ง ด้วย appserv ไว้แล้ว
พบว่า ไกล้เคียงที่สุดคือ Link ต่อไปนี้

http://webdevcodex.com/tutorial-installing-apache2-php5-mysql5-phpmyadmin3-windows-7-vista/#installphp

 ซึ่ง Link นี้จะช่วยให้เข้าใจ การติดตั้ง  Apache + PHP  บน สภาพแวดล้อม Windows ด้วย

รวมทั้ง หากติดตั้งใน Linux Server  CentOS จะมีการติดตั้ง PHP Package มาตรฐานมาให้
ซึ่งจะเป็น PHP5.1 ซึ่งไม่ สามารถใช้กับ บาง PHP Framework ได้ จึงอาจต้องติดตั้งใหม่
ซึ่งจากตัวอย่างนี้ จะเป็นแนวทางได้ แม้จะไม่ทั้งหมด

24 March 2011

Apache web server with SSL , mod_ssl

ข้อมูลการติดตั้ง  OpenSSL บน Apache WebServer (httpd server ) บน Windows

Thai Admin
http://www.thaiadmin.org/board/index.php?topic=48282.0

วิธีการ สร้าง Certificate .. ข้อมูลเก่าหน่อย
http://www.neilstuff.com/apache/apache2-ssl-windows.htm

OpenSSL มีทั้งบน Linux และ Windows

Windows Binary
http://www.openssl.org/related/binaries.html


การสร้าง Certificate / Key บน Apache Web Server โดยใช้กับ OpenSSL
บน Server Ubuntu
https://help.ubuntu.com/6.06/ubuntu/serverguide/C/httpd.html

Apache2 ::  mod_ssl  document
http://httpd.apache.org/docs/2.0/mod/mod_ssl.html

15 January 2011

ติดตั้ง AWStats

ค้นหาจาก  Google ได้ดังนี้ครับ

มันทำงานกับ Perl นะครับ

บน OpenBSD
http://puffer.sru.ac.th/OpenBSD/awstats

บน FreeBSD
http://www.thaiadmin.org/board/index.php?topic=94334.0
http://jakyjoon.blogspot.com/2008/12/awstats-log.html
เก่าหน่อย -> http://www.bandhit.com/webboard/viewtopic.php?t=50
FreeBSD (FTP,PDF ) --> http://www.uboninfo.net/board/index.php?topic=2890.0


บน Windows ( Apache WebServer ด้วย  AppServe Setup Packeage )
http://thichaiit.mobile.spaces.live.com/entry.aspx?h=cns!76FBB38BF33ED972!307&fp=/arc.aspx

บน Windows ( บน IIS Webserver )
http://www.joezine.com/node/1050/install-awstats-on-iis7

CentOS

    แนะนำลิงค์ที่เขียนว่า Prefer
    แต่ที่ต้องทำเพิ่มคือ การกำหนด config file ดังนี้ั
    ตัวอย่างนี้จะทำเพื่อดูที่ http://localhost/awstats/awstats.pl     คือรันจากเครื่อง localhost ดูได้เท่านั้น

cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.localhost.conf

ตัวอย่างแก้ไขแฟ้ม/etc/awstats/awstats.localhost.conf
ให้เหมาะกับ apache ดังนี้คือ

LogFile="/var/log/httpd/access_log"
LogType=W
LogFormat=1
SiteDomain="localhost"
HostAliases="localhost 127.0.0.1"
DirData="/var/lib/awstats"
DirCgi="/awstats"
DirIcons="/awstatsicons"
อาจแก้ไขโดยใช้
#gedit  ชื่อfile
#gedit  /etc/awstats/awstats.localhost.conf

สั่งสร้างฐานข้อมูลสถิติด้วย
perl /var/www/awstats/awstats.pl - config=localhost -update

กับสร้าง รายงาน static ด้วย

perl /var/www/awstats/awstats.pl - config=localhost -output - staticlinks >/var/www/html/awstats.myhttp.html


แล้ว restart apache (httpd) ใหม่

หมายเหตุ : ถ้า host เป็น IP อาจต้องสร้าง file เช่น /etc/awstats/awstats.192.168.1.35.conf กรณีที่ Host เป็น 192.168.1.35

บน Ubuntu


Fedora




แถมติดตั้ง FTP
http://puffer.sru.ac.th/OpenBSD/vsftpd

29 December 2010

CentOS Web Server + FTP Server

Setup Linux CentOS สำหรับ ทำ FTP Server
+ Web Server + php

http://202.143.161.22/linux/CentOS.htm

http://www.eak.in.th/2009/12/04/%E0%B8%95%E0%B8%B4%E0%B8%94%E0%B8%95%E0%B8%B1%E0%B9%89%E0%B8%87-centos-%E0%B9%81%E0%B8%A5%E0%B8%B0-web-server-packages/

CentOS with FTP
http://www.linuxthai.org/forum/index.php?topic=6795.0

FTP Server บน Fodera Core
http://www.linuxlane.com/vsftpd-fedora-core-6-server/


SSH
http://www.howtoconfig.com/os/ubuntu/ssh-login-without-password.html

2Way PKI + PHP
http://www.howtoconfig.com/development/php-2way-encrypt-pki-openssl.html


PXE Server
http://www.howtoconfig.com/os/ubuntu/network-install-via-pxe-server.html

Squid Reverse Proxy
http://www.howtoconfig.com/os/ubuntu/how-to-implement-squid-reverse-proxy.html

Authen Log
http://www.linuxthai.org/forum/index.php?topic=7605.0


eBook อื่นๆ ยังไม่ได้ลองโหลด
http://ebook-ubuntu.blogspot.com/2010/01/install-xen-centos-53.html


--------------------------------------------------------
OS อื่นๆ

WebDav Protocol บน SuSE   + แสดง Architech เบื้องต้น
http://www.playoss.com/node/111

ติดตั้ง WebDAV บน Apache
http://www.thaitux.info/test/node/38
http://www.thaitux.info/test/taxonomy/term/49

ลอง WebDav กับ Apache
http://vuthi.blogspot.com/2004/12/webdav-apache.html

------------------------------------------------------------
Apache Security
http://www.thaicert.nectec.or.th/paper/unix_linux/apache_sec1_1.php

10 October 2010

setup apache2 on ubuntu-server 6

************************************************************************
Note by Thitipong samranvanit  
Ubuntu Server , Install with LAMP 
Sun VM VirtualBox , ver 3.2.8 
Date  9 / 10 / 2010   
Document tools : Ubuntu Server + vi  ( 6 )
************************************************************************
I download LiveCD-Server6 from Ubuntu 
and Install In HD ( Oracle VirtualBox )

set ipconfig by  

 # ifconfig eth0 192.168.1.102  netmask 255.255.255.0  up 

set default gateway by 
 # route add default via 192.168.1.1 

In my machin  use  Oracle VirtualBox 

1 NetworkCard is Bridge Mode , Adapter1 as Bridge Adapter , Cable Connected
2 , Adapther 2 as NAT  , Cable not connected

I start ping gateway by ping  192.168.1.1 
and after success , then ping  www.google.co.th

end ping process by  Ctrl + C  (  must  LEFT Ctrl in VirtualBox  )

******************************
Apache2
******************************
Apache2 is in /etc/Apache2
config not in  /etc/apache2/httpd.conf
But  config in /etc/apache2/apache2.conf 

root directory is in 
/var/www 

You must copy file from  /var/www/default-www/*.html.en  to  /var/www by "cp"
and copy *.gif ,*.png from /var/www/default-ww/*.* to /var/www
then rename *.html.en to *.html   by  command "mv"    

then  open browser on host PC ( ex. Windows XP + Chrome ) 
and   enter url  http://192.168.1.102   
then  you will find  Apache page 

start/stop apache2 by
# /etc/init.d/apache2 start 
# /etc/init.d/apache2 stop 
or you can use "sudo" if you not root
$sudo /etc/init.d/apache2 start 
( must enter password of root again ) 


*********************************
To Test PHP 
*********************************
Create 1 file named  phpinfo.php
add this below code


end then  save in  /var/www

open browser in Host File to browse file 
http://192.168.1.102/phpinfo.php

***********************************
Test Mysql
***********************************
mysql is in /etc/mysql  
with config file my.cfg

Can check mysql by run at prompt 
#mysql  {enter}   to run mysql client 
if mysql server running (by default ) 
it will connect to mysql server database
mysql> 

run command to show database by 
mysql>show databases;
will list database 

(now mysql is part of Oracle ) 

***********************************
SYSTEM 
***********************************
hostname can view by command 
#cat /etc/hostname 

installing new software
apt-get install [pacakge] 
this command may tell you unknown .

use aptitude for more information 
#aptitude install [pacakge]
or user 
#aptitude   
to display  GUI (text mode) on Linux 
quit gui by "q"  
user F1  on keyboard for help

for Searching package use "/"
searching Apache2 may use 
"apache"  or "httpd" , in this machin 
found  "apache" 

you will find description of many program
on aptitude 
( most linux program name very unclear for WinXP user)

***********************************
Download File
***********************************
you can download file with 
wget ( see in aptitude ) 

***********************************
NOTE: in this Ubuntu Server (TextMode Only ) 
,there is no other files in /var/www  
***********************************






   


install apache on centOS

ต้อง DEBUG  PHP บนเครื่อง CentOS
เคยลองบน  WinXP แล้ว มีปัญหา เลยต้องลง OS เ้อง เลย

************************************************

config  Apache httpd
บน  CentOS
ลองทำบน  CentOS Live CD
ไปโหลด Live CD ตัวเล็กๆ 700MB จาก


sudo yum install httpd mod_ssl


ตาม
http://articles.slicehost.com/2008/2/6/centos-installing-apache-and-php5
http://www.techiecorner.com/125/how-to-install-lamp-apache-php-and-mysql-in-linux-using-yum/

แต่ยังไม่ได้ลอง mysql + php


ตรวจสอบต้องตรวจโดย  su - ก่อนเพื่อเป็น root
แล้วค่อย ใช้
service httpd status
service httpd start 
ตาม  http://www.mail-archive.com/centos@centos.org/msg02899.html
http://www.linuxmail.info/how-to-start-stop-services-centos-5/

ลองเปิด web browser แล้วเลือก
Browse  http://127.0.0.1/  จะเห็นหน้า CenteOS


************************************************
ก่อน install อาจต้อง ติดตั้ง network ก่อน
set default gateway โดย
http://www.cyberciti.biz/faq/howto-rhel-fedora-linux-setup-default-gateway/

# vi /etc/sysconfig/networkSetup GATEWAY={Router-IP}, if router IP is 74.86.49.129, type:
GATEWAY=192.168.1.1
ตัวอย่าง IP แต่ส่วนมากเป็น .1.1

Restart network ด้วย


# /etc/init.d/network restart


แล้ว ถ้าขึ้น OK หมด ก็ ลอง ปิง  192.168.1.1 
แล้วค่อยลองปิง google.co.th


อ้ันนี้ตามที่ลองทดสอบ จะได้ DHCP จาก router เอง
เช่น  192.168.1.34 




******************************************************
install mysql โดย 
******************************************************


# yum install mysql               <-- mysql client  
# yum install mysql-server 
ต้องคอยตอบ y  เรื่อยๆ 


#service mysqld status 
#service mysqld start  


connect mysql client by 
#mysql  
will prompt  
mysql> 


check database by 
mysql> show databases;
mysql> show status; 




******************************************************
Enable Service SSH  for Remote Access ( command line ) 
******************************************************
# service sshd status 
# service sshd start 




--------------------------------------------------------------------
Install ftp  on centOS (NOT Complete ) 


Install 
ftp server ( not secure ) 
by 
# yum install vsftpd
# chkconfig vsftpd on
# service vsftpd start

OpenFirewall
# vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
# service iptables start   <--- or restart   

if want to  Disable Firewall   - > #service iptables stop  

Test FTP 
$ ftp localhost

open at 
# vi /etc/vsftpd/vsftpd.conf
$ man vsftpd.conf

--  Help on  vsftpd  -- 
==================




====================================
SET  FTP  On  CentOS  , Thai/English

http://www.linuxlane.com/vsftpd-fedora-core-6-server/   <-- Thai
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch15_:_Linux_FTP_Server_Setup
http://www.cyberciti.biz/tips/rhel-fedora-centos-vsftpd-installation.html


14 July 2010

HTTP KeepAlive

ไปหาข้อมูล เกี่ยวกับ Tag KeepAlive ใน HTTP

พบข้อมูลดังนี้

สรุปสั้้น ก็น่าจะเป็นว่า ประหยัด ทรัพยากรของ server
เพราะไม่ทำให้ server ต้องเชื่อมต่อ connection จำนวนมากเกินไป
เช่น user เปิด browser แล้ว กด refresh หลายๆครั้ง
ถ้าไม่มีการ keepalive ก็จะมีหลาย conncetion แต่ถ้ามี keepalive ก็จะมีแค่
หนึ่ง connection
แต่ก็ขึ้นกับ เวลา timeout ที่กำหนดโดย webserver ด้วย เช่น Apache WebServer
ปัจจุบันที่ที่ HTTP/1.1 จำกำหนด Default เป็น keepAlive อยู่แล้ว
ยกเว้นมีการกำหนด


Apache HTTP , มีการ support keepalive

เอกสารอ่านยากแนววิชาการมากหน่อย และใช้เวลามาก ก็ตัวนีี้
http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html
http://tools.ietf.org/html/rfc2616

----------------------------------------------------------------------

ที่กล่าวมาก่อนหน้าจะเป็นการพูดถึง HTTP - KeepAlive แต่จริงๆก็จะมี TCP KeepAlive ด้วย
ซึ่งเป็นการทำงานในระดับ network ระดับล่างที่ต่ำไปกว่า Level ของ HTTP
โดย HTTP นั้นจะอยู่ที่ระดับ Leyer 7 ของ TCP/IP Stack คืออยู่ระดับ Application
http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html

อันนี้ก็พูดกันไปถึง  SYN/ACK เป็น TCP/IP Protocol ระดับล่างๆเลย ไม่กล่าวถึงในที่นี้
เพราะก็ยังไม่ค่อยเข้าใจนัก

25 November 2008

เปลี่ยน port mysql ใน AppServ

ในที่นี้ เนื่องจาก ติดตั้ง mysql 2 instance บนเครื่องเดียวกัน
และ มีการ ใช้ port ชนกันจึงต้องเปลี่ยน ที่ ตัวหนึ่้ง
( หลังจาก มีการเปลี่ยน port ของ apache web server ไปแล้ว )
โดยให้ instance ตัวหนึ่ง ใช้ port 3306 ปกติ
และอีกตัว ใช้ port 3307

ต้องการเปลี่ยน port ก็ แก้โดย
C:\AppServ\MySQL\my.ini

เปลี่ยน section
[client]
port=3306

ให้กลายเป็น
[client]
port=3307

และต้องเปลี่ยน phpMyAdmin อีกให้ มองเห็นตัวนี้ รวมทั้ง เมื่อจะติดต่อด้วย php
ต้องเรียกด้วย
$link = mysql_connect('127.0.0.1:3307', 'mysql_user', 'mysql_password');
หรือ
$link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');


แก้ไข ที่ phpMyAdmin ดังนี้
C:\AppServ\www\phpMyAdmin
config.inc.php แก้ไข จาก

cfg['Servers'][$i]['port'] = '';

ให้เป็น
cfg['Servers'][$i]['port'] = '3307';

แล้ว ลอง start mysql ใหม่
และ start phpmyadmin ใหม่ จาก browser

ถ้าทำการเปลี่ยน port ของ apache ต้อง restart apache ใหม่ด้วยครับ

Apache เพิ่ม Services และ uninstall services

View Help apache with :
>Apache.exe /?


Install Apache as Services
>apache.exe -n "Apache Web Server (Test)" -k install
-n คือชื่อที่จะเห็น ใน Services ของ Windows

สามารถ ลงได้ หลาย Service เช่น
apache.exe -n "Apache2(Test)" -k install
apache.exe -n "Apache2(Test 2)" -k install
apache.exe -n "Apache2(Test 3)" -k install
จะเห็นว่ามี 3 Services เมื่อ เปิด หน้าต่าง Services ใน Admin Tools
แต่ทั้ง สาม จะมี property ว่า เป็น .exe ตัวเดียวกัน
สามารถ แยก รันได้ อิสระ แต่มีปัญหาว่า มันใช้ port 80 เหมือนกัน มันเลย
รัน ให้พร้อมกันจริงๆไม่ได้ ในตอนนี้

apache.exe -k uninstall -n "Apache Web Server"
-n คือชื่อ

จาก ทั้ง 3 services ที่เห็น จะสามารถ uninstall ทั้ง 3 ได้ โดย
apache.exe -n "Apache2(Test)" -k uninstall
apache.exe -n "Apache2(Test 2)" -k uninstall
apache.exe -n "Apache2(Test 3)" -k uninstall

การ uninstall จะทำไม่สำเร็จ ถ้า service ยังรันอยู่
แต่ว่าจะโดนมาร์ค ไว้ว่า ให้ลบ เมื่อ มีการ stop services

19 November 2008

เปลี่ยน port mysql ใน AppServ

ในที่นี้ เนื่องจาก ติดตั้ง mysql 2 instance บนเครื่องเดียวกัน
และ มีการ ใช้ port ชนกันจึงต้องเปลี่ยน ที่ ตัวหนึ่้ง
( หลังจาก มีการเปลี่ยน port ของ apache web server ไปแล้ว )
โดยให้ instance ตัวหนึ่ง ใช้ port 3306 ปกติ
และอีกตัว ใช้ port 3307

ต้องการเปลี่ยน port ก็ แก้โดย
C:\AppServ\MySQL\my.ini

เปลี่ยน section
[client]
port=3306

ให้กลายเป็น
[client]
port=3307

หมายเหตุ ในส่วน [client] อาจไม่ต้องแก้ไขก็ได้ เพราะจะ ใช้กับ mysql.exe ซึ่งเป็น client
แต่ server ส่วนใหญ่จะเป็น 3306 อยู่แล้ว อาจแก้ไขเฉพาะ [mysqld] ก็พอ

และต้องเปลี่ยน section mysqld จาก
[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3306

ไปเป็น
[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3307

แล้ว restart mysql
แล้วอาจทดสอบด้วยการ telnet localhost 3307 ดู

และต้องเปลี่ยน phpMyAdmin อีกให้ มองเห็นตัวนี้ รวมทั้ง เมื่อจะติดต่อด้วย php
ต้องเรียกด้วย
$link = mysql_connect('127.0.0.1:3307', 'mysql_user', 'mysql_password');
หรือ
$link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');


แก้ไข ที่ phpMyAdmin ดังนี้
C:\AppServ\www\phpMyAdmin
config.inc.php แก้ไข จาก

cfg['Servers'][$i]['port'] = '';

ให้เป็น
cfg['Servers'][$i]['port'] = '3307';



แล้ว ลอง start mysql ใหม่
และ start phpmyadmin ใหม่ จาก browser

ถ้าทำการเปลี่ยน port ของ apache ต้อง restart apache ใหม่ด้วยครับ