Collection of useful command in centminmod

Centminmod - CentOS 7 Quick Commands
Commands for CentOS / centminmod / and other various items

##############################################
## CENTOS 7 COMMANDS
##############################################

Cron: checking log for what is running
# tail -f /var/log/cron

Empty Log or Any File
# truncate -s 0 /var/log/secure

Command Help
# systemctl --help

Load Average / Uptime
# cat /proc/loadavg
# uptime

Check on Service Status
# systemctl status nginx.service

Dump traffic on a network - when getting a DdoS attack
http://www.tcpdump.org/tcpdump_man.html
# tcpdump -w file.txt

List on running processes
# ps aux | less
# ps -U root -u root -N // see all process NOT as root
# ps -u vivek // see all processes of a specific user
# control + z to exit

Yum listing updates
# yum list mariadb* 
# yum list http*
# yum list php*
# yum list updates
# yum list gcc* g++* kernel* openssl*

CPU / Running Processes
# top

Current CentOS Release
# cat /etc/redhat-release

Get Free Memory Information & Get Swap Memory Information
# free -m
# smem -kpt
# smem -tuk

Get Disk / Filesystem Information
# df -h

Get CPU Information
# cat /proc/cpuinfo
# watch -n1 "lscpu | grep 'MHz' | awk '{print $1}'"

PHP List Modules / Module Information
# php -m
# php --ri mbstring  // mbstring
# php --ri memcache  // Memcache
# php --ri memcached  // Memcached
# php --ri redis  // Redis
# php --ri imagick  // imagick
# php --ri openssl  // openssl

Check listening Ports
# netstat -ntl

Check Cache
# ccache -s

List installed NGINX Modules
# ls -lah /usr/local/nginx/modules

Version Information (or -t)
# php -v
# mysql -v
# nginx -v

Changelog
# rpm -qa --changelog openssl | head -n8

To print a list of the messages in the queue, enter:
# exim -bp
# exim -Mrm {message-id}  // To remove a message from the queue

To remove all messages from the queue (two options)
# exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash
# exim -bp | exiqgrep -i | xargs exim -Mrm

Unpacking a tar.gz file w/ permissions intact
# tar -pczf name_of_your_archive.tar.gz /path/to/directory

PHPINFO File Location
Running the below will find the info file location.
You can delete the found file if you choose or password protect the file.
# ls -lah /usr/local/nginx/html | grep phpi

Speedtest
# nfsspeedtest -b 4k -s 128m
# nfsspeedtest -b 4k -s 128m -y
# nfsspeedtest -b 8k -s 128m -y
# nfsspeedtest -b 16k -s 128m -y

Hard Drive Information / Read Checking
# hdparm -I /dev/sda
# hdparm -Tt /dev/nvme0n1

Memory Information
# dmidecode -t memory

Motherboard Information
# dmidecode -t baseboard

Hard Drive SMART Information
# smartctl -data -A /dev/sda
# smartctl -data -A /dev/sdb


##############################################
## CENTOS OTHER STUFF
##############################################

### ADDING NEW IP ADDRESSES

Go to sysconfig
# nano /etc/sysconfig/network-scripts/ifcfg-enp0s3

Add under IPADDR=

IPADDR1="10.0.0.121"
PREFIX1="24"
IPADDR2="10.0.0.122"
PREFIX2="24"

Restart Service
# systemctl restart network.service

### CHANGING HOSTNAME

# nano -w /etc/hostname (enter hostname and nothing else)
# service network restart

Check status of hostname
# hostnamectl status

Check status of Cron
# service crond status

Test SSL
# testssl https://keepass.info/update/version2x.txt.gz

##############################################
## CENTMINMOD COMMANDS
##############################################

Centmin Directory Shortcut
# cmdir

Site Status (Maintenance Mode)
# sitestatus on|off

Centmin Mod Quick Info
# cminfo

Centmin Release Version
# cat /etc/centminmod-release

Centmin Version History Log
# cat /etc/centminmod-versionlog

Lists all logs in date ascending order so latest log at bottom
# ls -lArt /root/centminlogs

