สร้าง public_html ใน Ubuntu 12.04

Set ดังนี้

$ sudo a2enmod userdir
$ sudo service apache2 restart
$ mkdir ~/public_html && chmod 755 ~/public_html

เรียกใช้งานได้ดังนี้

http://localhost/~jack/

ตอนนี้สามารถเรียกใช้ไฟล์ html ได้แล้ว แต่ยังไม่สามารถใช้งาน php ได้ เพราะโดย default แล้วจะไม่สามารถใช้งานได้เนื่องจากเรื่องของความปลอดภัย แต่สามารถแก้ไขให้ใช้งานได้ดังนี้

เปิดไฟล์ php5.conf

comment out บรรทัด  php_admin_value engine Off

Before:

After:

Save and exit, then reload apache2 configuration with following commad:

To testing PHP script work or not in the public_html directory, you can create some php script. In this case we are usingphpinfo, in terminal type following command

If you done, open the web browser then access http://[hostname]/~username/info.php.

apache2 userdir module testing phpinfo  How to Enable and Configure Apache2 Userdir Module in Ubuntu Server 12.04

Link Reference :

Ref: How to Enable and Configure Apache2 userdir Module in Ubuntu Server 12.04