sudo yum install -y epel-releaseyum -y install centos-release-scl-rh centos-release-sclrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpmrpm -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 --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
adduser admin
passwd admin
gpasswd -a admin wheelsu - admin
mkdir .ssh
chmod 700 .ssh
vi .ssh/authorized_keys
# -> Paste public key and save
chmod 600 .ssh/authorized_keys
exit
systemctl reload sshdyum install -y git
Check your git version
git --version
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
yum --enablerepo=epel -y install nginxsystemctl start nginx.service
systemctl enable nginx.servicesystemctl start nginx.service
systemctl enable nginx.serviceyum --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/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
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
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