Server

Server

63 items(1/7) 2 3 4 5 Next » Last »|

macOS 11.0 Big Sur Apache Setup: Multiple PHP Versions

โดย Little Bear on 4 ต.ค. 64 14:48

เดี๋ยวค่อยมาเขียนรายละเอียด

brew tap shivammathur/php

เลือกมาสักเวอร์ชั่น

brew install shivammathur/php/php@5.6
brew install shivammathur/php/php@7.0
brew install shivammathur/php/php@7.1
brew install shivammathur/php/php@7.2
brew install shivammathur/php/php@7.3
brew install shivammathur/php/php@7.4
brew install shivammathur/php/php@8.0

config file อยู่ที่

/usr/local/etc/php/5.6/php.ini
/usr/local/etc/php/7.0/php.ini
/usr/local/etc/php/7.1/php.ini
/usr/local/etc/php/7.2/php.ini
/usr/local/etc/php/7.3/php.ini
/usr/local/etc/php/7.4/php.ini
/usr/local/etc/php/8.0/php.ini

ผลลัพท์ตอนติดตั้ง

[code]
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php7_module /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so

    <FilesMatch .php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/7.4/

php@7.4 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have php@7.4 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/php@7.4/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/php@7.4/sbin:$PATH"' >> ~/.zshrc

For compilers to find php@7.4 you may need to set:
  export LDFLAGS="-L/usr/local/opt/php@7.4/lib"
  export CPPFLAGS="-I/usr/local/opt/php@7.4/include"<br />
<br />
<br />
To start shivammathur/php/php@7.4:
  brew services start shivammathur/php/php@7.4
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/php@7.4/sbin/php-fpm --nodaemonize

เปลี่ยนลิงก์

brew unlink php && brew link --overwrite --force php@7.4

Apache

แก้ไขไฟล์ /etc/apache2/httpd.conf หรือ /usr/local/etc/httpd/httpd.conf file scroll to the bottom of the LoadModule entries.

LoadModule php5_module /usr/local/opt/php@5.6/lib/httpd/modules/libphp5.so
<a class="hashtag" href="/tags/LoadModule">#LoadModule</a> php7_module /usr/local/opt/php@7.0/lib/httpd/modules/libphp7.so
<a class="hashtag" href="/tags/LoadModule">#LoadModule</a> php7_module /usr/local/opt/php@7.1/lib/httpd/modules/libphp7.so
<a class="hashtag" href="/tags/LoadModule">#LoadModule</a> php7_module /usr/local/opt/php@7.2/lib/httpd/modules/libphp7.so
<a class="hashtag" href="/tags/LoadModule">#LoadModule</a> php7_module /usr/local/opt/php@7.3/lib/httpd/modules/libphp7.so
<a class="hashtag" href="/tags/LoadModule">#LoadModule</a> php7_module /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so
<a class="hashtag" href="/tags/LoadModule">#LoadModule</a> php_module /usr/local/opt/php@8.0/lib/httpd/modules/libphp.so

ที่มา macOS 11.0 Big Sur Apache Setup: Multiple PHP Versions

Alumni Med Server Installation

โดย Little Bear on 26 พ.ค. 64 13:02

ติดตั้ง Server ใหม่ของ Alumni Med เขียนบันทึกคำสั่งไว้สักหน่อย

sudo nano /etc/php/7.4/fpm/php.ini
sudo systemctl restart apache2

sudo nano /etc/mysql/conf.d/mysqld.cnf
sudo systemctl restart mysql

mkdir alumni
sshfs -p 22 username@example.com:/home/folder/ folder
umount folder

sudo apt update<br />
sudo apt upgrade

sudo apt install apache2 -y
systemctl status apache2

sudo a2dismod ssl
sudo a2enmod ssl

apt install php7.4 php7.4-mysql php-common php7.4-cli php7.4-json php7.4-common php7.4-opcache libapache2-mod-php7.4

apt install mariadb-server mariadb-client
systemctl status mariadb

mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';

sudo systemctl restart apache2<br />
sudo systemctl restart mysql

wget -r --ask-password ftp://user:example.com/

ที่มา

อีกที : macOS 11.0 Big Sur Apache/MiriaDB/PHP Setup

โดย Little Bear on 21 ธ.ค. 63 10:21

รอก่อนนะ ค่อยกลับมาทยอยเขียน

Edit Apache config

sudo nano /etc/apache2/httpd.conf
ServerName my.local.:80

<Directory "/">
AllowOverride All
Require all denied
</Directory>

<Directory "/Library/WebServer/Documents">
AllowOverride All
</Directory>

Restart Apache

