วันอาทิตย์ที่ 27 พฤษภาคม พ.ศ. 2555

Enabling apache UserDir (public_html) on CentOS


  1. Edit the /etc/httpd/conf/httpd.conf file.
  2. Change the ‘UserDir disabled’ line to ‘UserDir enabled <username>’.
    Uncomment the ‘UserDir public_html’ line.
    Also uncomment the whole ‘<Directory /home/*/public_html>’section until the ‘</Directory>’.
  3. Apply the proper permissions:
    # chmod 711 ~<username>
    # chmod 755 -R ~<username>/public_html/
  4. Run the following commands so SELinux wouldn’t bother you:
    # setsebool -P httpd_enable_homedirs true
    # chcon -R -t httpd_sys_content_t ~<username>/public_html   # It looks like it’s not necessary. See dgrift’s comments below.
  5. Extra Tip: It looks like on PHP versions  >= 5.3.0, to allow the short tag ‘<?’ we need to set ‘short_open_tag = On’ in the /etc/php.ini.
Restart the httpd service and after it you should be able to access http://localhost/~<username>/

References:

ไม่มีความคิดเห็น:

แสดงความคิดเห็น