sudo yum install -y epel-release
yum -y install centos-release-scl-rh centos-release-scl
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install -y https://centos7.iuscommunity.org/ius-release.rpm
yum update
timedatectl set-timezone Asia/Ho_Chi_Minh
timedatectl
yum install firewalld
systemctl start firewalld
# add some services
firewall-cmd --permanent --add-service=ssh
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-service=smtp
firewall-cmd --reload
systemctl enable firewalld
Some command usefull
firewall-cmd --permanent --add-port=4444/tcp
firewall-cmd --permanent --remove-port=4444/tcp
firewall-cmd --get-services
firewall-cmd --permanent --list-all
# List port http
semanage port -l | grep http_port_t
# Add port
semanage port -a -t http_port_t -p tcp 8090
# Remove port
semanage port -d -t http_port_t -p tcp 8090
yum -y install gcc gcc-c++ wget
adduser cent
passwd cent
gpasswd -a cent wheel
su - cent
mkdir .ssh
chmod 700 .ssh
vi .ssh/authorized_keys
# -> Paste public key and save
chmod 600 .ssh/authorized_keys
exit
systemctl reload sshd
yum install -y git
Check your git version
git --version
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
yum --enablerepo=epel -y install nginx
systemctl start nginx.service
systemctl enable nginx.service
systemctl start nginx.service
systemctl enable nginx.service
yum --enablerepo=remi,remi-php73 install -y php php-fpm php-cli php-mysqlnd php-zip php-devel php-gd php-common php-pear php-mbstring php-mcrypt php-pdo php-curl php-xml php-pear php-bcmath php-json
scl enable php73 bash
Use php -v
to check result:
PHP 7.3.4 (cli) (built: Apr 2 2019 13:48:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.4, Copyright (c) 1998-2018 Zend Technologies
vi /etc/php-fpm.d/www.conf
Change user = apache
to user = nginx
and group = apache
to group = nginx
vi /etc/php.ini
Change upload_max_filesize
and post_max_size
(change xx
to size you want):
upload_max_filesize = xxM
...
post_max_size = xxM
systemctl stop httpd.service
systemctl disable httpd.service
systemctl start php-fpm.service
systemctl enable php-fpm.service
vi /etc/nginx/conf.d/default.conf
Change content to (change example.com
to your domain or ip, xx
to size you want)
client_max_body_size xxM;
server {
listen 80;
server_name example.com;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
systemctl restart nginx.service
sudo yum --enablerepo=centos-sclo-rh -y install rh-mariadb102-mariadb-server
scl enable rh-mariadb102 bash
Use mysql -V
to check result:
mysql -V
# mysql Ver 15.1 Distrib 10.2.8-MariaDB, for Linux (x86_64) using EditLine wrapper
vi /etc/profile.d/rh-mariadb102.sh
"rh-mariadb102.sh" content:
# create new
#!/bin/bash
source /opt/rh/rh-mariadb102/enable
export X_SCLS="`scl enable rh-mariadb102 'echo $X_SCLS'`"
vi /etc/opt/rh/rh-mariadb102/my.cnf.d/mariadb-server.cnf
Add follows into [mysqld] section:
[mysqld]
character-set-server=utf8
Start & Enable
systemctl start rh-mariadb102-mariadb
systemctl enable rh-mariadb102-mariadb
Initial and setup root password
mysql_secure_installation
systemctl stop rh-mariadb102-mariadb
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
systemctl start rh-mariadb102-mariadb
mysql -u root
# In Mysql command
> USE mysql;
> UPDATE user SET password=PASSWORD('newPassword') WHERE User='root' AND Host = 'localhost';
> exit
systemctl stop rh-mariadb102-mariadb
systemctl unset-environment MYSQLD_OPTS
systemctl start rh-mariadb102-mariadb
sudo yum --enablerepo=remi,remi-php73 install -y php-mysqlnd phpMyAdmin
Link to /usr/share/nginx/html
sudo ln -s /usr/share/phpMyAdmin /usr/share/nginx/html
Change chown folder /var/lib/php/session
from apache
to nginx
chown -R nginx:nginx /var/lib/php/session
Restart PHP-FPM
systemctl restart php-fpm.service
yum --enablerepo=centos-sclo-rh -y install rh-postgresql10-postgresql-server
scl enable rh-postgresql10 bash
vi /etc/profile.d/rh-postgresql10.sh
"rh-postgresql10.sh" content
# create new
#!/bin/bash
source /opt/rh/rh-postgresql10/enable
export X_SCLS="`scl enable rh-postgresql10 'echo $X_SCLS'`"
postgresql-setup --initdb --unit rh-postgresql10-postgresql
systemctl start rh-postgresql10-postgresql
systemctl enable rh-postgresql10-postgresql
su - postgres
createuser cent
createdb testdb -O cent
# Login as cent user
root$ su cent
# List database
cent$ psql -l
# Select db & Set password
cent$ psql testdb
testdb=# alter user cent with password 'password';
# => ALTER ROLE
vi /var/opt/rh/rh-postgresql102/lib/pgsql/data/pg_hba.conf
# line 82: change like follows and add access permission
host all all 127.0.0.1/32 md5
host all all 10.0.0.0/24 md5
host all all ::1/128 md5
sudo vi /etc/yum.repos.d/mongodb-org-4.0.repo
Change content to:
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
Save and close the file. Use yum repolist
to check, content will be like this:
...
mongodb-org-4.0/7 MongoDB Repository 5
...
sudo yum install -y mongodb-org
Start & Enable MongoDB service with the systemctl utility:
sudo systemctl start mongod
sudo systemctl enable mongod
sudo yum install redis -y
Start & Enable Redis service with the systemctl utility:
sudo systemctl start redis.service
sudo systemctl enable redis
Check Redis status
sudo systemctl status redis.service
Ping Redis
redis-cli ping
!!! Required IUS Repo
yum install -y python36u python36u-libs python36u-devel python36u-pip
Check verion
python3.6 -V
pip3.6 -V
curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
yum info nodejs
###
#Arch : x86_64
#Epoch : 2
#Version : 10.15.3
#Release : 1nodesource
#Size : 53 M
###
yum install -y nodejs
node --version
# v10.15.3
npm --version
# 6.4.1