sudo apachectl restart
sudo apachectl -k graceful

Edit MariaDB config

nano ~/.my.cnf

Restart MariaDB

Auto start

brew services start mariadb

Manual start

mysql.server restart

ที่มา

Ubuntu Web Server Setup

โดย Little Bear on 19 ธ.ค. 63 13:19

แปะไว้ก่อน ค่อยมาเขียนรายละเอียดนะครับ

sudo nano /etc/php/7.4/fpm/php.ini
sudo systemctl restart apache2

sudo nano /etc/mysql/conf.d/mysqld.cnf sudo systemctl restart mysql

mkdir remotefolder sshfs -p 22 username@example.com:/home/folder/ remotefolder umount remotefolder

sshfs -p 22 username@example.com:/home/user/domains/example.com/public_html/ remotefolder nohup rsync -trv remotefolder/path/ path/ &

sudo apt update<br /> sudo apt upgrade

sudo apt install apache2 -y systemctl status apache2

sudo a2dismod ssl sudo a2enmod ssl<br /> <br /> <br />

apt install php7.4 php7.4-mysql php-common php7.4-cli php7.4-json php7.4-common php7.4-opcache libapache2-mod-php7.4

apt install mariadb-server mariadb-client systemctl status mariadb

mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; mysql> GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';<br /> <br /> <br />

sudo systemctl restart apache2<br /> sudo systemctl restart mysql<br /> <br /> <br /> wget -r --ask-password ftp://user:server.com/







- https://upcloud.com/community/tutorials/installing-lamp-stack-ubuntu/?utmterm=&utmcampaign=DSA&utmsource=adwords&utmmedium=ppc&hsaacc=9391663435&hsacam=7185608860&hsagrp=81739862313&hsaad=391197952986&hsasrc=g&hsatgt=dsa-460992423274&hsakw=&hsamt=b&hsanet=adwords&hsaver=3&gclid=CjwKCAiAeb-BRB2EiwAGBnXXuae-7ru2jsgSAiku6bX0k7XucjvKLGBQkSm-DKo92SXjG1odKAeRoCid0QAvD_BwE - https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql - https://stackoverflow.com/questions/113886/how-to-recursively-download-a-folder-via-ftp-on-linux - https://askubuntu.com/questions/709594/how-can-i-disable-and-enable-ssl-in-apache-without-a-command-if-possible

Apache Config on Ubuntu Server :: Manual add new site

โดย Little Bear on 10 ต.ค. 63 16:16

Create new user how

sudo adduser userName

Make user sudo how

sudo adduser userName sudo

MySQL Configuration

  • Increrase memory size for MySQL Server using nano /etc/my.cnf and add/change value ตามรายละเอียด
    innodbbufferpoolsize = 2048M
    innodblogfilesize = 512M
    maxconnections = 500
    keybuffer_size = 512M
    

PHP Config

Set timezone to Asia/Bangkok

nano /etc/php/7.4/apache2/php.ini
date.timezone = Asia/Bangkok

Add CNAME domain.com to ppi.psu.ac.th

Add new site to Apache

cd /etc/apache2/sites-available
nano sites-available/doname.com.conf
<VirtualHost *:80>
    ServerName domain.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/domain.com
</VirtualHost>
<VirtualHost *:80>
    ServerName www.domain.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/domain.com
</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
    ServerName domain.com
    ServerAdmin webmaster@localhost
    DocumentRoot /home/user/domains/domain.com
</VirtualHost>
<VirtualHost _default_:443>
    ServerName www.domain.com
    ServerAdmin webmaster@localhost
    DocumentRoot /home/user/domains/domain.com
</VirtualHost>
</IfModule>
cd /etc/apache2/sites-enabled
ln -s ../sites-available/domain.com.conf domain.com.conf

Restart Apache

systemctl restart apache2

Restart MySql

systemctl restart mysql

INSTALL Let's Encrypt

apt-add-repository -r ppa:certbot/certbot

After that, the following commands do not generate any errors:

apt update
apt-get update
apt install python3-certbot-apache
certbot --apache -d domain.com -d www.domain.com

You should test your configuration at:

https://www.ssllabs.com/ssltest/analyze.html?d=domain.com

IMPORTANT NOTES:

Congratulations! Your certificate and chain have been saved at:

  • /etc/letsencrypt/live/domain.com/fullchain.pem
  • Your key file has been saved at:
  • /etc/letsencrypt/live/domain.com/privkey.pem
  • Your cert will expire on 2021-01-08. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew all of your certificates, run "certbot renew"

To test the renewal process, you can do a dry run with certbot:

