Tag Archives: server

.htaccess main domain to subdirectory redirect

# .htaccess main domain to subdirectory redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line.
RewriteEngine on
# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
# Change ‘subdirectory’ to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don’t change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change ‘subdirectory’ to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change yourdomain.com to be your main domain again.
# Change ‘subdirectory’ to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
RewriteRule ^(/)?$ subdirectory/index.php [L]

แก้ปัญหา The terminal server has exceeded the maximum number of allowed connections

แก้ปัญหา The terminal server has exceeded the maximum number of allowed connections
ซึ่งเกิดจากการที่ login ค้างไว้ที่เครื่อง server และไม่ได้ log off ทำให้ connection เต็ม
วิธีแก้
start >run>cmd

ให้ใช้คำสั่ง

mstsc /v:00.00.00.00 /admin

หมายเหตุ 00.00.00.00 คือ ip ของเครื่อง server

วิธี set Apache ให้ run Python ได้

ลง python ที่ server
จากนั้นแก้ไฟล์ httpd.conf
แก้ไขบรรทัดนี้

AddHandler cgi-script .cgi .pl

โดยเติม .py เข้าไป
จากนั้น restart apache

ในส่วนของ script python ให้ใส่บรรทัด #!/PATH/TO/INTEPRETER ไว้บนสุด ขึ้นอยู่กับแต่ละเครื่องด้วยว่าติดตั้ง python ไว้ที่ไหน เช่น

#!c:/python27/python.exe

ตัวอย่าง

#!c:/python27/python.exe
print "Hello World!"

ก็จะสามารถรันได้แล้วครับ เอาไฟล์ script python ไปใส่ที่ www แล้วลองเรียกจาก Browser ได้เลย

วิธี Enabled Upload progress บน Drupal

ในส่วนของ Status report ของ drupal ถ้าขึ้นคำเตือนแบบด้านล่างนี้นะครับ
“Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the PECL uploadprogress library (preferred) or to install APC.”
วิธีเปิดใช้ก็คือ

  • download ไฟล์ php_uploadprogress.dll และ php_apc.dll ไปใสไว้ที่ ext ของ php ยกตัวอย่างนะครับ C:\AppServ\php5\ext ส่วนใคร config ไว้ที่ไหนก็ไปใส่ให้ถูกนะครับ
  • เปิด php.ini มาแก้ เพิ่ม 2 บรรทัดนี้
    extension=php_uploadprogress.dll
    extension=php_apc.dll
  • จากนั้นก็ save แล้ว Restart apache ลองดูครับว่าใช้ได้หรือยัง
  • วิธีทดสอบก็เอาไฟล์ examples ที่ผมแนบไปด้วยจากลิ้งด้านล่างไปทดสอบที่ server ผมจะบอกว่าได้หรือไม่ได้
  • ถ้าไม่ได้ต้องเพิ่มอีกสองบรรทัดนี้กรณีไม่สามารถเขียนไฟล์ temp ลงระบบได้ ไปเพิ่มที่ php.ini
    upload_tmp_dir = D:\temp\upload_tmp_dir
    uploadprogress.file.filename_template=D:\temp\upt_%s.txtหมายเหตุ:D:\temp\upload_tmp_dir เป็นพาธสมมุติที่จะให้เก็บนะครับ

จากนั้นลองทดสอบกับตัว examples ถ้าเป็นสีเขียวก็สมบูรณ์ครับ ลองอัพโหลดไฟล์ทดสอบดู

ไฟล์แนบครับ Enabled-Upload-progress

ความรู้บางส่วนมาจาก http://drupal.org/node/259744