- Installing MariaDB as MySQL replacement
- Install Apache 2.4
- Install PHP 7
- Get MySQL / MariaDB support in PHP
- Install the APCu PHP cache to speed up PHP
- Enable the SSL website in apache
- Install phpMyAdmin
Category Archives: Apache
สร้าง 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
1 |
<strong>sudo nano /etc/apache2/mods-available/php5.conf</strong> |
comment out บรรทัด php_admin_value engine Off
Before:
1 2 3 4 5 6 7 |
<strong>…</strong> <strong> <IfModule mod_userdir.c></strong> <strong> <Directory /home/*/public_html></strong> <strong> php_admin_value engine Off</strong> <strong> </Directory></strong> <strong> </IfModule></strong> <strong> …</strong> |
After:
1 2 3 4 5 6 7 |
<strong>…</strong> <strong> <IfModule mod_userdir.c></strong> <strong> <Directory /home/*/public_html></strong> <strong> # php_admin_value engine Off</strong> <strong> </Directory></strong> <strong> </IfModule></strong> <strong> …</strong> |
Save and exit, then reload apache2 configuration with following commad:
1 |
<strong>sudo /etc/init.d/apache2 reload</strong> |
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
1 |
<strong>echo '<?php phpinfo(); ?>' > ~/public_html/info.php</strong> |
If you done, open the web browser then access http://[hostname]/~username/info.php.
Link Reference :
Ref: How to Enable and Configure Apache2 userdir Module in Ubuntu Server 12.04
Apache : How to Enable mod_rewrite on Ubuntu
เปิดใช้โมดูล mod_rewrite
sudo a2enmod rewrite
แก้ไฟล์คอนฟิก
sudo nano /etc/apache2/sites-enabled/000-default
แก้ไข none ให้เป็น all
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
สุดท้าย บูต Apache ใหม่
sudo /etc/init.d/apache2 restart
ตรวจสอบว่าใช้ได้หรือยังด้วยคำสั่ง
apache2ctl -M
อย่าลืมตรวจสอบไฟล์ .htaccess มาได้ copy มาไว้ที่ /var/www แล้วหรือไม่ เพราะบางครั้ง มันไม่ได้ copy มา ไม่รู้ว่าทำไม ‘-_-
เท่านี้ Clean URL ก็จะใช้ได้แล้ว
ที่มา: drupal.in.th, drupal.org/
Apache on Mac
go to: System Preferences > Sharing
check on Web Sharing
Example, http://localhost
or http://localhost/~yourname/
Source Directory
/Library/WebServer/Documents
/Users/yourname/Sites/your web pages are here
Ref devarticles.com