Edit php.ini = phpedit ( /usr/local/lib/php.ini )
Edit my.cnf = mycnf ( /etc/my.cnf )
Edit php-fpm.conf = fpmconf ( /usr/local/etc/php-fpm.conf )
Edit nginx.conf = nginxconf ( /usr/local/nginx/conf/nginx.conf )
Edit (nginx) virtual.conf = vhostconf - only edits /usr/local/nginx/conf/conf.d/virtual.conf not the additional vhost domain.com.conf files added later
Edit (nginx) php.conf = phpinc ( /usr/local/nginx/conf/php.conf )
Edit (nginx) drop.conf = dropinc ( /usr/local/nginx/conf/drop.conf )
Edit (nginx) staticfiles.conf = statfilesinc ( /usr/local/nginx/conf/staticfiles.conf )
nginx stop/start/restart = ngxstop/ngxstart/ngxrestart
php-fpm stop/start/restart = fpmstop/fpmstart/fpmrestart
mysql stop/start/restart = mysqlstop/mysqlstart/mysqlrestart
nginx + php-fpm stop/start/restart = npstop/npstart/nprestart
memcached stop/start/restart =memcachedstop/memcachedstart/memcachedrestart
csf stop/start/restart = csfstop/csfstart/csfrestart

PageSpeed Options
# pscontrol handler  // edit pagespeedhandler.conf file
# pscontrol edit  // edit pagespeed.conf file
# pscontrol editstats  // edit pagespeedstatslog.conf file
# pscontrol on
# pscontrol off
# pscontrol statson  // turn on/off Pagespeed console pagespeedstatslog.conf file
# pscontrol statsoff  // turn on/off Pagespeed console pagespeedstatslog.conf file
# pscontrol admin  // access Pagespeed admin

PageSpeed Statistics
# localhost/ngx_pagespeed_statistics  // only ip 127.0.0.1 is allowed access

Adding PageSpeed Statistics to URL w/ IP
location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; }
location /ngx_pagespeed_message { allow 127.0.0.1; deny all; }
location /pagespeed_console { allow 127.0.0.1; deny all; }

PageSpeed Stats Command Line
# curl -s localhost/ngx_pagespeed_statistics
# curl -s localhost/pagespeed_global_admin/message_history or curl -s localhost/ngx_pagespeed_message


##############################################
## MYSQL COMMANDS
##############################################

MySQL Reference
How to Check and Repair MySQL Tables Using Mysqlcheck
Optimize All Tables # mysqlcheck -o --all-databases Optimize One Database # mysqlcheck -o <db_schema_name> Run mysqltuner in root folder # ./mysqltuner.pl Run mysqlreport in root folder # ./mysqlreport ############################################## ## LOG FILES ############################################## Nginx Log Files # tail -10 /usr/local/nginx/logs/[servername].access.log # tail -10 /usr/local/nginx/logs/[servername].error.log Domain Name Specific Log Files # tail -10 /home/nginx/domains/domainname.com/log/access.log # tail -10 /home/nginx/domains/domainname.com/log/error.log Other Specific Log Files # ls -lhrt /var/log PHP-FPM Log Files # tail -10 /var/log/php-fpm/www-error.log # tail -10 /var/log/php-fpm/www-php.error.log MariaDB Log Files # tail -10 /var/log/mysqld.log CSF Firewall Log Files # tail -10 /var/log/lfd.log Mail Log File # tail -10 /var/log/maillog Cron Job Log Files # tail -10 /var/log/cron Install Log Location > /root/centminlogs

Source : gist

in Blog | 929 Words

Install New Phalcon PHP (v 4) in Windows 10 64 bit and Laragon

Since its v4 release I don’t have time to test this version in my windows 10 box.

Today is the right time because I don’t know, I want to hehehe.

I already have phalcon 3.4.5 installed and related phalcon dev tools.

phalcon info

Phalcon DevTools (3.4.0)

Environment:
OS: Windows NT DESKTOP-O8J2929 10.0 build 18362 (Windows 10) AMD64
PHP Version: 7.2.26
PHP SAPI: cli
PHP Bin: C:\laragon\bin\php\php-7.2.26-nts-Win32-VC15-x64\php.exe
PHP Extension Dir: C:\php\ext
PHP Bin Dir: C:\php
Loaded PHP config: C:\laragon\bin\php\php-7.2.26-nts-Win32-VC15-x64\php.ini
Versions:
Phalcon DevTools Version: 3.4.0
Phalcon Version: 3.4.5
AdminLTE Version: 2.3.6

PHP 7.4.4 nts already in place

C:\laragon\www
? php -m | grep phalcon
Warning: Cannot load module ‘phalcon’ because required module ‘psr’ is not loaded in Unknown on line 0

C:\laragon\www
? php -m | grep phalcon
phalcon

Choose DLL version

Choose proper nts for my 64 bit machine

Enable phalcon and psr extension from Extensions menu and restart laragon

nice, phalcon 4.0.6 installed successfully

Time for phalcon devtools

Preparation before cloning

