Make Macbook Pro to be Web Server
แก้ config ของ Apache
sudo nano /etc/apache2/httpd.conf
AllowOverride All
เปิดใช้งาน mod_rewrite
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
Install PHP
brew update brew install php@7.3 brew link php@7.3 brew services start php@7.3
เปิดใช้งาน php
LoadModule php7_module libexec/apache2/libphp7.so
เปลี่ยน DocumentRoot ของ web
sudo mv /Library/WebServer/Documents /Library/WebServer/Documents.old sudo ln -s /New/Web/Folder /Library/WebServer/Documents
แก้ php config โดย cp /etc/php.ini.default /etc/php.ini
post_max_size = 16M upload_max_filesize = 1024M date.timezone = Asia/Bangkok
Restart Apache
sudo apachectl configtest sudo apachectl -k restart
ที่มา macOS 10.15 Catalina Apache Setup: SSL
Install MariaDB
brew install mariadb
Start MariaDB
Service start
brew services start mariadb
Start without service
mysql.server start
Link data to new location
sudo ln -s /Users/mysql /usr/local/var/mysql sudo chown -h user:group /usr/local/var/mysql
แก้ไข config file ~/.my.cnf
sql_mode = NO _ ENGINE _ SUBSTITUTION,STRICT _ TRANS _ TABLES default-storage-engine = MYISAM collation-server = utf8_unicode_ci character-set-server = utf8
Auto Start
launchd In MacOS, create a file called /Library/LaunchDaemons/com.mariadb.server.plist with the following contents (edit to suit):
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.mariadb.server</string> <key>KeepAlive</key><true/> <key>RunAtLoad</key><true/> <key>LaunchOnlyOnce</key><false/> <key>ExitTimeOut</key><integer>600</integer> <key>WorkingDirectory</key><string>/usr/local/var</string> <key>Program</key><string>/usr/local/bin/mysqld</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/mysqld</string> <string>--user=_mysql</string> <string>--basedir=/usr/local/opt/mariadb</string> <string>--plugin-dir=/usr/local/opt/mariadb/lib/plugin</string> <string>--datadir=/usr/local/var/mysql</string> <string>--log-error=/usr/local/var/mysql/Data-Server.local.err</string> <string>--pid-file=/usr/local/var/mysql/Data-Server.local.pid</string> <string>--sql-mode=ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION</string> </array> </dict> </plist>
Then from a shell, run launchctl load /Library/LaunchDaemons/com.mariadb.server.plist and MariaDB will run immediately, and also upon reboot.
Fix the 2002 socket error first if you haven’t done so from the MySQL section-
sudo mkdir /var/mysql
Location -> /usr/local/Cellar/mariadb/{version}
Data location /usr/local/var/mysql/
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
Start MySQL
sudo /usr/local/mysql/support-files/mysql.server start
Stop MySQL
sudo /usr/local/mysql/support-files/mysql.server stop
Restart MySQL
sudo /usr/local/mysql/support-files/mysql.server restart
Relate topics
- ddosify : Load Test - ไม่ผ่าน
- macOS 12 Monterey: Web Server Setup/Apache/MariaDB/PHP Multiple Versions
- Mirror iPad to a Mac
- Ubuntu Server Installation
- อีกที : macOS 11.0 Big Sur Apache/MiriaDB/PHP Setup
- Ubuntu Web Server Setup
- Apache Config on Ubuntu Server :: Manual add new site
- Check and Repair Hardisk
- Install AFP Share Server Protocal on Linux
- เช็คเงื่อนไข url request ใน .htaccess
- Mount Network Drive Using CIFS on Mac OSX
- วิธีการติดตั้ง Let’s Encrypt automated free SSL certificate
- Linux Server Tools
- Mac OSX Tips
- 7 วิธีในการเปิดเครื่อง Mac OS X
- พบบั๊ก GHOST ใน glibc ความร้ายแรงระดับสูง กระทบลินุกซ์รุ่นเก่าจำนวนมาก
- Server Setup : การกำหนดสิทธิ์ Root ให้กับ user บน Ubuntu 14.04
- Setup FTP Server under Ubuntu/Debian
- ย้ายบ้านให้ MySql
- Debian : ปิดการตรวจสอบฮาร์ดดิสอัตโนมัติขณะเปิดเครื่อง