sudo certbot renew --dry-run

Correct way to completely remove issued certificate(s) for a domain

certbot delete --cert-name domain.com

Copy file from another server using SSH

Alternatively, you could mount the myserver's filesystem over SSH with sshfs. This may be too much hassle for a one-off need, but convenient if you do this sort of thing often.

mkdir myserver
sshfs -p 22 domain.com:/path/ myserver
wget -O ~/myserver/path/to/remote/destination http://www.example.com/whatever

rsync -trv myserver/src/path/ dest/path/
umount myserver

rsync in background

nohup rsync -trv myserver/src/path/ dest/path/ &

Dump Database

mysqldump -u [username] -p [database-you-want-to-dump] > [path-to-place-data-dump.sql]
/usr/local/mysql/bin/mysqldump -u [username] -p [database-you-want-to-dump] > [path-to-place-data-dump.sql]

Ways to Flush DNS Cache on Mac OSx

sudo killall -HUP mDNSResponder

WhoIs LookUp

nslookup -type=ns softganz.com

Setup Time Sync

ติดตั้ง

apt-get install ntp

แก้ไข config

server 1.th.pool.ntp.org
server 0.asia.pool.ntp.org
server 2.asia.pool.ntp.org
server clock.nectec.or.th

Restart

service ntp restart

ที่มา

Check and Repair Hardisk

โดย Little Bear on 22 มิ.ย. 63 23:29

umount -l /dev/sda1
e2fsck -cfpv /dev/sda1 > chresult.txt&

Install AFP Share Server Protocal on Linux

โดย Little Bear on 2 พ.ย. 62 12:53
sudo apt-get install netatalk
sudo nano /etc/netatalk/AppleVolumes.default

/shares                "Shares" /media/user/VolumeName  "ShareName"

sudo /etc/init.d/netatalk restart

วิธีการติดตั้ง Let’s Encrypt automated free SSL certificate

โดย Little Bear on 31 ม.ค. 60 13:55

เข้าสู่ยุค https จึงจำต้องทำเสียแล้ว

มาลองติดตั้ง Let's Encrypt บน Directadmin กันอีกสักรอบ

1. เริ่มด้วยการแก้ไข config ของ Directadmin ให้สามารถใช้งาน Let's Encrypt ก่อน

nano /usr/local/directadmin/conf/directadmin.conf

สำหรับใครที่ใช้ path : /var/www/html/.well-known (ใช้โดเมนเดียว) ให้เพิ่ม

enable_ssl_sni=1
letsencrypt=1

ส่วนใครที่ใช้ path : /home/user/domains/domain.com/public_html/.well-known (ใช้หลายโดเมน) ให้เพิ่ม

enable_ssl_sni=1
letsencrypt=2

หรือจะสั่งผ่าน Terminal ก็ได้โดย

echo enable_ssl_sni=1 >> /usr/local/directadmin/conf/directadmin.conf
echo letsencrypt=2 >> /usr/local/directadmin/conf/directadmin.conf

แล้วสั่ง update config โดย

cd /usr/local/directadmin/custombuild
./build update
./build rewrite_confs

2. แล้วมาเพิ่ม Let's Encrypt ให้กับแต่ละเว็บ

กำหนดให้เว็บสามารถใช้งาน Secure SSL ก่อน

แล้วจึงไปเพิ่ม SSL Certificates ให้กับเว็บ โดยเลือก Free & automatic certificate from Let's Encrypt

(ต้องทำทั้ง www และ ไม่มี www)

ถ้าต้องการให้สามารถใช้งานได้ทั้ง https และ http ให้สร้าง link private _ html ให้ชี้ไปที่ public _ html ด้วยคำสั่ง

ln -s public _ html private _ html

แต่ถ้าต้องการให้ใช้งานเฉพาะ https อย่างเดียว ให้ rename public _ html ไปเป็น private _ html แล้วสร้าง folder public _ html ใหม่ และสร้างไฟล์ .htaccess โดยเพิ่มคำสั่ง

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Let's Encrypt ก็จะเป็นของเรา

Linux Server Tools

โดย Little Bear on 31 ต.ค. 59 10:52

top :: the Linux Top Command

top

iotop :: I/O Monitor

iotop

iftop :: Bandwidth Monitor

iftop

ดูรายละเอียดเพิ่มเติม

iptstate : IP Tables State

iptstate

ดูรายละเอียด

df :: Display Free Disk Space

df

Make Macbook Pro to be Web Server

โดย Little Bear on 10 ก.ค. 58 16:43

แก้ 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

63 items(1/7) 2 3 4 5 Next » Last »|