mv phalcondevtools phalcondevtools3

git clone https://github.com/phalcon/phalcon-devtools.git
Cloning into ‘phalcon-devtools’…
remote: Enumerating objects: 27110, done.
remote: Total 27110 (delta 0), reused 0 (delta 0), pack-reused 27110
Receiving objects: 100% (27110/27110), 19.44 MiB | 1.65 MiB/s, done.
Resolving deltas: 100% (14463/14463), done.

Rename

mv phalcon-devtools phalcondevtools4

mv phalcondevtools3 phalcondevtools

At this moment I have two folder :

phalcondevtools -> for phalcon 3

phalcondevtools4 -> for phalcon 4

Install phalcon dev tools 4′

cd phalcondevtools4

composer install

Check it now

C:\phalcondevtools4 (master)
? phalcon info

Phalcon DevTools (4.0.3)

Environment:
OS: Windows NT DESKTOP-O8J2929 10.0 build 18362 (Windows 10) AMD64
PHP Version: 7.4.4
PHP SAPI: cli
PHP Bin: C:\laragon\bin\php\php-7.4.4-nts-Win32-vc15-x64\php.exe
PHP Extension Dir: C:\php\ext
PHP Bin Dir: C:\php
Loaded PHP config: C:\laragon\bin\php\php-7.4.4-nts-Win32-vc15-x64\php.ini
Versions:
Phalcon DevTools Version: 4.0.3
Phalcon Version: 4.0.6
AdminLTE Version: 2.3.6

Test call from absolutee path

c:\phalcondevtools4\phalcon

Phalcon DevTools (4.0.3)

Available commands:
info (alias of: i)
commands (alias of: list, enumerate)
controller (alias of: create-controller)
module (alias of: create-module)
model (alias of: create-model)
all-models (alias of: create-all-models)
project (alias of: create-project)
scaffold (alias of: create-scaffold)
migration (alias of: create-migration)
webtools (alias of: create-webtools)
serve (alias of: server)
console (alias of: shell, psysh)

Great, now its time for symbolic link

Well, at the moment symbolic link is not work so I use absolute path to create phalcon 4 project.

in Blog | 375 Words

Compile Phalcon Extension on Centminmod

Wow, almost a year I didn’t touch this blog. At least this blog still have visitor from nowhere 🙂

Ok, today I have challenge to install phalcon php extension (at the moment the version is 3.4.2). The vps server already has centminmod installed using latest version of CentOS 7.

Since the server is critical so I decide to use other vps server (get free $25 in credit for new user here) to get the recipe and share it here for others that might need it.

Lets get start!

Update CentOS

# yum update

Check current php version

# php -v

PHP 7.0.33 (cli) (built: Feb 16 2019 10:38:06) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies

Yes, this legacy app run on php 7.0.33

Compile Phalcon php

# git clone --branch v3.4.2 --depth=1 "git://github.com/phalcon/cphalcon.git"

# cd cphalcon/build/

# ./install

Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012
appending configuration tag “CXX” to libtool
mkdir .libs
gcc -I. -I/root/cphalcon/build/php7/64bits -DPHP_ATOM_INC -I/root/cphalcon/build/php7/64bits/include -I/root/cphalcon/build/php7/64bits/main -I/root/cphalcon/build/php7/64bits -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DPHALCON_RELEASE -DHAVE_CONFIG_H -march=native -mtune=native -O2 -fomit-frame-pointer -c /root/cphalcon/build/php7/64bits/phalcon.zep.c -fPIC -DPIC -o .libs/phalcon.o

gcc -shared .libs/phalcon.o -march=native -mtune=native -Wl,-soname -Wl,phalcon.so -o .libs/phalcon.so
creating phalcon.la
(cd .libs && rm -f phalcon.la && ln -s ../phalcon.la phalcon.la)
cp ./.libs/phalcon.so /root/cphalcon/build/php7/64bits/modules/phalcon.so
cp ./.libs/phalcon.lai /root/cphalcon/build/php7/64bits/modules/phalcon.la
PATH=”$PATH:/sbin” ldconfig -n /root/cphalcon/build/php7/64bits/modules
———————————————————————-
Libraries have been installed in:
/root/cphalcon/build/php7/64bits/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR’
flag during linking and do at least one of the following:
– add LIBDIR to the `LD_LIBRARY_PATH’ environment variable
during execution
– add LIBDIR to the `LD_RUN_PATH’ environment variable
during linking
– use the `-Wl,–rpath -Wl,LIBDIR’ linker flag
– have your system administrator add LIBDIR to `/etc/ld.so.conf’

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.

Build complete.
Don’t forget to run ‘make test’.

Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20151012/
Installing header files: /usr/local/include/php/

Thanks for compiling Phalcon!
Build succeed: Please restart your web server to complete the installation

Enable phalcon extension

# nano /etc/centminmod/php.d/phalcon.ini

fill with this line :

extension=phalcon.so

save the file and restart

# nprestart

Check if phalcon extension installed

echo ‘<?php phpinfo();?>’ > /usr/local/nginx/html/info2.php

then access it with browser

or using command line

# php -m | grep phalcon

Handling rewrite problem

“Mod-Rewrite is not enabled

Please enable rewrite module on your web server to continue”

# nano /usr/local/nginx/conf/conf.d/learn.digitalfusi.com.ssl.conf

Change these sections :

1. root /home/nginx/domains/url/public/public;
2. try_files $uri $uri/ /index.php?_url=$uri&$args;

save.

Update 1 :

section 2 need to update as this :

try_files $uri $uri/ @rewrite;

and make new section for @rewrite :

location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
} #rewrite

Update 2 :

Handling error message :

“warning: Remote branch v3.4.3 not found in upstream origin, using HEAD instead”

wget -c https://github.com/phalcon/cphalcon/archive/v3.4.3.tar.gz

tar xvzf v3.4.3.tar.gz

cd cphalcon-3.4.3/build/

./install

Try if rewrite rule work

Edit controller file

# nano /home/nginx/domains/url/public/app/controllers/IndexController.php

Modify the content to this

<?php

class IndexController extends ControllerBase
{

public function indexAction()
{

}

public function testAction($id1,$id2,$id3)

{
echo ‘really nice bro ‘.$id1.’ var 2 :’.$id2.’ var 3 : ‘.$id3;
}
}

save the file.

Access the address from browser

https://url/index/test/d/e/f

and the output will be

really nice bro d var 2 :e var 3 : f

Great, since the value of d,e and f printed correctly then rewrite rule work perfectly.

Note :

  • I upload sample project inside public folder so for root (document root) I change it to public/public.
  • url in this note is depend on you. It might be tld os subdomain
  • I enable https by default so I only deal with ssl.conf file
  • webtools only available from localhost, enable it from cmd -> phalcon project projectname –enable-webtools
in Blog | 819 Words

Free $20 for DevOps Class – openbsd, freebsd, dragonflybsd and netbsd vps

Update : The offer seem no longer available.

I have to prepare for new class that required vps access. The class will teach unix based system like openbsd, freebsd, dragonfly bsd plus netbsd in 12 meets.

This class will be basic for devops but most important thing for me is my student can get full environment in every OS. Vps came to my mind and this March 2017 is really great since Vultr announce great news :

They double everything and they also provide ‘sanbox plan’ for beginner.

In nutshell you’ll get 1GB memory and 25Gb space vps on the OS you choose. SSD speed also superb :

dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync
16384+0 records in
16384+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 3.87756 s, 277 MB/s

For limited time Vultr offer free $20 that you can use for many things;

  • Set git server using gitlab.
  • Set up aws compatible cloud with minio
  • Testing zfs latest FreeBSD 12 vs Hammer in dragonflybsd
  • Tes mysql replicate while setting master in Germany Vps and mysql slave in Paris or Amsterdam.

Long time ago I’ll need $10 server to achieve that but now I just need $5 vps server /mo to get 1GB server which is awesome 🙂

I just spread the news to let others know and grab your free $20 by using this link.

Long live the queen!

in Blog | 221 Words

Install Laravel Valet on macOS Sierra

Just quick note for myself when try Laravel Valet on macOS Sierra (10.12.2)

Install  homebrew (if not installed) :

/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

Install PHP 7.1

Libpng

brew link libpng

Linking /usr/local/Cellar/libpng/1.6.28… 18 symlinks created

brew install homebrew/php/php71

test :

php -v

PHP 7.1.0 (cli) (built: Dec  2 2016 11:32:42) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies

Install Composer

brew install composer

Install Valet

composer global require laravel/valet
cd
nano .bash_profile

Add this line :

export PATH=$PATH:~/.composer/vendor/bin

save.

source .bash_profile
echo $PATH

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/alamsyahrasyid/.composer/vendor/bin

valet install

Password:
[nginx] is not installed, installing it now via Brew… ?
[dnsmasq] is not installed, installing it now via Brew… ?

Valet installed successfully!

Start valet

valet start

Valet services have been started.

Install mysql

brew install mariadb
brew services start mariadb

 

in Blog | 163 Words