ggg
Anonymous
1K x views • 5 years ago
#! /bin/bash
echo "--> CentOS System, Pasang Apache, PHP, MariaDB <--"
echo "Nama Pelanggan : ";
read a;
echo "Selamat Datang Mr./Mrs. $a, Lanjut?";
sudo yum -y update
sudo reboot
https://www.youtube.com/watch?v=YGNeZV1raGQ&feature=emb_title
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm [On CentOS/RHEL 7]
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
dnf install http://rpms.remirepo.net/fedora/remi-release-29.rpm [On Fedora 29]
#_centos6
yum update && yum install epel-release
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
#_centos7
yum update && yum install epel-release
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
#_centos8
dnf install httpd -y
systemctl enable --now httpd
systemctl status httpd
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
firewall-cmd --list-services
dnf info php
dnf install php
systemctl enable php-fpm
systemctl start php-fpm
systemctl status php-fpm
dnf search php-
php-gd.x86_64 : A module for PHP applications for using the gd graphics library
php-cli.x86_64 : Command-line interface for PHP
php-fpm.x86_64 : PHP FastCGI Process Manager
php-cli.x86_64 : Command-line interface for PHP
cd /var/www/html/
echo "<h1>hello world</h1>" > index.html
cd /var/www
mkdir superuser.web.id wpdev.web.id
echo "<h1>superuser.web.id</h1>" > superuser.web.id/index.html
echo "<h1>wpdev.web.id</h1>" > wpdev.web.id/index.html
cd /etc/httpd/conf.d/
vi superuser.web.id.conf
<VirtualHost *:80>
ServerName www.superuser.web.id
ServerAlias superuser.web.id
DocumentRoot /var/www/superuser.web.id
<Directory /var/www/superuser.web.id>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/superuser.web.id_error.log
CustomLog /var/log/httpd/superuser.web.id_access.log combined
</VirtualHost>
vi wpdev.web.id.conf
<VirtualHost *:80>
ServerName www.wpdev.web.id
ServerAlias wpdev.web.id
DocumentRoot /var/www/wpdev.web.id
<Directory /var/www/wpdev.web.id>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/wpdev.web.id_error.log
CustomLog /var/log/httpd/wpdev.web.id_access.log combined
</VirtualHost>
systemctl restart httpd
systemctl status httpd
#_rhel7
subscription-manager repos --enable=rhel-7-server-optional-rpms
#_rhel6
subscription-manager repos --enable=rhel-6-server-optional-rpms
#_Fedora 24-29
# rpm -Uvh http://rpms.remirepo.net/fedora/remi-release-29.rpm [On Fedora 29]
# rpm -Uvh http://rpms.remirepo.net/fedora/remi-release-28.rpm [On Fedora 28] dst
RHEL or CentOS 7
yum install yum-utils
shows all enabled repositories. These two commands are identical.
yum repolist
yum -v repolist all
yum repolist disabled
yum-config-manager --disable remi-php54
yum-config-manager --enable remi-php74
yum-config-manager --enable remi-php73
#_For example, to install PHP 7.x version, use the following command.
#_---------CentOS & RHEL -------------
yum-config-manager --enable remi-php70 && yum install php
yum-config-manager --enable remi-php71 && yum install php
yum-config-manager --enable remi-php72 && yum install php
yum-config-manager --enable remi-php73 && yum install php
yum-config-manager --enable remi-php74
#_------------- On Fedora -------------
dnf --enablerepo=remi install php70
dnf --enablerepo=remi install php71
dnf --enablerepo=remi install php72
dnf --enablerepo=remi install php73 [Install PHP 7.3]
#_------ RHEL/CentOS 7/6------
yum search all php
#_------ Fedora / CENTOS 8------
dnf search all php
yum install httpd mariadb mariadb-server php php-common php-mysql php-gd php-xml php-mbstring php-mcrypt
yum install httpd mariadb mariadb-server php php-common php-mysql php-gd php-xml php-mbstring php-mcrypt
systemctl start mariadb
mysql_secure_installation
systemctl enable mariadb
systemctl start httpd
systemctl enable httpd
Then we will configure MariaDB to start automatically on system boot:
systemctl enable mariadb
systemctl start httpd
systemctl enable httpd
# mysql -u root -p
Enter password:
## Create database ##
CREATE DATABASE wordpress;
## Creating new user ##
CREATE USER wordpress@localhost IDENTIFIED BY "secure_password";
## Grant privileges to database ##
GRANT ALL ON wordpress.* TO wordpress@localhost;
## FLUSH privileges ##
FLUSH PRIVILEGES;
## Exit ##
exit
cd /tmp && wget http://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz -C /var/www/html
/var/www/html/wordpress
chown -R apache /var/www/html/wordpress
#Creating Apache Virtual Host for WordPress
vim /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/wordpress
ServerName tecminttest.com
ServerAlias www.tecminttest.com
ErrorLog /var/log/httpd/tecminttest-error-log
CustomLog /var/log/httpd/tecminttest-acces-log common
</VirtualHost>
systemctl restart httpd
#_on ubuntu add vhost domain demo like www.wordpress.lan
$ sudo nano /etc/hosts
$ ping wordpress.lan
#_ in windows C:\Windows\System32\drivers\etc
sudo apt-get install apache2 apache2-utils php libapache2-mod-php php-mysql php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip mariadb-server mariadb-client
sudo apt-get install phpmyadmin
sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/
sudo mv /etc/apache2/conf-available/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin
sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/
sudo mv /etc/apache2/conf.d/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
#_next step is to create a Virtual Host on the Apache web server
sudo nano /etc/apache2/sites-available/wordpress.conf
<VirtualHost *:80>
ServerName wordpress.lan
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite wordpress.conf
sudo systemctl reload apache2
#_To avoid that future Apache error concerning, ServerName FQDN missing open main configfile '/etc/apache2/apache2.conf',
ServerName wordpress.lan
sudo systemctl restart apache2
sudo mysql_secure_installation
sudo mysql -u root -p
CREATE DATABASE mysite;
GRANT ALL PRIVILEGES ON mysite.* TO 'mysiteadmin'@'localhost' IDENTIFIED BY 'SecureP@ssHere!';
FLUSH PRIVILEGES;
EXIT;
wget http://wordpress.org/latest.tar.gz
sudo tar xvzf latest.tar.gz
sudo cp -r wordpress/* /var/www/html
#_On Debian systems, run the following commands.
$ sudo tar xvzf latest.tar.gz
$ sudo mkdir -p /var/www/html
$ sudo cp -r wordpress/* /var/www/html
$ sudo service apache2 restart
$ sudo service mysql restart
$ sudo chown -R www-data /var/www/html
$ sudo chmod -R 755 /var/www/html
http://wordpress.lan/index.php
sudo chown -R root /var/www/html
#_Enable HTTPS on WordPress
$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository universe
$ sudo apt-get update
$ sudo apt-get install certbot python3-certbot-nginx
$ sudo certbot --apache
#_you can check your site’s HTTPS at https://www.ssllabs.com/ssltest/.
yum list php
yum install httpd
systemctl enable httpd
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
#_Install repository Remi. Repository Remi ini menyediakan PHP versi 5.4, 7.0, 7.1, dan 7.2.
#_Perintah install repository di bawah ini akan menambah file .repo di /etc/yum.repos.d.
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
ls -l /etc/yum.repos.d
yum install yum-utils
yum-config-manager --enable remi-php70
yum info php
yum install php php-common
systemctl restart httpd
nano /var/www/html/info.php
#_php_di_ubuntu Install Apache and FastCGI module.
sudo apt update
sudo apt install apache2 libapache2-mod-fcgid -y
#_Install PHP and PHP-FPM.
sudo apt install php php-fpm -y
sudo systemctl status php7.4-fpm
sudo a2enmod actions fcgid alias proxy_fcgi
sudo nano /etc/apache2/sites-available/000-default.conf
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>
sudo systemctl restart apache2
sudo systemctl status apache2
#_Access http://localhost/info.php or http://serverIP/info.php. In the Server API the value is FPM/FastCGI.
sudo echo "<?php phpinfo(); ?>" > /var/www/html/info.php
Server requirements that must be met to run Laravel 8:
PHP > 7.3_!_BCMath PHP Extension_!_Ctype PHP Extension_!_Fileinfo PHP extension_!_JSON PHP Extension
Mbstring PHP Extension_!_OpenSSL PHP Extension_!_PDO PHP Extension_!_Tokenizer_PHP_Extension_!_XML PHP Extension
sudo apt install composer
sudo apt install php php-common php-bcmath php-mbstring php-mysql php-tokenizer php-zip
#_Install Laravel 8.0 using Composer and save it in the /home/user/public_html/blog
mkdir ~/public_html
cd ~/public_html
composer create-project laravel/laravel blog 8.0
composer create-project laravel/laravel blog
cd blog
php artisan serve
#_Browse http://127.0.0.1:8000 atau http://localhost:8000.
sudo apt install apache2 libapache2-mod-php
sudo systemctl restart apache2
sudo systemctl status apache2
#_URL http://127.0.0.1:8000 can be changed to a hostname or local domain using Apache virtual host & the file /etc/hosts.
<VirtualHost *:80>
ServerName laravel.web
DocumentRoot /home/user/public_html/blog/public
<Directory /home/user/public_html/blog/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/laravel.web_error.log
CustomLog /var/log/apache2/laravel.web_access.log combined
</VirtualHost>
sudo a2ensite laravel.web.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
sudo chown -R $USER:www-data /home/user/public_html/blog
sudo chmod -R 775 /home/user/public_html/blog
sudo nano /etc/hosts
127.0.0.1 laravel.web @@
sudo apt install build-essential curl file git
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
Make homebrew available in the system environment:
test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo eval" ($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval $($(brew --prefix)/bin/brew shellenv)" >>~/.profile
Install the dependency package for mkcert:
sudo apt install libnss3-tools
brew install mkcert
mkcert -install
#_Create an SSL certificate for laravel.web:
mkcert laravel.web
sudo mkdir /etc/apache2/ssl
sudo mv laravel.web*.pem /etc/apache2/ssl
sudo nano /etc/apache2/sites-available/laravel.web.conf
<VirtualHost *:80>
ServerName laravel.web
RewriteEngine on
RewriteCond %{SERVER_NAME} =laravel.web
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName laravel.web
DocumentRoot /home/user/public_html/blog/public
<Directory /home/user/public_html/blog/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/laravel.web_error.log
CustomLog /var/log/apache2/laravel.web_access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/laravel.web.pem
SSLCertificateKeyFile /etc/apache2/ssl/laravel.web-key.pem
</VirtualHost>
</IfModule>
sudo a2enmod ssl
sudo systemctl restart apache2
Browse https://laravel.web.
sudo apt install mariadb-server
sudo mysql_secure_installation
Enter current password for root (enter for none): ENTER
Set root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
sudo mysql -u root -p
CREATE DATABASE blog;
CREATE USER 'userblog'@'localhost' IDENTIFIED BY 'passblog';
GRANT ALL PRIVILEGES ON blog.* TO 'userblog'@'localhost';
FLUSH PRIVILEGES;
EXIT;
nano ~/public_html/blog/.env
DB_DATABASE=blog
DB_USERNAME=userblog
DB_PASSWORD=passblog
php artisan migrate
Install laravel/jetstream:
composer require laravel/jetstream
composer update
Install livewire:
php artisan jetstream:install livewire
#_laravel apache ubuntu
sudo apt install composer
sudo apt install php php-common php-bcmath php-mbstring php-mysql php-tokenizer php-zip
mkdir ~/public_html
cd ~/public_html
composer create-project laravel/laravel blog 8.0
composer create-project laravel/laravel blog
cd blog
php artisan serve
http://127.0.0.1:8000 atau http://localhost:8000.
sudo apt install apache2 libapache2-mod-php
sudo apt install apache2 libapache2-mod-php
sudo systemctl restart apache2
sudo systemctl status apache2
hostname atau local domain dengan menggunakan Apache virtual host dan file /etc/hosts.
laravel.web:
sudo nano /etc/apache2/sites-available/laravel.web.conf
<VirtualHost *:80>
ServerName laravel.web
DocumentRoot /home/musaamin/public_html/blog/public
<Directory /home/musaamin/public_html/blog/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/laravel.web_error.log
CustomLog /var/log/apache2/laravel.web_access.log combined
</VirtualHost>
sudo a2ensite laravel.web.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
sudo chown -R $USER:www-data /home/musaamin/public_html/blog
sudo chmod -R 775 /home/musaamin/public_html/blog
sudo nano /etc/hosts
127.0.0.1 laravel.web
sudo apt install build-essential curl file git
#_Download dan jalankan installer Homebrew:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo eval" ($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval $($(brew --prefix)/bin/brew shellenv)" >>~/.profile
brew install mkcert
#_Install Certificate Authority (CA):
mkcert -install
mkcert laravel.web
sudo mkdir /etc/apache2/ssl
sudo mv laravel.web*.pem /etc/apache2/ssl
sudo nano /etc/apache2/sites-available/laravel.web.conf
<VirtualHost *:80>
ServerName laravel.web
RewriteEngine on
RewriteCond %{SERVER_NAME} =laravel.web
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName laravel.web
DocumentRoot /home/musaamin/public_html/blog/public
<Directory /home/musaamin/public_html/blog/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/laravel.web_error.log
CustomLog /var/log/apache2/laravel.web_access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/laravel.web.pem
SSLCertificateKeyFile /etc/apache2/ssl/laravel.web-key.pem
</VirtualHost>
</IfModule>
sudo a2enmod ssl
sudo systemctl restart apache2
sudo mysql_secure_installation
Enter current password for root (enter for none): ENTER
Set root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
sudo mysql -u root -p
CREATE DATABASE blog;
CREATE USER 'userblog'@'localhost' IDENTIFIED BY 'passblog';
GRANT ALL PRIVILEGES ON blog.* TO 'userblog'@'localhost';
FLUSH PRIVILEGES;
EXIT;
#_Buka file .env:
nano ~/public_html/blog/.env
Konfigurasi koneksi database:
DB_DATABASE=blog
DB_USERNAME=userblog
DB_PASSWORD=passblog
php artisan migrate
Memasang laravel/jetstream:
composer require laravel/jetstream
composer update
php artisan jetstream:install livewire
#_install_ioncube................................
yum install httpd php php-cli
systemctl enable httpd
systemctl start httpd
systemctl status httpd
curl -O https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xzvf ioncube_loaders_lin_x86-64.tar.gz
ls ioncube
php -i | grep extension_dir
extension_dir => /usr/lib64/php/modules => /usr/lib64/php/modules
Copy ionCube Loader 5.4 ke extension directory.
cp ioncube/ioncube_loader_lin_5.4.so /usr/lib64/php/modules
#_Masukkan ionCube Loader ke dalam konfigurasi PHP.
vi /etc/php.ini
#_Masukkan opsi di bawah ini ke dalam file php.ini.
zend_extension = /usr/lib64/php/modules/ioncube_loader_lin_5.4.so
Restart Apache web server.
systemctl restart httpd
php -v
#_Here are the packages that we will install. Please keep in mind that MySQL 8 connectors (PHP, Perl, Python, Java, etc.) #_will work unchanged with MariaDB as both systems use the same client protocol & the client lib are binary compatible.
yum-config-manager --enable remi-php72 && yum install php
yum-config-manager --enable remi-php73 && yum install php
yum search php
yum install php php-mysql php-pdo php-gd php-mbstring
#echo "<?php phpinfo(); ?>" > /var/www/html/info.php
#systemctl restart httpd
#_if you get an error on PHP Date & Timezone, open php.ini config file https://www.php.net/manual/en/timezones.php
#_search and uncomment date.timezone statement, append your physical location & restart Apache daemon.
nano /etc/php.ini
date.timezone = Continent/City
#_centos7
yum --enablerepo=remi install php-mysqlnd php-pgsql php-pecl-mongo php-pdo php-pecl-memcache php-pecl-memcached php-gd php-xml php-mbstring php-mcrypt php-pecl-apcu php-cli php-pear
#_centos8
dnf --enablerepo=remi install php-mysqlnd php-pgsql php-pecl-mongo php-pdo php-pecl-memcache php-pecl-memcached php-gd php-xml php-mbstring php-mcrypt php-pecl-apcu php-cli php-pear
MariaDB/MySQL (php-mysql) – a dynamic shared object that will add MariaDB support to PHP.
PostgreSQL (php-pgsql) – PostgreSQL database support for PHP.
MongoDB (php-pecl-mongo) – An interface for communicating with the MongoDB database in PHP.
Generic (php-pdo) – A dynamic shared object that will add a database access abstraction layer to PHP.
Memcache (php-pecl-memcache) – Memcached is a caching daemon designed especially for dynamic web applications to decrease database load by storing objects in memory.
Memcached (php-pecl-memcached) An extension that uses the libmemcached lib to provide API for communicating with memcached servers.
GD (php-gd) – A dynamic share object that adds support for using the gd graphics library to PHP.
XML (php-xml) – A dynamic shared objects that adds support to PHP for manipulating XML documents.
MBString (php-mbstring) – An extension to handle multi-byte string in PHP applications.
MCrypt (php-mcrypt) – A Mcrypt library for PHP scripts.
APC (php-pecl-apcu) – APC module used to optimize and cache PHP code.
CLI (php-cli) – Command-line interface for PHP.
PEAR (php-pear) – Application Repository framework for PHP.
Install these following necessary PHP modules with the command below.
#_
rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm [On RHEL/CentOS 7]
# rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm [On RHEL/CentOS 6]
# rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-fc29-1.noarch.rpm [On Fedora 29]
# rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-fc28-1.noarch.rpm [On Fedora 28]
#_After installing the MySQL Yum repofor your Linux platform, now install the latest version (currently 8.0)
yum install mysql-community-server [On RHEL/CentOS]
# dnf install mysql-community-server [On Fedora]
service mysqld start
yum install httpd
#systemctl status|start|stop|restart|reload httpd
#service httpd status|start|stop|restart|reload
#apachectl configtest| graceful
#_Apache DocumentRoot path it’s set to /var/www/html
nano /etc/httpd/conf.d/welcome.conf
systemctl restart httpd
# systemctl start httpd
# systemctl enable httpd
# systemctl status httpd
#_Apache Virtual Hosts in RHEL/CentOS 7
cd /etc/httpd/
mkdir sites-available sites-enabled
nano conf/httpd.conf
on httpd.conf in /etc/httpd/sites-enabled
IncludeOptional sites-enabled/*.conf
nano /etc/httpd/sites-available/rheltest.lan.conf
<VirtualHost *:80>
ServerName rheltest.lan
DocumentRoot "/var/www/rheltest.lan"
<Directory "/var/www/rheltest.lan">
Options Indexes FollowSymLinks MultiViews
# AllowOverride controls what directives may be placed in .htaccess files.
AllowOverride All
# Controls who can get stuff from this server file
Order allow,deny
Allow from all
</Directory>
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
ErrorLog /var/log/httpd/rheltest.lan-error.log
CustomLog /var/log/httpd/rheltest.lan-access.log combined
</VirtualHost>
#_time to create a2ensite & a2dissite bash scripts on a executable system path-in this case is /usr/local/bin/ – but
#_you can use any executable path that $PATH system variable outputs. Create a2ensite Script
nano /usr/local/bin/a2ensite
#---------------------------
#!/bin/bash
if test -d /etc/httpd/sites-available && test -d /etc/httpd/sites-enabled ;
then
echo "-----------------------------------------------"
else
mkdir /etc/httpd/sites-available
mkdir /etc/httpd/sites-enabled
fi
avail=/etc/httpd/sites-available/$1.conf
enabled=/etc/httpd/sites-enabled/
site='ls /etc/httpd/sites-available/'
if [ "$#" != "1" ]; then
echo "Use script: a2ensite virtual_site"
echo -e "\nAvailable virtual hosts:\n$site"
exit 0
else
if test -e $avail; then
sudo ln -s $avail $enabled
else
echo -e "$avail virtual host does not exist! Please create one!\n$site"
exit 0
fi
if test -e $enabled/$1.conf; then
echo "Success!! Now restart Apache server: sudo systemctl restart httpd"
else
echo -e "Virtual host $avail does not exist!\nPlease see available virtual hosts:\n$site"
exit 0
fi
fi
#--------------------
#_Create a2dissite Script
nano /usr/local/bin/a2dissite
#------------------
#!/bin/bash
avail=/etc/httpd/sites-enabled/$1.conf
enabled=/etc/httpd/sites-enabled
site='ls /etc/httpd/sites-enabled/'
if [ "$#" != "1" ]; then
echo "Use script: a2dissite virtual_site"
echo -e "\nAvailable virtual hosts: \n$site"
exit 0
else
if test -e $avail; then
sudo rm $avail
else
echo -e "$avail virtual host does not exist! Exiting!"
exit 0
fi
if test -e $enabled/$1.conf; then
echo "Error!! Could not remove $avail virtual host!"
else
echo -e "Success! $avail has been removed!\nPlease restart Apache: sudo systemctl restart httpd"
exit 0
fi
fi
#-------------
chmod +x /usr/local/bin/a2*
a2ensite vhost_name
a2disite vhost_name
#_To test it, enable the virtual host created earlier, restart Apache then load http://rheltest.lan.
a2ensite rheltest.lan
systemctl restart httpd
#_That’s it! Now you can use a2eniste and a2dissite bash scripts as system commands to manage Apache Vhosts
#_Lets set up Name Based Virtual Hosting and IP based Virtual hosting in RHEL, CentOS and Fedora.
#_OS – CentOS 6.5
#_Application – Apache Web Server
#_IP Address – 192.168.0.100
#_IP Address – 192.168.0.101
#_Domain – www.example1.com
#_Domain – www.example2.com
#_before creating a virtual host, you need to create a directory
mkdir /var/www/html/example1.com/
mkdir /var/www/html/example1.com/
vi /etc/httpd/conf/httpd.conf
NameVirtualHost 192.168.0.100:80 @@
#_move to the bottom of the file by pressing Shift + G
<VirtualHost 192.168.0.100:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/example1.com
ServerName www.example1.com
ErrorLog logs/www.example1.com-error_log
CustomLog logs/www.example1.com-access_log common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/example2.com
ServerName www.example2.com
ErrorLog logs/www.example2.com-error_log
CustomLog logs/www.example2.com-access_log common
</VirtualHost>
[root@tecmint ~]# httpd -t
Syntax OK
service httpd restart
#_If syntax is OK. Please restart your Web server and add it to chkconfig
#_to make your web server start in runlevel 3 and 5 at the boot time only.
chkconfig --level 35 httpd on
[root@tecmint ~]# vi /var/www/html/example1.com/index.html
<html><head><title>www.example1.com</title></head><body><h1>Hello, Welcome to www.exa1.com.</h1></body></html>
[root@tecmint ~]# vi /var/www/html/example2.com/index.html
<html><head><title>www.example2.com</title></head><body><h1>Hello, Welcome to www.exa2.com.</h1></body></html>
http://www.example1.com
http://www.example2.com
#_To setup IP based virtual hosting, you must have more than one IP address/Port assigned to your server or your Linux
#_It can be on a single NIC card , For example: eth0:1, eth0:2, eth0:3 … so forth. Multiple NIC cards can also be #_attached. If you don’t know how to create multiple IP’s on single NIC, follow the below guide, that will help you
#_As you can see in above output, two IPs 192.168.0.100 (eth0) and 192.168.0.101 (eth0:1) is attached to the server, #_both IPs are assigned to the same physical network device (eth0). Search for word "Listen" on httpd.conf ,
[root@tecmint ~]# vi /etc/httpd/conf/httpd.conf
# Listen 80
Listen 192.168.0.100:80
#_Now, create a Virtual host sections for both the domains. Go the bottom of the file
<VirtualHost 192.168.0.100:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/example1
ServerName www.example1.com
ErrorLog logs/www.example1.com-error_log
TransferLog logs/www.example1.com-access_log
</VirtualHost>
<VirtualHost 192.168.0.101:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/example2
ServerName www.example2.com
ErrorLog logs/www.example2.com-error_log
TransferLog logs/www.example2.com-access_log
</VirtualHost>
service httpd restart
#_Installing MariaDB 10 Database Server
vi /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
#_------ On RHEL/CentOS 7 ------
yum --enablerepo=remi install httpd MariaDB-client MariaDB-server
#_------ On Fedora / CENTOS 8------
dnf --enablerepo=remi install httpd MariaDB-client MariaDB-server
systemctl enable httpd
systemctl enable mariadb
systemctl start httpd
systemctl start mariadb
#_On SysVinit
chkconfig --levels 235 httpd on
chkconfig --levels 235 mysqld on
#------ Start Apache and MySQL ------
/etc/init.d/httpd start
/etc/init.d/mysqld start
yum install mariadb-server mariadb
systemctl start mariadb
mysql_secure_installation
systemctl enable mariadb
#_by default official RHEL 7.0 or CentOS 7.0 repositories doesn’t provide PHPMYADMIN
#_install PhpMyAdmin package by enabling CentOS 7.0 rpmforge repositories using the following command.
yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
yum install phpmyadmin
nano /etc/httpd/conf.d/phpmyadmin.conf
Order Deny,Allow @@
Deny from all @@
Allow from 127.0.0.1 @@
#_To be able to login to PhpMyAdmin Web interface using cookie authentication method
#_add a blowfish string to phpmyadmin config.inc.php file using the generate a secret string, restart Apache Web
$cfg['blowfish_secret'] = 'ftwetwe94892fwbc'; @@
#_postgres
sudo yum repolist
sudo yum search postgresql13
sudo yum -y install postgresql13 postgresql13-server
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl start postgresql-13
sudo systemctl status postgresql-13
sudo systemctl enable postgresql-13
sudo su - postgres
psql -c "alter user postgres with password 'FromVarRead'" !!!!
sudo vi /var/lib/pgsql/13/data/postgresql.conf
listen_addresses = '172.20.11.11' @@@
sudo vi /var/lib/pgsql/13/data/pg_hba.conf
# Accept from anywhere (not recommended)
host all all 0.0.0.0/0 md5 @@
# Accept from trusted subnet (Recommended setting)
host all all 172.20.11.0/24 md5 @@
sudo systemctl restart postgresql-13
sql -U <dbuser> -h <serverip> -p 5432 <dbname> @@
systemctl status firewalld
firewall-cmd --state
dnf install firewalld
systemctl start firewalld
systemctl enable firewalld
systemctl status firewalld
firewall-cmd --state
firewall-cmd --get-zones
firewall-cmd --list-all-zones
firewall-cmd --get-active-zones
firewall-cmd --get-default-zone
#_Menampilkan konfigurasi satu zone, misalnya public.
firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: enp0s3 enp0s8
sources:
services: cockpit dhcpv6-client ssh
ports:
protocols:
masquerade: no
forward-ports:
#_Konfigurasi public zone di atas hanya mengijinkan service yang terdaftar yaitu cockpit, dhcpv6-client, dan ssh.
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --reload
firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: enp0s3 enp0s8
sources:
services: cockpit dhcpv6-client http ssh
firewall-cmd --get-services
#_Menghapus service dari zone gunakan remove.
firewall-cmd --zone=public --remove-service=http
#_Misalnya kita ingin mengijinkan akses ke port nomor 5000 untuk protokol TCP dan UDP.
firewall-cmd --zone=public --add-port=5000/tcp --permanent
firewall-cmd --zone=public --add-port=5000/udp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: enp0s3 enp0s8
sources:
services: cockpit dhcpv6-client http ssh
ports: 5000/tcp 5000/udp
protocols:
masquerade: no
firewall-cmd --zone=public --list-ports
5000/tcp 5000/udp
firewall-cmd --zone=public --remove-port=5000/tcp --permanent
firewall-cmd --zone=public --remove-port=5000/udp --permanent
firewall-cmd --reload
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
firewall-cmd --list-services
#_If you are running firewalld, make sure to allow Apache traffic on the firewall.
# firewall-cmd --zone=public --permanent --add-service=http
# firewall-cmd --zone=public --permanent --add-service=https
# firewall-cmd --reload
firewall-cmd --add-service=http
firewall-cmd --permanent --add-service=http
systemctl restart firewalld
# firewall-cmd --state
# firewall-cmd --list-all
# firewall-cmd --list-interfaces
# firewall-cmd --get-service
# firewall-cmd --query-service service_name
# firewall-cmd --add-port=8080/tcp
centos8
https://musaamin.web.id/cara-install-php-dengan-nginx-di-centos-8/
dnf install nginx
systemctl enable --now nginx
systemctl start nginx
systemctl status nginx
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
firewall-cmd --list-services
dnf install php php-mysqlnd php-pdo php-gd php-mbstring
systemctl enable php-fpm
systemctl start php-fpm
systemctl status php-fpm
cd /usr/share/nginx/html
echo "<?php phpinfo(); ?>" > info.php #_Lalu browsing http://ip-server/info.php.
#_Buat Document Root terlebih dahulu dan file testing PHP.
mkdir /var/www/superuser.web.id
echo "<?php phpinfo(); ?>" > /var/www/superuser.web.id
vi /etc/nginx/conf.d/superuser.web.id.conf
server {
listen 80;
server_name superuser.web.id;
root /var/www/superuser.web.id;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
}
access_log /var/log/nginx/superuser.web.id.access.log;
error_log /var/log/nginx/superuser.web.id.error.log warn;
}
systemctl restart nginx
systemctl status nginx
#_ cari nama paketnya dengan perintah dnf search.
dnf search php-
php-gd.x86_64 : A module for PHP applications for using the gd graphics library
php-cli.x86_64 : Command-line interface for PHP
php-fpm.x86_64 : PHP FastCGI Process Manager
php-cli.x86_64 : Command-line interface for PHP
systemctl enable --now nginx
systemctl start nginx
systemctl status nginx
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
firewall-cmd --list-services
https://usaamin.web.id/cara-install-php-7-4-di-centos-8/
dnf install epel-release -y
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
dnf module list php
dnf module enable php:remi-7.4
dnf install php php-cli php-common
systemctl enable httpd
systemctl start httpd
systemctl status httpd
#_Cek status php-fpm service, karena CentOS 8 tidak pakai Apache module. Install PHP tadi jadi menginstall PHP-FPM.
systemctl enable php-fpm
systemctl status php-fpm
UBUNT
-----------------------------
https://saamin.web.id/how-to-install-laravel-8-on-ubuntu-2004/
Server requirements that must be met to run Laravel 8:
PHP >= 7.3
BCMath PHP Extension
Ctype PHP Extension
Fileinfo PHP extension
JSON PHP Extension
Mbstring PHP Extension
OpenSSL PHP Extension
PDO PHP Extension
Tokenizer PHP Extension
XML PHP Extension
sudo apt install composer
sudo apt install php php-common php-bcmath php-mbstring php-mysql php-tokenizer php-zip
mkdir ~/public_html
cd ~/public_html
composer create-project laravel/laravel blog 8.0
composer create-project laravel/laravel blog
cd blog
php artisan serve
#_Starting Laravel development server: http://127.0.0.1:8000
sudo apt install apache2 libapache2-mod-php
sudo systemctl restart apache2
sudo systemctl status apache2
sudo nano /etc/apache2/sites-available/laravel.web.conf
<VirtualHost *:80>
ServerName laravel.web
DocumentRoot /home/user/public_html/blog/public
<Directory /home/user/public_html/blog/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/laravel.web_error.log
CustomLog /var/log/apache2/laravel.web_access.log combined
</VirtualHost>
sudo a2ensite laravel.web.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
sudo chown -R $USER:www-data /home/user/public_html/blog
sudo chmod -R 775 /home/user/public_html/blog
sudo nano /etc/hosts
127.0.0.1 laravel.web
sudo apt install build-essential curl file git
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
Test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo eval" ($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval $($(brew --prefix)/bin/brew shellenv)" >>~/.profile
sudo apt install libnss3-tools
brew install mkcert
mkcert -install
mkcert laravel.web
sudo mkdir /etc/apache2/ssl
sudo mv laravel.web*.pem /etc/apache2/ssl
Open the laravel.web virtual host configuration file:
sudo nano /etc/apache2/sites-available/laravel.web.conf
<VirtualHost *:80>
ServerName laravel.web
RewriteEngine on
RewriteCond %{SERVER_NAME} =laravel.web
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName laravel.web
DocumentRoot /home/user/public_html/blog/public
<Directory /home/user/public_html/blog/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/laravel.web_error.log
CustomLog /var/log/apache2/laravel.web_access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/laravel.web.pem
SSLCertificateKeyFile /etc/apache2/ssl/laravel.web-key.pem
</VirtualHost>
</IfModule>
sudo a2enmod ssl
sudo systemctl restart apache2
sudo apt install mariadb-server
sudo mysql_secure_installation
Enter current password for root (enter for none): ENTER
Set root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
sudo mysql -u root -p
CREATE DATABASE blog;
CREATE USER 'userblog'@'localhost' IDENTIFIED BY 'passblog';
GRANT ALL PRIVILEGES ON blog.* TO 'userblog'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Open the .env file:
nano ~/public_html/blog/.env
DB_DATABASE=blog
DB_USERNAME=userblog
DB_PASSWORD=passblog
Run migrate to create a user table:
php artisan migrate
composer require laravel/jetstream
composer update
php artisan jetstream:install livewire
>>>>>>>>>>>>>>>
yum update && yum install httpd mariadb mariadb-server *yum os
aptitude update && aptitude install apache2 mariadb-server mariadb-client mariadb.common *debian
wget https://downloads.php.net/~ab/php-7.0.0RC1.tar.gz
tar xzf php-7.0.0RC1.tar.gz -C /opt
cd /opt/php-7.0.0RC1.tar.gz
./buildconf --force
# ./configure \
--prefix=$HOME/php7/usr \
--with-config-file-path=$HOME/php7/usr/etc \
--enable-mbstring \
--enable-zip \
--enable-bcmath \
--enable-pcntl \
--enable-ftp \
--enable-exif \
--enable-calendar \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-curl \
--with-mcrypt \
--with-iconv \
--with-gmp \
--with-pspell \
--with-gd \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-zlib-dir=/usr \
--with-xpm-dir=/usr \
--with-freetype-dir=/usr \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-openssl \
--with-pdo-mysql=/usr \
--with-gettext=/usr \
--with-zlib=/usr \
--with-bz2=/usr \
--with-recode=/usr \
--with-mysqli=/usr/bin/mysql_config \
--with-apxs2
#_configure: error: no acceptable C compiler found in $PATH see 'config.log' for more details
yum install gcc
aptitude install gcc
#_configure: error: xml2-config not found. Please check your libxml2 installation.
gcc
libxml2-devel
pkgconfig
openssl-devel
bzip2-devel
curl-devel
libpng-devel
libpng-devel
libjpeg-devel
libXpm-devel
freetype-devel
gmp-devel
libmcrypt-devel
mariadb-devel
aspell-devel
recode-devel
httpd-devel
yum install gcc libxml2-devel pkgconfig openssl-devel bzip2-devel libpng-devel libpng-devel libjpeg-devel libXpm-devel freetype-devel gmp-devel libmcrypt-devel mariadb-devel aspell-devel recode-devel httpd-devel
make
make install
#_debian
apt-get install make libxml2-dev libcurl4-openssl-dev libjpeg-dev libpng-dev libxpm-dev libmysqlclient-dev libicu-dev libfreetype6-dev libxslt-dev libssl-dev libbz2-dev libgmp-dev libmcrypt-dev libpspell-dev librecode-dev apache2-dev
ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h
make
make install
ls -l /opt/php-7.0.0RC1 | grep php.ini
cp /opt/php-7.0.0RC1/php.ini-development /usr/local/lib
/etc/httpd/conf/httpd.conf *yum
/etc/apache2/apache2.conf *deb
LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
#_ debi omit the LoadModule line & also need to remove & create the follow symbolic links to the indicated Apache modules
cd /etc/apache2
rm mods-enabled/mpm_event.conf
rm mods-enabled/mpm_event.load
ln -s mods-available/mpm_prefork.conf mpm_prefork.conf
ln -s mods-available/mpm_prefork.load mpm_prefork.load
# systemctl restart httpd [On CentOS 7 box]
# systemctl restart apache2 [On Debian 8 box]
---------------------
#yum -y update
#yum install net-snmp net-snmp-utils -y
#systemctl enable snmpd
#systemctl restart snmpd
#sudo yum install firewalld
#sudo systemctl enable firewalld
#mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig
#systemctl restart firewalld
#firewall-cmd --permanent --add-port=161/udp
#firewall-cmd --reload
#firewall-cmd --list-all
######echo -e "# sec.name source community\ncom2sec notConfigUser default @lawangs18\n
####\n# Second, map the security name into a group name:\n
# We do not want annoying "Connection from UDP: " messages in syslog.\n# If the following option is commented out, snmpd will print each incoming\n
# connection, which can be useful for debugging.\ndontLogTCPWrappersConnects yes" > /etc/snmp/snmpd.conf
cukcukcukcukcuk
https://tecadmin.net/install-laravel-framework-on-centos/
Setup Yum Repositories
First of all, you need to add REMI and EPEL rpm repositories in your system. these repositories have updated packages. Use one of the below commands as per your OS version and system architecture.
CentOS/RHEL 7:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-12.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
CentOS/RHEL 6:
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Install Apache, MySQL and PHP
Here is short instruction for the installation of LAMP stack. Its required to run the Laravel framework on your CentOS system. Use this guide for the detailed LAMP setup on CentOS
Install Apache
yum --enablerepo=remi,epel install httpd
yum --enablerepo=remi,epel install mysql-server
service mysqld start
/usr/bin/mysql_secure_installation
yum --enablerepo=remi,epel install php php-zip php-mysql php-mcrypt php-xml php-mbstring
service httpd restart
Install Composer
Composer is required for installing Laravel dependencies. So use below commands to download and use as a command in our system.
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/bin/composer
chmod +x /usr/bin/composer
Install Laravel
To download latest version of Laravel, Use below command to clone master repo of laravel from github.
cd /var/www
git clone https://github.com/laravel/laravel.git
Navigate to the Laravel code directory and use the composer to install all dependencies required for the Laravel framework.
cd /var/www/laravel
composer install
Dependency installation will take some time. After than set proper permissions on files.
chown -R apache.apache /var/www/laravel
chmod -R 755 /var/www/laravel
chmod -R 755 /var/www/laravel/storage
SELinux enabled systems also run the below command to allow write on storage directory.
chcon -R -t httpd_sys_rw_content_t /var/www/laravel/storage
Set Encryption Key
Laravel uses .evn file for environment configuration. Use .evn file for configuring all the environment variables for your application like the database, SMTP, security key, etc.
cp .env.example .env
Now set the 32 bit long random number encryption key, which used by the Illuminate encrypter service.
php artisan key:generate
Application key set successfully.
You can view the .env file to find the Application key is configured.
Create Apache Virtual Host
Now add a Virtual Host in your Apache configuration file to access Laravel framework from web browser. To do it edit Apache configuration file /etc/httpd/conf/httpd.conf and add below code at end of file
vim /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerName laravel.example.com
DocumentRoot /var/www/laravel/public
<Directory /var/www/laravel>
AllowOverride All
</Directory>
</VirtualHost>
Restart Apache service and access the Laravel framework using your favorite web browser and start developing a great web application.
service httpd restart
https://tecadmin.net/install-lamp-apache-mysql-and-php-on-centos-rhel-7/
https://tecadmin.net/install-lamp-apache-mysql-and-php-on-centos-rhel-7/
https://tecadmin.net/install-lamp-apache-mysql-and-php-on-centos-rhel-7/
LAMP stands for Linux, Apache, MySQL and PHP. Its is used for hosting websites written with PHP programming language and using MySQL as backend database server. This article will help you to install Apache 2.4, MySQL 8 and PHP 7.3 on CentOS 7 and RedHat 7 systems. You may also use video tutorial on Youtube for installation instruction’s.
Prerequsitis
The two most popular rpm repositories REMI and EPEL have most of the updated packages. They are also providing the latest packages for LAMP setup. Enable both repositories on your system using the following commands on your CentOS 7 system.
rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
Install Apache Server
Apache or HTTP is the most popular web server used on Linux based systems. Let’s install Apache web server using the following command by enabling EPEL and REMI yum repositories.
yum --enablerepo=epel,remi install httpd
Now start httpd service and enable to start on boot using commands.
systemctl enable httpd.service
systemctl start httpd.service
Install MySQL Server
First, add MySQL yum repository in your system using the following command. You may also visit repo.mysql.com to find repository rpms for other operating systems. The below command will work with CentOS and RedHat 7.
rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
The default MySQL 8 repository is enabled for installation. To change edit repository configuration file (/etc/yum.repos.d/mysql-community.repo) and enable/disable repositories as per requirements.
Then install the MySQL server and other dependency packages.
yum install mysql-server
After installation enable MySQL service and start it.
systemctl enable mysqld.service
systemctl start mysqld.service
The installer generated a temporary password for MySQL root user and copied to log file. You can find this password using the below command.
grep "A temporary password" /var/log/mysqld.log | tail -n1
[Some text hidden] A temporary password is generated for root@localhost: Eif;=YpBy2h#
Apply security on newly installed MySQL server. This will also prompt you to change the temporary password with a new password.
mysql_secure_installation
Enter password for user root: [Enter password here found in log file]
The existing password for the user account root has expired. Please set a new password.
New password: [Enter new password]
Re-enter new password: [Re-enter new password]
Change the password for root? - n
Remove anonymous users? - y
Disallow root login remotely? - y
Remove test database and access to it? - y
Reload privilege tables now? - y
MySQL has been installed on your system. After this install PHP.
Install PHP
Now, install PHP packages with enabling EPEL and REMI repositories using the following command.
yum --enablerepo=epel,remi-php74 install php
yum --enablerepo=remi-php74 list php-*
yum --enablerepo=remi-php74 install php-mysql php-xml php-xmlrpc php-soap php-gd
After installing php and other php modules restart Apache service.
systemctl restart httpd.service
Allow Port in Firewall
Finally open firewall ports for HTTP (80) and HTTPS (443) services using the following command.
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
php -v
httpd -v
mysql -v
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-centos-8
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-centos-8
dnf module list postgresql
Output
postgresql 9.6 client, server [d] PostgreSQL server and client module
postgresql 10 [d] client, server [d] PostgreSQL server and client module
postgresql 12 client, server
To enable the module stream for Postgres version 12, run the following command:
sudo dnf module enable postgresql:12
When prompted, press y and then ENTER to confirm that you want to enable the stream:
Output
====================================================================
Package Architecture Version Repository Size
====================================================================
Enabling module streams:
postgresql 12
Transaction Summary
====================================================================
Is this ok [y/N]: y
After enabling the version 12 module stream, you can install the postgresql-server package to install PostgreSQL 12 and all of its dependencies:
sudo dnf install postgresql-server
When given the prompt, confirm the installation by pressing y then ENTER:
Output
. . .
Install 4 Packages
Total download size: 16 M
Installed size: 62 M
Is this ok [y/N]: y
Now that the software is installed, you will perform some initialization steps to prepare a new database cluster for PostgreSQL.
Creating a New PostgreSQL Database Cluster
You have to create a new PostgreSQL database cluster before you can start creating tables and loading them with data. A database cluster is a collection of databases that are managed by a single server instance. Creating a database cluster consists of creating the directories in which the database data will be placed, generating the shared catalog tables, and creating the template1 and postgres databases.
The template1 database is a template of sorts used to create new databases; everything that is stored in template1, even objects you add yourself, will be placed in new databases when they’re created. The postgres database is a default database designed for use by users, utilities, and third-party applications.
The Postgres package we installed in the previous step comes with a handy script called postgresql-setup which helps with low-level database cluster administration. To create a database cluster, run the script using sudo and with the --initdb option:
sudo postgresql-setup --initdb
You will see the following output:
Output
* Initializing database in '/var/lib/pgsql/data'
* Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log
Now start the PostgreSQL service using systemctl:
sudo systemctl start postgresql
Then, use systemctl once more to enable the service to start up whenever the server boots:
sudo systemctl enable postgresql
This will give the following output
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /usr/lib/systemd/system/postgresql.service.
Using PostgreSQL Roles and Databases
PostgreSQL uses a concept called roles to handle client authentication and authorization. These are in some ways similar to regular Unix-style accounts, but Postgres does not distinguish between users and groups and instead prefers the more flexible term role.
Upon installation, Postgres is set up to use ident authentication, meaning that it associates Postgres roles with a matching Unix/Linux system account. If a role exists within Postgres, a Unix/Linux username with the same name is able to sign in as that role.
The installation procedure created a user account called postgres that is associated with the default postgres role. In order to use PostgreSQL, you can log in to that account.
There are a few ways to use this account to access the PostgreSQL prompt.
Switching Over to the postgres Account
Switch over to the postgres account on your server by typing:
sudo -i -u postgres
You can now access a Postgres prompt immediately by typing:
psql
This will log you into the PostgreSQL prompt, and from here you are free to interact with the database management system right away.
Exit out of the PostgreSQL prompt by typing:
\q
This will bring you back to the postgres account’s Linux command prompt. Now return to your original account with the following:
exit
Accessing a Postgres Prompt Without Switching Accounts
You can also run commands with the postgres account directly using sudo.
For instance, in the previous example, you were instructed to access the Postgres prompt by first switching to the postgres user and then running psql to open the Postgres prompt. As an alternative, you could do this in one step by running the single command psql as the postgres user with sudo, like this:
sudo -u postgres psql
This will log you directly into Postgres without the intermediary bash shell.
Again, you can exit the interactive Postgres session by typing:
\q
In this step, you used the postgres account to reach the psql prompt. But many use cases require more than one Postgres role. Read on to learn how to configure new roles.
Creating a New Role
Currently, you just have the postgres role configured within the database. You can create new roles from the command line with the createrole command. The --interactive flag will prompt you for the name of the new role and also ask whether it should have superuser permissions.
If you are logged in as the postgres account, you can create a new user by typing:
createuser --interactive
sudo -u postgres createuser --interactiveThe script will prompt you with some choices and, based on your responses, execute the necessary Postgres commands to create a user to your specifications. For this tutorial, create a role named sammy and give it superuser privileges by entering y when prompted:
Output
Enter name of role to add: sammy
Shall the new role be a superuser? (y/n) y
man createuser
Creating a New Database
Another assumption that the Postgres authentication system makes by default is that for any role used to log in, that role will have a database with the same name which it can access.
This means that if the user you created in the last section is called sammy, that role will attempt to connect to a database which is also called sammy by default. You can create such a database with the createdb command.
If you are logged in as the postgres account, you would type something like:
createdb sammy
If, instead, you prefer to use sudo for each command without switching from your normal account, you would type:
sudo -u postgres createdb sammy
This flexibility provides multiple paths for creating databases as needed.
Now that you’ve created a new database, you will log in to it with your new role.
Opening a Postgres Prompt with the New Role
To log in with ident-based authentication, you’ll need a Linux user with the same name as your Postgres role and database.
If you don’t have a matching Linux user available, you can create one with the adduser command. You will have to do this from your non-root account with sudo privileges (meaning, not logged in as the postgres user):
sudo adduser sammy
Once this new account is available, you can either switch over and then connect to the database by first typing:
sudo -i -u sammy
psql
sudo -u sammy psql
This command will log you in automatically.
If you want your user to connect to a different database, you can do so by including the -d flag and specifying the database, like this:
psql -d postgres
Once logged in, you can check your current connection information by typing:
\conninfo
This will show the following output:
Output
You are connected to database "sammy" as user "sammy" via socket in "/var/run/postgresql" at port "5432".
Creating and Deleting Tables
Now that you know how to connect to the PostgreSQL database system, you can learn some basic Postgres management tasks.
First, create a table to store some data. As an example, you will make a table that describes some playground equipment.
The basic syntax for this command is as follows:
CREATE TABLE table_name (
column_name1 col_type (field_length) column_constraints,
column_name2 col_type (field_length),
column_name3 col_type (field_length)
);
These commands give the table a name, and then define the columns as well as the column type and the max length of the field data. You can also optionally add table constraints for each column.
For demonstration purposes, create a simple table like this:
CREATE TABLE playground (
equip_id serial PRIMARY KEY,
type varchar (50) NOT NULL,
color varchar (25) NOT NULL,
location varchar(25) check (location in ('north', 'south', 'west', 'east', 'northeast', 'southeast', 'southwest', 'northwest')),
install_date date
);
This command will create a table that inventories playground equipment. It starts with an equipment ID, which is of the serial type. This data type is an auto-incrementing integer. You’ve also given this column the constraint of PRIMARY KEY, which means that the values must be unique and not null.
For two of the columns (equip_id and install_date), the command does not specify a field length. This is because some column types don’t require a set length because the length is implied by the type.
The next two lines create columns for the equipment type and color respectively, each of which cannot be empty. The line after these creates a location column and a constraint that requires the value to be one of eight possible values. The last line creates a date column that records the date on which you installed the equipment.
You can see your new table by typing:
\d
\dt
Adding, Querying, and Deleting Data in a Table
Now that you have a table, you can insert some data into it.
As an example, add a slide and a swing by calling the table you want to add to, naming the columns, and then providing data for each column, like this:
INSERT INTO playground (type, color, location, install_date) VALUES ('slide', 'blue', 'south', '2017-04-28');
INSERT INTO playground (type, color, location, install_date) VALUES ('swing', 'yellow', 'northwest', '2018-08-16');
SELECT * FROM playground;
DELETE FROM playground WHERE type = 'slide';
Adding and Deleting Columns from a Table
After creating a table, you can modify it to add or remove columns. Add a column to show the last maintenance visit for each piece of equipment by typing:
ALTER TABLE playground ADD last_maint date;
If you view your table information again, you will see the new column has been added (but no data has been entered):
SELECT * FROM playground;
Deleting a column is just as simple. If you find that your work crew uses a separate tool to keep track of maintenance history, you can delete the column by typing:
ALTER TABLE playground DROP last_maint;
This deletes the last_maint column and any values found within it, but leaves all the other data intact.
Having now added and deleted columns, you can try updating existing data in the final step.
Updating Data in a Table
So far, you’ve learned how to add records to a table and how to delete them, but this tutorial hasn’t yet covered how to modify existing entries.
You can update the values of an existing entry by querying for the record you want and setting the column to the value you wish to use. You can query for the swing record (this will match every swing in your table) and change its color to red:
UPDATE playground SET color = 'red' WHERE type = 'swing';
You can verify that the operation was successful by querying the data again:
SELECT * FROM playground;
https://www.digitalocean.com/community/tutorials/sqlite-vs-mysql-vs-postgresql-a-comparison-of-relational-database-management-systems
https://www.digitalocean.com/community/tutorials/introduction-to-queries-postgresql
https://www.tecmint.com/install-pgadmin4-in-centos-7/
https://www.tecmint.com/install-pgadmin4-in-centos-7/
yum -y install pgadmin4
# mv /etc/httpd/conf.d/pgadmin4.conf.sample /etc/httpd/conf.d/pgadmin4.conf
# vi /etc/httpd/conf.d/pgadmin4.conf
<VirtualHost *:80>
LoadModule wsgi_module modules/mod_wsgi.so
WSGIDaemonProcess pgadmin processes=1 threads=25
WSGIScriptAlias /pgadmin4 /usr/lib/python2.7/site-packages/pgadmin4-web/pgAdmin4.wsgi
<Directory /usr/lib/python2.7/site-packages/pgadmin4-web/>
WSGIProcessGroup pgadmin
WSGIApplicationGroup %{GLOBAL}
<IfModule mod_authz_core.c>
# Apache 2.4
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
</VirtualHost>
Next we will create logs and lib directories for pgAdmin4 and set their ownership:
# mkdir -p /var/lib/pgadmin4/
# mkdir -p /var/log/pgadmin4/
# chown -R apache:apache /var/lib/pgadmin4
# chown -R apache:apache /var/log/pgadmin4
# vi /usr/lib/python2.7/site-packages/pgadmin4-web/config_distro.py
And add the following lines:
LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin4/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin4/sessions'
STORAGE_DIR = '/var/lib/pgadmin4/storage'
Finally we will create our user account, with which we will authenticate in the web interface. To do this, run:
# python /usr/lib/python2.7/site-packages/pgadmin4-web/setup.py
Now you can access your server’s http://ip-address/pgadmin4 or http://localhost/pgadmin4 to reach the pgAdmin4 interface:
If you receive 403 error while accessing PgAdmin4 interface, you need to set the correct SELinux context on the following files.
# chcon -t httpd_sys_rw_content_t /var/log/pgadmin4 -R
# chcon -t httpd_sys_rw_content_t /var/lib/pgadmin4 -R
At your first login, you will need to add a new server to manage. Click on “Add New Server”. You will need to configure the PostgresQL connection. In the first tab “General”, enter the following settings:
Name – give name of the server you are configuring.
Comment – leave a comment to give description of the instance.
catat repo !!!
Repositories configuration:
On Fedora, standards repositories are enough, on Enterprise Linux (RHEL, CentOS) the Extra Packages for Enterprise Linux (EPEL) repository must be configured, and on RHEL the optional channel must be enabled.
Fedora 31
dnf install https://rpms.remirepo.net/fedora/remi-release-31.rpm
Fedora 30
dnf install https://rpms.remirepo.net/fedora/remi-release-30.rpm
RHEL version 8.1
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
RHEL version 7.7
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
subscription-manager repos --enable=rhel-7-server-optional-rpms
CentOS version 8.0
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
CentOS version 7.7
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
php module usage
With Fedora modular and RHEL / CentOS 8, you can simply use the remi-7.4 stream of the php module
dnf module reset php
dnf module install php:remi-7.4
remi-php74 repository activation
Needed packages are in the remi-safe (enabled by default) and remi-php74 repositories,
the latest is not enabled by default (administrator choice according to the desired PHP version).
RHEL or CentOS 7
yum install yum-utils
yum-config-manager --enable remi-php74
Fedora
dnf config-manager --set-enabled remi-php74
PHP upgrade
By choice, the packages have the same name than in the distribution, so a simple update is enough:
yum update
------------------------
https://ostechnix.com/install-apache-mariadb-php-lamp-stack-ubuntu-16-04/
Ansibel
https://www.tecmint.com/screen-command-examples-to-manage-linux-terminals/
sudo apt install apache2
sudo systemctl status apache2
sudo ufw app list
Apache
Apache Full
Apache Secure
OpenSSH
As you can see, Apache and OpenSSH applications have installed UFW profiles.
If you look into the “Apache Full” profile, you will see that it enables traffic to the ports 80 and 443:
sudo ufw app info "Apache Full"
Profile: Apache Full
Title: Web Server (HTTP,HTTPS)
Description: Apache v2 is the next generation of the omnipresent Apache web
server.
Ports:
80,443/tcp
sudo ufw allow in "Apache Full"
sudo apt install mariadb-server mariadb-client
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://sgp1.mirrors.digitalocean.com/mariadb/repo/10.3/ubuntu bionic main'
sudo apt update
sudo apt install mariadb-server
sudo systemctl status mysql
mysql_secure_installation
Enter current password for root (enter for none):
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Enter current password for root (enter for none):
You can't login set the password. You will see an error like below.
To fix this problem, log in as MySQL database administrator using command:
sudo mysql -u root
use mysql;
update user set plugin='' where User='root';
flush privileges;
\q
mysql_secure_installation
Enter current password for root (enter for none): # Press ENTER
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] # Press ENTER...
New password: # Enter password
Re-enter new password: # Re-enter password...
Password updated successfully!
PHP...
sudo apt install php libapache2-mod-php php-mysql
sudo vi /var/www/html/info.php
sudo systemctl restart apache2
sudo apt-cache search php- | less
sudo apt-cache show php-gd
sudo apt install php-gd
To install all modules (not necessary though), run:
sudo apt-get install php*
https://ostechnix.com/install-apache-mariadb-php-lamp-stack-on-arch-linux-2016/
https://ostechnix.com/install-nginx-mariadb-php-lemp-stack-on-arch-linux-2016/
https://www.tecmint.com/install-apache-mariadb-php-phpmyadmin-in-ubuntu-14-10/
sudo hostnamectl set-hostname yourFQDNname
sudo hostnamectl
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install apache2
http://your_server_IP
sudo apt-get install php5 php5-mysql php5-mcrypt php5-gd libapache2-mod-php5
sudo apt-cache search php5
sudo apt-cache show php5-module_name
sudo apt-get install mariadb-client mariadb-server
sudo mysql_secure_installation
mysql -u root -p
sudo apt-get install phpmyadmin
sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin
sudo service apache2 restart
http://your_server_IP/phpmyadmin
sudo nano /var/www/html/info.php
In order to be sure that Apache and MariaDB services are started after every system reboot, install sysv-rc-conf package that manages Ubuntu init scripts, then enable both services system-wide by running the following commands.
$ sudo apt-get install sysv-rc-conf
$ sudo sysv-rc-conf apache2 on
$ sudo sysv-rc-conf mysql on
https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-on-ubuntu-18-04-lamp/
https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-on-ubuntu-18-04-lamp/
In this tutorial, I will use the hostname server1.example.com with the IP address 192.168.1.100.
sudo -s
apt-get -y install mysql-server mysql-client
mysql_secure_installation
apt-get -y install mariadb-server mariadb-client
mysql_secure_installation
Enter current password for root (enter for none): <-- press enter
Set root password? [Y/n] <-- y
New password: <-- Enter the new MariaDB root password here
Re-enter new password: <-- Repeat the password
Remove anonymous users? [Y/n] <-- y
Disallow root login remotely? [Y/n] <-- y
Reload privilege tables now? [Y/n] <-- y
mysql -u root -p
apt-get -y install apache2
apt-get -y install php7.2 libapache2-mod-php7.2
systemctl restart apache2
nano /var/www/html/info.php
<?php
phpinfo();
chown www-data:www-data /var/www/html/info.php
As you see, PHP 7.2 is working, and it's working through the Apache 2.0 Handler, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP. MySQL is not listed there which means we don't have MySQL / MariaDB support in PHP yet.
Get MySQL / MariaDB support in PHP
To get MySQL support in PHP, we can install the php7.2-mysql package. It's a good idea to install some other PHP modules as well as you might need them for your applications. You can search for available PHP modules like this:
apt-cache search php7.2
apt-cache search php-
as not all PHP packages have the version number 7.2 in their name.
apt-get -y install php7.2-mysql php7.2-curl php7.2-gd php7.2-intl php-pear php-imagick php7.2-imap php-memcache php7.2-pspell php7.2-recode php7.2-sqlite3 php7.2-tidy php7.2-xmlrpc php7.2-xsl php7.2-mbstring php-gettext
systemctl restart apache2
Install the Opcache + APCu PHP cache to speed up PHP
PHP 7 ships with a built-in opcode cacher for caching and optimizing PHP intermediate code, it has the name 'opcache' and is available in the package php7.0-opcache. It is strongly recommended to have an Opcache installed to speed up your PHP page. Besides opcache, I will install APCu which is a compatibility wrapper for opcache to provide the functions of the APC cache, an often used caching system in PHP 5.x versions and many CMS systems still use it.
apt-get -y install php7.2-opcache php-apcu
Don't worry if it shows that Opcache is already installed.
systemctl restart apache2
Enable the SSL website in apache
SSL/ TLS is a security layer to encrypt the connection between the web browser and your server. Most web browsers start to show sites as insecure today when the connection between the server and the web browser is not encrypted with SSL. In this chapter, I will show you how to secure your website with SSL.
Execute the following commands on your server to enable SSL (https://) support. Run:
a2enmod ssl
a2ensite default-ssl
which enables the SSL module and adds a symlink in the /etc/apache2/sites-enabled folder to the file /etc/apache2/sites-available/default-ssl.conf to include it into the active apache configuration. Then restart apache to enable the new configuration:
systemctl restart apache2
apt-get -y install python3-certbot-apache
nano /etc/apache2/sites-available/000-default.conf
ServerName example.com
certbot --apache -d example.com
Accept the terms and conditions of the Let's Encrypt SSL authority.
Then choose if you want to redirect non-SSL requests to https:// automatically. I'll select yes here to avoid duplicate content problems when the website is available as http:// and https:// version.
The SSL certificate has been issued successfully.
When you access the website now with a browser, you will get redirected automatically to SSL and the green padlock in front of the URL bar in the browser shows that we are using a trusted SSL certificate now.
Let's encrypt Auto Renewal
Let's Encrypt SSL certificates are valid for a short period of 80 days only. Therefore a cronjob to auto-renew the SSL certificates is necessary that runs the certbot --renew command.
This cronjob get setup automatically when you install certbot, the cron file is /etc/cron.d/certbot. So there is nothing more to do here. If you like to know what the cronjob looks like, run the command:
/etc/cron.d/certbot
root@server1:~# cat /etc/cron.d/certbot
# /etc/cron.d/certbot: crontab entries for the certbot package
#
# Upstream recommends attempting renewal twice a day
#
# Eventually, this will be an opportunity to validate certificates
# haven't been revoked, etc. Renewal will only occur if expiration
# is within 30 days.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew
apt-get -y install phpmyadmin
Web server to configure automatically: <-- Select the option: apache2
Configure database for phpmyadmin with dbconfig-common? <-- Yes
MySQL application password for phpmyadmin: <-- Press enter, apt will create a random password automatically.
mysql -u root
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'howtoforge';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
Afterward, you can access phpMyAdmin under http://192.168.1.100/phpmyadmin/:
Virtual machine image download of this tutorial
This tutorial is available as ready to use virtual machine image in ovf/ova format that is compatible with VMWare and Virtualbox. The virtual machine image uses the following login details:
SSH / Shell Login
Username: administrator
Password: howtoforge
This user has sudo rights.
MySQL Login
Username: root
Password: howtoforge
The IP of the VM is 192.168.1.100, it can be changed in the file /etc/network/interfaces. Please change all the above passwords to secure the virtual machine.
Apache: http://httpd.apache.org/
PHP: http://www.php.net/
MySQL: http://www.mysql.com/
MariaDB: https://mariadb.com/
Ubuntu: http://www.ubuntu.com/
phpMyAdmin: http://www.phpmyadmin.net/
---------------------
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-20-04-id
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-20-04-id
Menginstal Apache dan Memperbarui Firewall
sudo apt update
sudo apt install apache2
Setelah instalasi selesai, Anda akan perlu menyesuaikan pengaturan firewall Anda untuk memperbolehkan lalu lintas HTTP. UFW memiliki berbagai profil aplikasi berbeda yang dapat Anda manfaatkan untuk menyelesaikannya. Untuk mendapatkan daftar semua profil aplikasi UFW yang tersedia, Anda dapat menjalankan:
sudo ufw app list
Berikut adalah makna dari setiap profil ini:
Apache: Profil ini hanya membuka porta 80 (lalu lintas web normal dan tidak terenkripsi).
Apache Full: Profil ini membuka baik porta 80 (lalu lintas web normal dan tidak terenkripsi) dan
porta 443 (lalu lintas terenkripsi TLS/SSL).
Apache Secure: Profile ini hanya membuka porta 443 (lalu lintas terenkripsi TLS/SSL).
Untuk saat ini, sebaiknya izinkan hanya koneksi pada porta 80, karena ini adalah instalasi Apache yang baru dan Anda belum memiliki sertifikat TLS/SSL yang dikonfigurasi untuk mengizinkan lalu lintas HTTPS di server Anda.
sudo ufw allow in "Apache"
sudo ufw status
http://your_server_ip
Cara Menemukan Alamat IP Publik Server Anda
Jika Anda tidak mengetahui alamat IP publik server Ada, ada sejumlah cara untuk mengetahuinya. Biasanya, ini adalah alamat yang digunakan untuk terhubung ke server Anda melalui SSH.
Ada beberapa cara untuk melakukannya dari baris perintah. Pertama, Anda dapat menggunakan alat iproute2 untuk mengetahui alamat IP dengan mengetik ini:
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
Ini akan menampilkan dua atau tiga baris tanggapan. Semua adalah alamat yang benar, tetapi komputer Anda mungkin hanya dapat menggunakan salah satunya, jadi silakan mencoba masing-masing alamat itu.
Cara alternatifnya adalah menggunakan utilitas curl untuk menghubungi pihak luar supaya memberitahukan bagaimana pihak luar melihat server Anda. Hal ini dilakukan dengan menanyakan alamat IP Anda kepada server tertentu:
curl http://icanhazip.com
Terlepas dari cara yang digunakan untuk mengetahui alamat IP Anda, ketik alamat IP pada bilah alamat di peramban web Anda untuk melihat laman Apache asali.
sudo apt install mysql-server
sudo mysql_secure_installation
Anda akan ditanya apakah Anda ingin mengonfigurasi VALIDATE PASSWORD PLUGIN.
Catatan: Mengaktifkan fitur ini merupakan keputusan yang Anda pertimbangkan sendiri. Jika diaktifkan, kata sandi yang tidak cocok dengan kriteria yang ditentukan akan ditolak oleh MySQL dengan suatu kesalahan. Akan lebih aman jika Anda tetap menonaktifkan validasi, tetapi Anda harus selalu menggunakan kata sandi yang kuat dan unik untuk kredensial basis data.
Jawab Y untuk ya, atau jawaban lain untuk melanjutkan tanpa mengaktifkan.
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No:
Jika Anda menjawab “ya”, Anda akan diminta untuk memilih tingkat validasi kata sandi. Harap ingat bahwa jika Anda memasukkan 2 sebagai tingkat terkuat, Anda akan menjumpai kesalahan saat berusaha menentukan kata sandi yang tidak mengandung angka, huruf kapital dan huruf kecil, serta karakter khusus, atau kata sandi yang berdasarkan pada kata-kata kamus umum.
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
Terlepas dari pilihan pengaturan VALIDATE PASSWORD PLUGIN, server Anda akan meminta Anda untuk memilih dan mengonfirmasi kata sandi untuk pengguna root MySQL. Ini tidak sama dengan root sistem. Pengguna root basis data adalah pengguna administratif dengan privilese penuh terhadap sistem basis data. Meskipun metode autentikasi asali untuk pengguna root MySQL mengecualikan penggunaan kata sandi, sekalipun kata kata sandi sudah dibuat, Anda tetap harus menentukan kata sandi yang kuat di sini sebagai langkah keamanan tambahan. Kita akan membahas hal ini sebentar lagi.
Jika Anda mengaktifkan validasi kata sandi, Anda akan diperlihatkan kekuatan kata sandi untuk kata sandi root yang baru saja Anda masukkan dan server Anda akan bertanya apakah Anda ingin melanjutkan dengan kata sandi itu. Jika Anda puas dengan kata sandi ini, tekan Y untuk “ya” di prompt:
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
Untuk pertanyaan lainnya, tekan Y dan tombol ENTER pada setiap pertanyaan. Ini akan menghapus sebagian pengguna anonim dan basis data percobaan, menonaktifkan log masuk root dari jarak jauh, dan memuat aturan-aturan baru ini sehingga MySQL segera menerapkan perubahan yang Anda buat.
Setelah Anda selesai, lakukan percobaan apakah Anda dapat melakukan log masuk ke konsol MySQL dengan mengetik:
sudo mysql
exit
Anda juga akan memerlukan libapache2-mod-php untuk memungkinkan Apache menangani berkas PHP. Paket PHP inti akan secara otomatis terinstal sebagai dependensi.
sudo apt install php libapache2-mod-php php-mysql
php -v
Menciptakan Hos Virtual untuk Situs Web Anda
Ketika menggunakan server web Apache, Anda bisa menciptakan hos virtual (serupa dengan blok server di Nginx) untuk merangkum detail konfigurasi dan menjadi hos dari lebih dari satu domain dari server tunggal. Dalam panduan ini, kita akan menyiapkan domain bernama your_domain, tetapi Anda harus menggantinya dengan nama domain Anda sendiri.
Catatan: Jika Anda menggunakan DigitalOcean sebagai penyedia hos DNS, lihat dokumen produk kami untuk instruksi mendetail tentang cara mempersiapkan nama domain baru dan mengarahkannya ke server Anda.
Apache pada Ubuntu 20.04 memiliki satu blok server yang aktif secara asali, yang dikonfigurasi untuk menyajikan dokumen-dokumen dari direktori /var/www/html. Meskipun ini berfungsi baik untuk situs tunggal, ini bisa menjadi sulit dijalankan jika Anda menjadi hos dari beberapa situs. Alih-alih memodifikasi /var/www/html, kita akan menciptakan suatu struktur direktori dalam /var/www untuk situs your_domain, dengan membiarkan /var/www/html sebagai direktori asali yang akan ditampilkan jika permintaan klien tidak cocok dengan situs lain.
Buat direktori untuk your_domain sebagai berikut:
sudo mkdir /var/www/your_domain
Selanjutnya, tentukan kepemilikan direktori dengan variabel lingkungan $USER, yang akan merujuk pada pengguna sistem Anda saat ini:
sudo chown -R $USER:$USER /var/www/your_domain
Kemudian, buka berkas konfigurasi baru dalam direktori sites-available Apache dengan menggunakan editor baris perintah yang Anda sukai. Di sini, kita akan menggunakan nano:
sudo nano /etc/apache2/sites-available/your_domain.conf
Ini akan menciptakan berkas kosong yang baru. Tempelkan konfigurasi dasar berikut:
/etc/apache2/sites-available/your_domain.conf
<VirtualHost *:80>
ServerName your_domain
ServerAlias www.your_domain
ServerAdmin webmaster@localhost
DocumentRoot /var/www/your_domain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Dengan konfigurasi VirtualHost ini, kita menyuruh Apache untuk menyajikan your_domain menggunakan /var/www/your_domain sebagai direktori root web. Jika Anda ingin menguji Apache tanpa nama domain, Anda dapat menghapus atau memberikan komentar pada opsi ServerName dan ServerAlias dengan menambahkan karakter # di depan masing-masing baris opsi.
Anda dapat menggunakan a2ensite untuk mengaktifkan hos virtual yang baru:
sudo a2ensite your_domain
Anda mungkin ingin menonaktifkan situs web asali yang terinstal dengan Apache. Ini diperlukan jika Anda tidak menggunakan nama domain khusus, karena dalam hal ini, konfigurasi asali Apache akan menimpa hos virtual Anda. Untuk menonaktifkan situs web asali Apache, ketikkan:
sudo a2dissite 000-default
Untuk memastikan berkas konfigurasi Anda tidak berisi kesalahan sintaks, jalankan:
sudo apache2ctl configtest
Terakhir, muat ulang Apache agar perubahan ini diterapkan:
sudo systemctl reload apache2
Situs web Anda yang baru kini sudah aktif, tetapi root web /var/www/your_domain masih kosong.
Buat berkas index.html di dalam lokasi itu sehingga kita dapat menguji apakah hos virtual bekerja sesuai harapan:
nano /var/www/your_domain/index.html
Sertakan konten berikut di dalam berkas ini:
<html>
<head>
<title>your_domain website</title>
</head>
<body>
<h1>Hello World!</h1>
<p>This is the landing page of <strong>your_domain</strong>.</p>
</body>
</html>
Anda dapat meninggalkan berkas ini di lokasinya saat ini sebagai laman landas sementara untuk aplikasi Anda sampai Anda menyiapkan berkas index.php untuk menggantinya. Setelah Anda melakukannya, ingat untuk menghapus atau mengganti nama berkas index.html dari root dokumen Anda, karena berkas ini lebih diutamakan daripada berkas index.php secara asali.
Catatan Tentang DirectoryIndex pada Apache
Dengan pengaturan DirectoryIndex asali pada Apache, berkas yang diberi nama index.html akan selalu lebih diutamakan daripada berkas index.php. Ini berguna untuk menyiapkan laman pemeliharaan di aplikasi PHP, dengan menciptakan berkas index.html sementara yang mengandung suatu pesan informatif bagi pengunjung. Karena lebih diutamakan daripada laman index.php, laman ini akan menjadi laman landas untuk aplikasi. Setelah pemeliharaan selesai, index.html diubah namanya atau dihapus dari root dokumen, sehingga mengembalikan laman aplikasi reguler.
sudo nano /etc/apache2/mods-enabled/dir.conf
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
sudo systemctl reload apache2
sudo rm /var/www/your_domain/info.php
Menguji Koneksi Basis Data dari PHP (Opsional)
Saat menyusun tulisan ini, pustaka PHP MySQL asli mysqlndtidak mendukung caching_sha2_authentication, metode autentikasi asali untuk MySQL 8. Kita akan perlu menciptakan pengguna baru dengan metode autentikasi mysql_native_password agar dapat terhubung ke basis data MySQL dari PHP.
Kita akan menciptakan basis data bernama example_database dan pengguna bernama example_user, tetapi Anda dapat mengganti nama-nama ini dengan nilai yang berbeda.
Pertama, hubungkan ke konsol MySQL menggunakan akun root:
sudo mysql
CREATE DATABASE example_database;
CREATE USER 'example_user'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
GRANT ALL ON example_database.* TO 'example_user'@'%';
exit
mysql -u example_user -p
CREATE TABLE example_database.todo_list (
item_id INT AUTO_INCREMENT,
content VARCHAR(255),
PRIMARY KEY(item_id)
);
INSERT INTO example_database.todo_list (content) VALUES ("My first important item");
SELECT * FROM example_database.todo_list;
nano /var/www/your_domain/todo_list.php
<?php
$user = "example_user";
$password = "password";
$database = "example_database";
$table = "todo_list";
try {
$db = new PDO("mysql:host=localhost;dbname=$database", $user, $password);
echo "<h2>TODO</h2><ol>";
foreach($db->query("SELECT content FROM $table") as $row) {
echo "<li>" . $row['content'] . "</li>";
}
echo "</ol>";
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
http://your_domain_or_IP/todo_list.php
https://httpd.apache.org/docs/current/vhosts/
https://www.howtoforge.com/tutorial/ubuntu-lts-minimal-server/
Preliminary Note
In this tutorial, I use the hostname server1.example.com with the IP address 192.168.0.100 and the gateway 192.168.0.1 These settings might differ for you, so you have to replace them where appropriate.
........
https://www.niagahoster.co.id/blog/cara-install-lemp-di-ubuntu/
LEMP adalah singkatan dari Linux, Nginx, MariaDB, dan PHP. Fungsi LEMP adalah untuk membuat server website dan membantu agar aplikasi menjadi dinamis. Fungsinya sama seperti dengan XAMPP yang ada di sistem operasi Windows.
Langkah 1 : Menginstall Nginx dan Memperbarui Firewall
Nginx adalah web server HTTP dan proxy dengan kode open source yang bisa juga berfungsi sebagai proxy IMAP/POP3. Kenapa menggunakan Nginx? Karena Nginx menawarkan penggunaan memori yang kecil dengan konkurensi yang tinggi. Sehingga akan mempercepat Anda dalam menyelesaikan semua proses di server. Berikut ini adalah langkah-langkah cara update CentOS 7 dan install Nginx.
sudo apt-get update && apt-get upgrade
sudo apt-get install nginx
Terkadang, dalam beberapa kasus halaman default Nginx tidak muncul. Ini dapat disebabkan oleh pengaturan firewall yang diterapkan pada server. Untuk menanggulangi hal ini, Anda perlu install UFW guna mengatur Nginx agar menerima permintaan web pada port 80 dan port 443 di firewall. Oleh karena itu, langkah selanjutnya kami akan memberikan panduan instalasi UFW.
Install UFW
Uncomplicated Firewall (UFW) merupakan kumpulan perintah yang digunakan untuk konfigurasi iptables di Ubuntu. UFW sudah tersedia di Ubuntu dan secara default sudah terinstall di dalamnya.
Untuk melakukan instalasi UFW, gunakan perintah berikut.
sudo apt-get install ufw
Setelah itu, berikan izin pada traffic HTTP dan HTTPS agar bisa melewati firewall
sudo ufw allow http
sudo ufw allow https
ufw –help
sudo systemctl restart nginx
sudo systemctl status nginx
sudo apt install mariadb-server
sudo mysql_secure_installation
Keempat, Anda akan diminta untuk membatasi akses root dari localhost saja. Ini untuk memperkecil kemungkinan orang lain menebak kata sandi root Anda. Klik Y untuk membatasi root di localhost.
sudo mariadb
GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'admin1234' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;
mariadb -u admin -p
sudo apt install php-fpm php-mysql
https://www.niagahoster.co.id/blog/cara-install-wordpress-menggunakan-nginx-di-centos-7/
https://www.niagahoster.co.id/blog/cara-install-wordpress-menggunakan-nginx-di-ubuntu/
https://www.niagahoster.co.id/blog/cara-install-lemp-di-debian/
https://langittutorial.blogspot.com/2017/12/cara-install-dan-menggunakan-respin-remastering-tool-ubuntu-16.html
https://storage.googleapis.com/kubernetes-release/release/stable.txt
https://musaamin.web.id/cara-install-dan-setting-xampp-for-linux/
https://musaamin.web.id/cara-install-dan-setting-xampp-for-linux/
https://langittutorial.blogspot.com/2017/12/cara-install-dan-menggunakan-respin-remastering-tool-ubuntu-16.html
https://musaamin.web.id/cara-install-nextcloud-client-ubuntu/
https://musaamin.web.id/cara-install-nextcloud-client-ubuntu/
https://musaamin.web.id/cara-install-mysql55-ubuntu1804/
groupadd mysql
useradd -g mysql mysql
tar xzvf mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.5.62-linux-glibc2.12-x86_64 /usr/local/mysql
cd /usr/local/mysql
chown -R mysql:mysql *
Install paket dependensi libaio1.
apt install libaio1
scripts/mysql_install_db --user=mysql
cp support-files/my-medium.cnf /etc/my.cnf
Copy file konfigurasi service mysql-server.
bin/mysqld_safe --user=mysql &
cp support-files/mysql.server /etc/init.d/mysql.server
bin/mysqladmin -u root password 'rahasia'
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
reboot
update-rc.d -f mysql.server defaults
/etc/init.d/mysql.server start
/etc/init.d/mysql.server status
mysql -u root -p
https://www.youtube.com/c/musaamin/videos
https://www.youtube.com/c/musaamin/videos
install lampp
sudo /opt/lampp/lampp start
Starting XAMPP for Linux 7.2.18-1...
XAMPP: Starting Apache...fail.
XAMPP: Another web server is already running.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.
sudo systemctl stop apache2
sudo systemctl disable apache2
sudo systemctl stop mysql
sudo systemctl disable mysql
File konfigurasi XAMPP:
Apache configuration file: /opt/lampp/etc/httpd.conf, /opt/lampp/etc/extra/httpd-xampp.conf
PHP configuration file: /opt/lampp/etc/php.ini
MySQL configuration file: /opt/lampp/etc/my.cnf
ProFTPD configuration file: /opt/lampp/etc/proftpd.conf
Direktori penting XAMPP:
Direktori Document Root: /opt/lampp/htdocs
Direktori database: /opt/lampp/var/mysql
Direktori konfigurasi: /opt/lampp/etc
cd /opt/lampp/htdocs
sudo mkdir webku.com
sudo chown $USER.$USER webku.com
sudo gedit /opt/lampp/etc/httpd.conf
# Virtual hosts
#Include etc/extra/httpd-vhosts.conf
TO.....
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
Selanjutnya buka file konfigurasi virtual hosts httpd-vhosts.conf .....
sudo gedit /opt/lampp/etc/extra/httpd-vhosts.conf
Before ...
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/opt/lampp/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/opt/lampp/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
AFTER ...
<VirtualHost *:80>
ServerName localhost
DocumentRoot /opt/lampp/htdocs
ErrorLog "logs/localhost.error.log"
CustomLog "logs/localhost.access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerName webku.com
DocumentRoot /opt/lampp/htdocs/webku.com
ErrorLog "logs/webku.com.error.log"
CustomLog "logs/webku.com.access.log" common
</VirtualHost>
sudo gedit /etc/hosts
127.0.0.1 webku.com
sudo /opt/lampp/lampp reloadapache
https://musaamin.web.id/cara-install-dan-setting-xampp-for-linux/
https://musaamin.web.id/cara-install-dan-setting-xampp-for-linux/
https://musaamin.web.id/cara-install-sistem-informasi-desa-opensid-di-ubuntu-18-04/
https://musaamin.web.id/cara-install-sistem-informasi-desa-opensid-di-ubuntu-18-04/
sudo apt install apache2 -y
cd /etc/apache2/sites-available
sudo nano desaindah.id.conf
<VirtualHost *:80>
ServerName www.desaindah.id
ServerAlias desaindah.id
DocumentRoot /var/www/desaindah.id
<Directory /var/www/desaindah.id>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/desaindah.id.error.log
CustomLog /var/log/apache2/desaindah.id.access.log combined
</VirtualHost>
sudo a2ensite desaindah.id.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
sudo systemctl status apache2
cd /var/www
sudo mkdir desaindah.id
sudo nano desaindah.id/test.html
sudo rm /var/www/desaindah.id/test.html
sudo apt install php php-common php-mysql php-gd php-cli libapache2-mod-php -y
sudo apt install mariadb-server mariadb-client -y
sudo mysql_secure_installation
Enter current password for root (enter for none): ENTER
Set root password? [Y/n] y
New password: PASSWORD_ROOT
Re-enter new password: MASUKKAN_ULANG_PASSWORD_ROOT
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
sudo mysql -u root -p
create database opensid;
create user 'user_opensid'@'localhost' identified by 'pass_opensid';
grant all privileges on opensid.* to 'user_opensid'@'localhost';
flush privileges;
wget https://github.com/OpenSID/OpenSID/archive/v19.07.zip -O OpenSID-v19.07.zip
unzip OpenSID*.zip
sudo cp -Rv OpenSID-19.07/* /var/www/desaindah.id/
cd /var/www/desaindah.id
sudo cp -Rv desa-contoh desa
sudo chown -R $USER:www-data ../desaindah.id
sudo chmod -R 775 ../desaindah.id
mysql -u user_opensid -p opensid < desaindah.id/contoh_data_awal_20190701.sql
nano desa/config/database.php
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'user_opensid';
$db['default']['password'] = 'pass_opensid';
$db['default']['database'] = 'opensid';
Akses laman admin OpenSID http://desaindah.id/index.php/siteman, username = admin, password = sid304.
https://github.com/OpenSID/OpenSID
https://github.com/OpenSID/OpenSID/wiki
https://demo.opensid.or.id/
https://www.facebook.com/groups/opensid
https://www.howtoforge.com/tutorial/ubuntu-lts-minimal-server/
https://www.howtoforge.com/tutorial/ubuntu-lts-minimal-server/
https://www.howtoforge.com/ubuntu_lamp_for_newbies
sudo apt-get install apache2
http://localhost/
sudo apt-get install php5 libapache2-mod-php5
sudo /etc/init.d/apache2 restart
sudo gedit /var/www/testphp.php
<?php phpinfo(); ?>
sudo apt-get install mysql-server
gksudo gedit /etc/mysql/my.cnf
bind-address = 127.0.0.1
mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
gksudo gedit /etc/php5/apache2/php.ini
;extension=mysql.so
extension=mysql.so
sudo /etc/init.d/apache2 restart
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mariadb-php-lamp-stack-debian9
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mariadb-php-lamp-stack-debian9
sudo apt update
sudo apt install apache2
sudo ufw app list
sudo ufw app info "WWW Full"
sudo ufw allow in "WWW Full"
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
sudo apt install curl
curl http://icanhazip.com
sudo apt install mariadb-server
sudo mysql_secure_installation
sudo mariadb
GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
mariadb -u admin -p
sudo apt install php libapache2-mod-php php-mysql
sudo nano /etc/apache2/mods-enabled/dir.conf
/etc/apache2/mods-enabled/dir.conf
<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>
sudo systemctl restart apache2
apt search php- | less
apt show package_name
apt show php-cli
sudo apt install php-cli
sudo apt install package1 package2 ...
sudo nano /var/www/html/info.php
http://your_server_ip/info.php
sudo rm /var/www/html/info.php
https://medium.com/@dataq/instalasi-linux-apache-mysql-php-lamp-stack-pada-ubuntu-16-04-b243d3048b35
https://medium.com/@dataq/instalasi-php-apache-module-pada-ubuntu-16-04-481d288a909d
https://medium.com/@dataq/instalasi-apache-dan-php-fpm-pada-ubuntu-16-04-cd8900b5d529
1. Instalasi Apache
$ sudo apt update
$ sudo apt install apache2
alamat IP atau alamat domain server anda tersebut, misalkan http://mydomain.com/ atau http://104.16.123.127/.
Konfig firewall
sudo ufw app list
sudo ufw app info "Apache Full"
Untuk mengijinkan incoming packet dengan port dan protocol dalam application profile Apache Full, jalankan perintah:
sudo ufw allow in "Apache Full"
Jangan lupa untuk mengijinkan pula incoming packet dengan application profile OpenSSH dengan perintah:
sudo ufw allow in "OpenSSH"
$ sudo ufw status
$ sudo ufw enable
3. Menyembunyikan Informasi Terkait Apache
Menyembunyikan informasi terkait web server Apache, seperti versi Apache dan sistem operasi, sebenarnya bersifat optional karena informasi tersebut bukanlah sebuah vulnerability. Namun menyembunyikan informasi ini adalah langkah pencegahan untuk mempersulit penyerang dalam menemukan vulnerability yang ada pada aplikasi yang terpasang pada server.
Ada dua konfigurasi Apache yang perlu kita ubah, yaitu ServerSignature dan ServerTokens. Bukalah file /etc/apache2/conf-available/security.conf kemudian ubahlah konfigurasiServerTokensmenjadi:
ServerTokens Prod
dan konfigurasi ServerSignature menjadi:
ServerSignature Off
Simpan perubahan tersebut lalu restart service Apache dengan perintah:
$ sudo systemctl restart apache2.service
https://medium.com/tag/web-server
https://medium.com/tag/web-server
https://blog.panoply.io/a-comparative-vmariadb-vs-mysql
sudo apt-get update
sudo apt-get install mysql-server
mysql_secure_installation
mysql -u root -p
https://akaabachi.medium.com/respect-of-the-kill-how-to-properly-terminate-your-linux-processes-99f6025f2e53
$ sudo apt-get update
$ sudo apt-get install mariadb-server
$ sudo mysql_secure_installation
Secara default user root menggunakan unix_socket untuk autentikasi, sehingga kita dapat login menggunakan user root tanpa password. Anda cukup menekan enter ketika anda diminta memasukkan current password for root. Anda juga tidak perlu merubah password root ketika menemui opsi Set root password?. Jawablah tiap pertanyaan pada yang muncul sesuai dengan tingkat keamanan yang anda inginkan. Berikut adalah contoh konfigurasi yang saya rekomendasikan:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.Enter current password for root (enter for none):
OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.Set root password? [Y/n] n
... skipping.By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.Remove anonymous users? [Y/n] Y
... Success!Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] Y
... Success!By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.Remove test database and access to it? [Y/n] Y
- Dropping te
echo "--> CentOS System, Pasang Apache, PHP, MariaDB <--"
echo "Nama Pelanggan : ";
read a;
echo "Selamat Datang Mr./Mrs. $a, Lanjut?";
sudo yum -y update
sudo reboot
https://www.youtube.com/watch?v=YGNeZV1raGQ&feature=emb_title
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm [On CentOS/RHEL 7]
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
dnf install http://rpms.remirepo.net/fedora/remi-release-29.rpm [On Fedora 29]
#_centos6
yum update && yum install epel-release
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
#_centos7
yum update && yum install epel-release
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
#_centos8
dnf install httpd -y
systemctl enable --now httpd
systemctl status httpd
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
firewall-cmd --list-services
dnf info php
dnf install php
systemctl enable php-fpm
systemctl start php-fpm
systemctl status php-fpm
dnf search php-
php-gd.x86_64 : A module for PHP applications for using the gd graphics library
php-cli.x86_64 : Command-line interface for PHP
php-fpm.x86_64 : PHP FastCGI Process Manager
php-cli.x86_64 : Command-line interface for PHP
cd /var/www/html/
echo "<h1>hello world</h1>" > index.html
cd /var/www
mkdir superuser.web.id wpdev.web.id
echo "<h1>superuser.web.id</h1>" > superuser.web.id/index.html
echo "<h1>wpdev.web.id</h1>" > wpdev.web.id/index.html
cd /etc/httpd/conf.d/
vi superuser.web.id.conf
<VirtualHost *:80>
ServerName www.superuser.web.id
ServerAlias superuser.web.id
DocumentRoot /var/www/superuser.web.id
<Directory /var/www/superuser.web.id>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/superuser.web.id_error.log
CustomLog /var/log/httpd/superuser.web.id_access.log combined
</VirtualHost>
vi wpdev.web.id.conf
<VirtualHost *:80>
ServerName www.wpdev.web.id
ServerAlias wpdev.web.id
DocumentRoot /var/www/wpdev.web.id
<Directory /var/www/wpdev.web.id>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/wpdev.web.id_error.log
CustomLog /var/log/httpd/wpdev.web.id_access.log combined
</VirtualHost>
systemctl restart httpd
systemctl status httpd
#_rhel7
subscription-manager repos --enable=rhel-7-server-optional-rpms
#_rhel6
subscription-manager repos --enable=rhel-6-server-optional-rpms
#_Fedora 24-29
# rpm -Uvh http://rpms.remirepo.net/fedora/remi-release-29.rpm [On Fedora 29]
# rpm -Uvh http://rpms.remirepo.net/fedora/remi-release-28.rpm [On Fedora 28] dst
RHEL or CentOS 7
yum install yum-utils
shows all enabled repositories. These two commands are identical.
yum repolist
yum -v repolist all
yum repolist disabled
yum-config-manager --disable remi-php54
yum-config-manager --enable remi-php74
yum-config-manager --enable remi-php73
#_For example, to install PHP 7.x version, use the following command.
#_---------CentOS & RHEL -------------
yum-config-manager --enable remi-php70 && yum install php
yum-config-manager --enable remi-php71 && yum install php
yum-config-manager --enable remi-php72 && yum install php
yum-config-manager --enable remi-php73 && yum install php
yum-config-manager --enable remi-php74
#_------------- On Fedora -------------
dnf --enablerepo=remi install php70
dnf --enablerepo=remi install php71
dnf --enablerepo=remi install php72
dnf --enablerepo=remi install php73 [Install PHP 7.3]
#_------ RHEL/CentOS 7/6------
yum search all php
#_------ Fedora / CENTOS 8------
dnf search all php
yum install httpd mariadb mariadb-server php php-common php-mysql php-gd php-xml php-mbstring php-mcrypt
yum install httpd mariadb mariadb-server php php-common php-mysql php-gd php-xml php-mbstring php-mcrypt
systemctl start mariadb
mysql_secure_installation
systemctl enable mariadb
systemctl start httpd
systemctl enable httpd
Then we will configure MariaDB to start automatically on system boot:
systemctl enable mariadb
systemctl start httpd
systemctl enable httpd
# mysql -u root -p
Enter password:
## Create database ##
CREATE DATABASE wordpress;
## Creating new user ##
CREATE USER wordpress@localhost IDENTIFIED BY "secure_password";
## Grant privileges to database ##
GRANT ALL ON wordpress.* TO wordpress@localhost;
## FLUSH privileges ##
FLUSH PRIVILEGES;
## Exit ##
exit
cd /tmp && wget http://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz -C /var/www/html
/var/www/html/wordpress
chown -R apache /var/www/html/wordpress
#Creating Apache Virtual Host for WordPress
vim /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/wordpress
ServerName tecminttest.com
ServerAlias www.tecminttest.com
ErrorLog /var/log/httpd/tecminttest-error-log
CustomLog /var/log/httpd/tecminttest-acces-log common
</VirtualHost>
systemctl restart httpd
#_on ubuntu add vhost domain demo like www.wordpress.lan
$ sudo nano /etc/hosts
$ ping wordpress.lan
#_ in windows C:\Windows\System32\drivers\etc
sudo apt-get install apache2 apache2-utils php libapache2-mod-php php-mysql php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip mariadb-server mariadb-client
sudo apt-get install phpmyadmin
sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/
sudo mv /etc/apache2/conf-available/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin
sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/
sudo mv /etc/apache2/conf.d/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
#_next step is to create a Virtual Host on the Apache web server
sudo nano /etc/apache2/sites-available/wordpress.conf
<VirtualHost *:80>
ServerName wordpress.lan
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite wordpress.conf
sudo systemctl reload apache2
#_To avoid that future Apache error concerning, ServerName FQDN missing open main configfile '/etc/apache2/apache2.conf',
ServerName wordpress.lan
sudo systemctl restart apache2
sudo mysql_secure_installation
sudo mysql -u root -p
CREATE DATABASE mysite;
GRANT ALL PRIVILEGES ON mysite.* TO 'mysiteadmin'@'localhost' IDENTIFIED BY 'SecureP@ssHere!';
FLUSH PRIVILEGES;
EXIT;
wget http://wordpress.org/latest.tar.gz
sudo tar xvzf latest.tar.gz
sudo cp -r wordpress/* /var/www/html
#_On Debian systems, run the following commands.
$ sudo tar xvzf latest.tar.gz
$ sudo mkdir -p /var/www/html
$ sudo cp -r wordpress/* /var/www/html
$ sudo service apache2 restart
$ sudo service mysql restart
$ sudo chown -R www-data /var/www/html
$ sudo chmod -R 755 /var/www/html
http://wordpress.lan/index.php
sudo chown -R root /var/www/html
#_Enable HTTPS on WordPress
$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository universe
$ sudo apt-get update
$ sudo apt-get install certbot python3-certbot-nginx
$ sudo certbot --apache
#_you can check your site’s HTTPS at https://www.ssllabs.com/ssltest/.
yum list php
yum install httpd
systemctl enable httpd
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
#_Install repository Remi. Repository Remi ini menyediakan PHP versi 5.4, 7.0, 7.1, dan 7.2.
#_Perintah install repository di bawah ini akan menambah file .repo di /etc/yum.repos.d.
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
ls -l /etc/yum.repos.d
yum install yum-utils
yum-config-manager --enable remi-php70
yum info php
yum install php php-common
systemctl restart httpd
nano /var/www/html/info.php
#_php_di_ubuntu Install Apache and FastCGI module.
sudo apt update
sudo apt install apache2 libapache2-mod-fcgid -y
#_Install PHP and PHP-FPM.
sudo apt install php php-fpm -y
sudo systemctl status php7.4-fpm
sudo a2enmod actions fcgid alias proxy_fcgi
sudo nano /etc/apache2/sites-available/000-default.conf
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>
sudo systemctl restart apache2
sudo systemctl status apache2
#_Access http://localhost/info.php or http://serverIP/info.php. In the Server API the value is FPM/FastCGI.
sudo echo "<?php phpinfo(); ?>" > /var/www/html/info.php
Server requirements that must be met to run Laravel 8:
PHP > 7.3_!_BCMath PHP Extension_!_Ctype PHP Extension_!_Fileinfo PHP extension_!_JSON PHP Extension
Mbstring PHP Extension_!_OpenSSL PHP Extension_!_PDO PHP Extension_!_Tokenizer_PHP_Extension_!_XML PHP Extension
sudo apt install composer
sudo apt install php php-common php-bcmath php-mbstring php-mysql php-tokenizer php-zip
#_Install Laravel 8.0 using Composer and save it in the /home/user/public_html/blog
mkdir ~/public_html
cd ~/public_html
composer create-project laravel/laravel blog 8.0
composer create-project laravel/laravel blog
cd blog
php artisan serve
#_Browse http://127.0.0.1:8000 atau http://localhost:8000.
sudo apt install apache2 libapache2-mod-php
sudo systemctl restart apache2
sudo systemctl status apache2
#_URL http://127.0.0.1:8000 can be changed to a hostname or local domain using Apache virtual host & the file /etc/hosts.
<VirtualHost *:80>
ServerName laravel.web
DocumentRoot /home/user/public_html/blog/public
<Directory /home/user/public_html/blog/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/laravel.web_error.log
CustomLog /var/log/apache2/laravel.web_access.log combined
</VirtualHost>
sudo a2ensite laravel.web.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
sudo chown -R $USER:www-data /home/user/public_html/blog
sudo chmod -R 775 /home/user/public_html/blog
sudo nano /etc/hosts
127.0.0.1 laravel.web @@
sudo apt install build-essential curl file git
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
Make homebrew available in the system environment:
test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo eval" ($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval $($(brew --prefix)/bin/brew shellenv)" >>~/.profile
Install the dependency package for mkcert:
sudo apt install libnss3-tools
brew install mkcert
mkcert -install
#_Create an SSL certificate for laravel.web:
mkcert laravel.web
sudo mkdir /etc/apache2/ssl
sudo mv laravel.web*.pem /etc/apache2/ssl
sudo nano /etc/apache2/sites-available/laravel.web.conf
<VirtualHost *:80>
ServerName laravel.web
RewriteEngine on
RewriteCond %{SERVER_NAME} =laravel.web
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName laravel.web
DocumentRoot /home/user/public_html/blog/public
<Directory /home/user/public_html/blog/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/laravel.web_error.log
CustomLog /var/log/apache2/laravel.web_access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/laravel.web.pem
SSLCertificateKeyFile /etc/apache2/ssl/laravel.web-key.pem
</VirtualHost>
</IfModule>
sudo a2enmod ssl
sudo systemctl restart apache2
Browse https://laravel.web.
sudo apt install mariadb-server
sudo mysql_secure_installation
Enter current password for root (enter for none): ENTER
Set root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
sudo mysql -u root -p
CREATE DATABASE blog;
CREATE USER 'userblog'@'localhost' IDENTIFIED BY 'passblog';
GRANT ALL PRIVILEGES ON blog.* TO 'userblog'@'localhost';
FLUSH PRIVILEGES;
EXIT;
nano ~/public_html/blog/.env
DB_DATABASE=blog
DB_USERNAME=userblog
DB_PASSWORD=passblog
php artisan migrate
Install laravel/jetstream:
composer require laravel/jetstream
composer update
Install livewire:
php artisan jetstream:install livewire
#_laravel apache ubuntu
sudo apt install composer
sudo apt install php php-common php-bcmath php-mbstring php-mysql php-tokenizer php-zip
mkdir ~/public_html
cd ~/public_html
composer create-project laravel/laravel blog 8.0
composer create-project laravel/laravel blog
cd blog
php artisan serve
http://127.0.0.1:8000 atau http://localhost:8000.
sudo apt install apache2 libapache2-mod-php
sudo apt install apache2 libapache2-mod-php
sudo systemctl restart apache2
sudo systemctl status apache2
hostname atau local domain dengan menggunakan Apache virtual host dan file /etc/hosts.
laravel.web:
sudo nano /etc/apache2/sites-available/laravel.web.conf
<VirtualHost *:80>
ServerName laravel.web
DocumentRoot /home/musaamin/public_html/blog/public
<Directory /home/musaamin/public_html/blog/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/laravel.web_error.log
CustomLog /var/log/apache2/laravel.web_access.log combined
</VirtualHost>
sudo a2ensite laravel.web.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
sudo chown -R $USER:www-data /home/musaamin/public_html/blog
sudo chmod -R 775 /home/musaamin/public_html/blog
sudo nano /etc/hosts
127.0.0.1 laravel.web
sudo apt install build-essential curl file git
#_Download dan jalankan installer Homebrew:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo eval" ($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval $($(brew --prefix)/bin/brew shellenv)" >>~/.profile
brew install mkcert
#_Install Certificate Authority (CA):
mkcert -install
mkcert laravel.web
sudo mkdir /etc/apache2/ssl
sudo mv laravel.web*.pem /etc/apache2/ssl
sudo nano /etc/apache2/sites-available/laravel.web.conf
<VirtualHost *:80>
ServerName laravel.web
RewriteEngine on
RewriteCond %{SERVER_NAME} =laravel.web
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName laravel.web
DocumentRoot /home/musaamin/public_html/blog/public
<Directory /home/musaamin/public_html/blog/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/laravel.web_error.log
CustomLog /var/log/apache2/laravel.web_access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/laravel.web.pem
SSLCertificateKeyFile /etc/apache2/ssl/laravel.web-key.pem
</VirtualHost>
</IfModule>
sudo a2enmod ssl
sudo systemctl restart apache2
sudo mysql_secure_installation
Enter current password for root (enter for none): ENTER
Set root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
sudo mysql -u root -p
CREATE DATABASE blog;
CREATE USER 'userblog'@'localhost' IDENTIFIED BY 'passblog';
GRANT ALL PRIVILEGES ON blog.* TO 'userblog'@'localhost';
FLUSH PRIVILEGES;
EXIT;
#_Buka file .env:
nano ~/public_html/blog/.env
Konfigurasi koneksi database:
DB_DATABASE=blog
DB_USERNAME=userblog
DB_PASSWORD=passblog
php artisan migrate
Memasang laravel/jetstream:
composer require laravel/jetstream
composer update
php artisan jetstream:install livewire
#_install_ioncube................................
yum install httpd php php-cli
systemctl enable httpd
systemctl start httpd
systemctl status httpd
curl -O https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xzvf ioncube_loaders_lin_x86-64.tar.gz
ls ioncube
php -i | grep extension_dir
extension_dir => /usr/lib64/php/modules => /usr/lib64/php/modules
Copy ionCube Loader 5.4 ke extension directory.
cp ioncube/ioncube_loader_lin_5.4.so /usr/lib64/php/modules
#_Masukkan ionCube Loader ke dalam konfigurasi PHP.
vi /etc/php.ini
#_Masukkan opsi di bawah ini ke dalam file php.ini.
zend_extension = /usr/lib64/php/modules/ioncube_loader_lin_5.4.so
Restart Apache web server.
systemctl restart httpd
php -v
#_Here are the packages that we will install. Please keep in mind that MySQL 8 connectors (PHP, Perl, Python, Java, etc.) #_will work unchanged with MariaDB as both systems use the same client protocol & the client lib are binary compatible.
yum-config-manager --enable remi-php72 && yum install php
yum-config-manager --enable remi-php73 && yum install php
yum search php
yum install php php-mysql php-pdo php-gd php-mbstring
#echo "<?php phpinfo(); ?>" > /var/www/html/info.php
#systemctl restart httpd
#_if you get an error on PHP Date & Timezone, open php.ini config file https://www.php.net/manual/en/timezones.php
#_search and uncomment date.timezone statement, append your physical location & restart Apache daemon.
nano /etc/php.ini
date.timezone = Continent/City
#_centos7
yum --enablerepo=remi install php-mysqlnd php-pgsql php-pecl-mongo php-pdo php-pecl-memcache php-pecl-memcached php-gd php-xml php-mbstring php-mcrypt php-pecl-apcu php-cli php-pear
#_centos8
dnf --enablerepo=remi install php-mysqlnd php-pgsql php-pecl-mongo php-pdo php-pecl-memcache php-pecl-memcached php-gd php-xml php-mbstring php-mcrypt php-pecl-apcu php-cli php-pear
MariaDB/MySQL (php-mysql) – a dynamic shared object that will add MariaDB support to PHP.
PostgreSQL (php-pgsql) – PostgreSQL database support for PHP.
MongoDB (php-pecl-mongo) – An interface for communicating with the MongoDB database in PHP.
Generic (php-pdo) – A dynamic shared object that will add a database access abstraction layer to PHP.
Memcache (php-pecl-memcache) – Memcached is a caching daemon designed especially for dynamic web applications to decrease database load by storing objects in memory.
Memcached (php-pecl-memcached) An extension that uses the libmemcached lib to provide API for communicating with memcached servers.
GD (php-gd) – A dynamic share object that adds support for using the gd graphics library to PHP.
XML (php-xml) – A dynamic shared objects that adds support to PHP for manipulating XML documents.
MBString (php-mbstring) – An extension to handle multi-byte string in PHP applications.
MCrypt (php-mcrypt) – A Mcrypt library for PHP scripts.
APC (php-pecl-apcu) – APC module used to optimize and cache PHP code.
CLI (php-cli) – Command-line interface for PHP.
PEAR (php-pear) – Application Repository framework for PHP.
Install these following necessary PHP modules with the command below.
#_
rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm [On RHEL/CentOS 7]
# rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm [On RHEL/CentOS 6]
# rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-fc29-1.noarch.rpm [On Fedora 29]
# rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-fc28-1.noarch.rpm [On Fedora 28]
#_After installing the MySQL Yum repofor your Linux platform, now install the latest version (currently 8.0)
yum install mysql-community-server [On RHEL/CentOS]
# dnf install mysql-community-server [On Fedora]
service mysqld start
yum install httpd
#systemctl status|start|stop|restart|reload httpd
#service httpd status|start|stop|restart|reload
#apachectl configtest| graceful
#_Apache DocumentRoot path it’s set to /var/www/html
nano /etc/httpd/conf.d/welcome.conf
systemctl restart httpd
# systemctl start httpd
# systemctl enable httpd
# systemctl status httpd
#_Apache Virtual Hosts in RHEL/CentOS 7
cd /etc/httpd/
mkdir sites-available sites-enabled
nano conf/httpd.conf
on httpd.conf in /etc/httpd/sites-enabled
IncludeOptional sites-enabled/*.conf
nano /etc/httpd/sites-available/rheltest.lan.conf
<VirtualHost *:80>
ServerName rheltest.lan
DocumentRoot "/var/www/rheltest.lan"
<Directory "/var/www/rheltest.lan">
Options Indexes FollowSymLinks MultiViews
# AllowOverride controls what directives may be placed in .htaccess files.
AllowOverride All
# Controls who can get stuff from this server file
Order allow,deny
Allow from all
</Directory>
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
ErrorLog /var/log/httpd/rheltest.lan-error.log
CustomLog /var/log/httpd/rheltest.lan-access.log combined
</VirtualHost>
#_time to create a2ensite & a2dissite bash scripts on a executable system path-in this case is /usr/local/bin/ – but
#_you can use any executable path that $PATH system variable outputs. Create a2ensite Script
nano /usr/local/bin/a2ensite
#---------------------------
#!/bin/bash
if test -d /etc/httpd/sites-available && test -d /etc/httpd/sites-enabled ;
then
echo "-----------------------------------------------"
else
mkdir /etc/httpd/sites-available
mkdir /etc/httpd/sites-enabled
fi
avail=/etc/httpd/sites-available/$1.conf
enabled=/etc/httpd/sites-enabled/
site='ls /etc/httpd/sites-available/'
if [ "$#" != "1" ]; then
echo "Use script: a2ensite virtual_site"
echo -e "\nAvailable virtual hosts:\n$site"
exit 0
else
if test -e $avail; then
sudo ln -s $avail $enabled
else
echo -e "$avail virtual host does not exist! Please create one!\n$site"
exit 0
fi
if test -e $enabled/$1.conf; then
echo "Success!! Now restart Apache server: sudo systemctl restart httpd"
else
echo -e "Virtual host $avail does not exist!\nPlease see available virtual hosts:\n$site"
exit 0
fi
fi
#--------------------
#_Create a2dissite Script
nano /usr/local/bin/a2dissite
#------------------
#!/bin/bash
avail=/etc/httpd/sites-enabled/$1.conf
enabled=/etc/httpd/sites-enabled
site='ls /etc/httpd/sites-enabled/'
if [ "$#" != "1" ]; then
echo "Use script: a2dissite virtual_site"
echo -e "\nAvailable virtual hosts: \n$site"
exit 0
else
if test -e $avail; then
sudo rm $avail
else
echo -e "$avail virtual host does not exist! Exiting!"
exit 0
fi
if test -e $enabled/$1.conf; then
echo "Error!! Could not remove $avail virtual host!"
else
echo -e "Success! $avail has been removed!\nPlease restart Apache: sudo systemctl restart httpd"
exit 0
fi
fi
#-------------
chmod +x /usr/local/bin/a2*
a2ensite vhost_name
a2disite vhost_name
#_To test it, enable the virtual host created earlier, restart Apache then load http://rheltest.lan.
a2ensite rheltest.lan
systemctl restart httpd
#_That’s it! Now you can use a2eniste and a2dissite bash scripts as system commands to manage Apache Vhosts
#_Lets set up Name Based Virtual Hosting and IP based Virtual hosting in RHEL, CentOS and Fedora.
#_OS – CentOS 6.5
#_Application – Apache Web Server
#_IP Address – 192.168.0.100
#_IP Address – 192.168.0.101
#_Domain – www.example1.com
#_Domain – www.example2.com
#_before creating a virtual host, you need to create a directory
mkdir /var/www/html/example1.com/
mkdir /var/www/html/example1.com/
vi /etc/httpd/conf/httpd.conf
NameVirtualHost 192.168.0.100:80 @@
#_move to the bottom of the file by pressing Shift + G
<VirtualHost 192.168.0.100:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/example1.com
ServerName www.example1.com
ErrorLog logs/www.example1.com-error_log
CustomLog logs/www.example1.com-access_log common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/example2.com
ServerName www.example2.com
ErrorLog logs/www.example2.com-error_log
CustomLog logs/www.example2.com-access_log common
</VirtualHost>
[root@tecmint ~]# httpd -t
Syntax OK
service httpd restart
#_If syntax is OK. Please restart your Web server and add it to chkconfig
#_to make your web server start in runlevel 3 and 5 at the boot time only.
chkconfig --level 35 httpd on
[root@tecmint ~]# vi /var/www/html/example1.com/index.html
<html><head><title>www.example1.com</title></head><body><h1>Hello, Welcome to www.exa1.com.</h1></body></html>
[root@tecmint ~]# vi /var/www/html/example2.com/index.html
<html><head><title>www.example2.com</title></head><body><h1>Hello, Welcome to www.exa2.com.</h1></body></html>
http://www.example1.com
http://www.example2.com
#_To setup IP based virtual hosting, you must have more than one IP address/Port assigned to your server or your Linux
#_It can be on a single NIC card , For example: eth0:1, eth0:2, eth0:3 … so forth. Multiple NIC cards can also be #_attached. If you don’t know how to create multiple IP’s on single NIC, follow the below guide, that will help you
#_As you can see in above output, two IPs 192.168.0.100 (eth0) and 192.168.0.101 (eth0:1) is attached to the server, #_both IPs are assigned to the same physical network device (eth0). Search for word "Listen" on httpd.conf ,
[root@tecmint ~]# vi /etc/httpd/conf/httpd.conf
# Listen 80
Listen 192.168.0.100:80
#_Now, create a Virtual host sections for both the domains. Go the bottom of the file
<VirtualHost 192.168.0.100:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/example1
ServerName www.example1.com
ErrorLog logs/www.example1.com-error_log
TransferLog logs/www.example1.com-access_log
</VirtualHost>
<VirtualHost 192.168.0.101:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/example2
ServerName www.example2.com
ErrorLog logs/www.example2.com-error_log
TransferLog logs/www.example2.com-access_log
</VirtualHost>
service httpd restart
#_Installing MariaDB 10 Database Server
vi /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
#_------ On RHEL/CentOS 7 ------
yum --enablerepo=remi install httpd MariaDB-client MariaDB-server
#_------ On Fedora / CENTOS 8------
dnf --enablerepo=remi install httpd MariaDB-client MariaDB-server
systemctl enable httpd
systemctl enable mariadb
systemctl start httpd
systemctl start mariadb
#_On SysVinit
chkconfig --levels 235 httpd on
chkconfig --levels 235 mysqld on
#------ Start Apache and MySQL ------
/etc/init.d/httpd start
/etc/init.d/mysqld start
yum install mariadb-server mariadb
systemctl start mariadb
mysql_secure_installation
systemctl enable mariadb
#_by default official RHEL 7.0 or CentOS 7.0 repositories doesn’t provide PHPMYADMIN
#_install PhpMyAdmin package by enabling CentOS 7.0 rpmforge repositories using the following command.
yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
yum install phpmyadmin
nano /etc/httpd/conf.d/phpmyadmin.conf
Order Deny,Allow @@
Deny from all @@
Allow from 127.0.0.1 @@
#_To be able to login to PhpMyAdmin Web interface using cookie authentication method
#_add a blowfish string to phpmyadmin config.inc.php file using the generate a secret string, restart Apache Web
$cfg['blowfish_secret'] = 'ftwetwe94892fwbc'; @@
#_postgres
sudo yum repolist
sudo yum search postgresql13
sudo yum -y install postgresql13 postgresql13-server
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl start postgresql-13
sudo systemctl status postgresql-13
sudo systemctl enable postgresql-13
sudo su - postgres
psql -c "alter user postgres with password 'FromVarRead'" !!!!
sudo vi /var/lib/pgsql/13/data/postgresql.conf
listen_addresses = '172.20.11.11' @@@
sudo vi /var/lib/pgsql/13/data/pg_hba.conf
# Accept from anywhere (not recommended)
host all all 0.0.0.0/0 md5 @@
# Accept from trusted subnet (Recommended setting)
host all all 172.20.11.0/24 md5 @@
sudo systemctl restart postgresql-13
sql -U <dbuser> -h <serverip> -p 5432 <dbname> @@
systemctl status firewalld
firewall-cmd --state
dnf install firewalld
systemctl start firewalld
systemctl enable firewalld
systemctl status firewalld
firewall-cmd --state
firewall-cmd --get-zones
firewall-cmd --list-all-zones
firewall-cmd --get-active-zones
firewall-cmd --get-default-zone
#_Menampilkan konfigurasi satu zone, misalnya public.
firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: enp0s3 enp0s8
sources:
services: cockpit dhcpv6-client ssh
ports:
protocols:
masquerade: no
forward-ports:
#_Konfigurasi public zone di atas hanya mengijinkan service yang terdaftar yaitu cockpit, dhcpv6-client, dan ssh.
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --reload
firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: enp0s3 enp0s8
sources:
services: cockpit dhcpv6-client http ssh
firewall-cmd --get-services
#_Menghapus service dari zone gunakan remove.
firewall-cmd --zone=public --remove-service=http
#_Misalnya kita ingin mengijinkan akses ke port nomor 5000 untuk protokol TCP dan UDP.
firewall-cmd --zone=public --add-port=5000/tcp --permanent
firewall-cmd --zone=public --add-port=5000/udp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: enp0s3 enp0s8
sources:
services: cockpit dhcpv6-client http ssh
ports: 5000/tcp 5000/udp
protocols:
masquerade: no
firewall-cmd --zone=public --list-ports
5000/tcp 5000/udp
firewall-cmd --zone=public --remove-port=5000/tcp --permanent
firewall-cmd --zone=public --remove-port=5000/udp --permanent
firewall-cmd --reload
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
firewall-cmd --list-services
#_If you are running firewalld, make sure to allow Apache traffic on the firewall.
# firewall-cmd --zone=public --permanent --add-service=http
# firewall-cmd --zone=public --permanent --add-service=https
# firewall-cmd --reload
firewall-cmd --add-service=http
firewall-cmd --permanent --add-service=http
systemctl restart firewalld
# firewall-cmd --state
# firewall-cmd --list-all
# firewall-cmd --list-interfaces
# firewall-cmd --get-service
# firewall-cmd --query-service service_name
# firewall-cmd --add-port=8080/tcp
centos8
https://musaamin.web.id/cara-install-php-dengan-nginx-di-centos-8/
dnf install nginx
systemctl enable --now nginx
systemctl start nginx
systemctl status nginx
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
firewall-cmd --list-services
dnf install php php-mysqlnd php-pdo php-gd php-mbstring
systemctl enable php-fpm
systemctl start php-fpm
systemctl status php-fpm
cd /usr/share/nginx/html
echo "<?php phpinfo(); ?>" > info.php #_Lalu browsing http://ip-server/info.php.
#_Buat Document Root terlebih dahulu dan file testing PHP.
mkdir /var/www/superuser.web.id
echo "<?php phpinfo(); ?>" > /var/www/superuser.web.id
vi /etc/nginx/conf.d/superuser.web.id.conf
server {
listen 80;
server_name superuser.web.id;
root /var/www/superuser.web.id;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
}
access_log /var/log/nginx/superuser.web.id.access.log;
error_log /var/log/nginx/superuser.web.id.error.log warn;
}
systemctl restart nginx
systemctl status nginx
#_ cari nama paketnya dengan perintah dnf search.
dnf search php-
php-gd.x86_64 : A module for PHP applications for using the gd graphics library
php-cli.x86_64 : Command-line interface for PHP
php-fpm.x86_64 : PHP FastCGI Process Manager
php-cli.x86_64 : Command-line interface for PHP
systemctl enable --now nginx
systemctl start nginx
systemctl status nginx
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
firewall-cmd --list-services
https://usaamin.web.id/cara-install-php-7-4-di-centos-8/
dnf install epel-release -y
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
dnf module list php
dnf module enable php:remi-7.4
dnf install php php-cli php-common
systemctl enable httpd
systemctl start httpd
systemctl status httpd
#_Cek status php-fpm service, karena CentOS 8 tidak pakai Apache module. Install PHP tadi jadi menginstall PHP-FPM.
systemctl enable php-fpm
systemctl status php-fpm
UBUNT
-----------------------------
https://saamin.web.id/how-to-install-laravel-8-on-ubuntu-2004/
Server requirements that must be met to run Laravel 8:
PHP >= 7.3
BCMath PHP Extension
Ctype PHP Extension
Fileinfo PHP extension
JSON PHP Extension
Mbstring PHP Extension
OpenSSL PHP Extension
PDO PHP Extension
Tokenizer PHP Extension
XML PHP Extension
sudo apt install composer
sudo apt install php php-common php-bcmath php-mbstring php-mysql php-tokenizer php-zip
mkdir ~/public_html
cd ~/public_html
composer create-project laravel/laravel blog 8.0
composer create-project laravel/laravel blog
cd blog
php artisan serve
#_Starting Laravel development server: http://127.0.0.1:8000
sudo apt install apache2 libapache2-mod-php
sudo systemctl restart apache2
sudo systemctl status apache2
sudo nano /etc/apache2/sites-available/laravel.web.conf
<VirtualHost *:80>
ServerName laravel.web
DocumentRoot /home/user/public_html/blog/public
<Directory /home/user/public_html/blog/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/laravel.web_error.log
CustomLog /var/log/apache2/laravel.web_access.log combined
</VirtualHost>
sudo a2ensite laravel.web.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
sudo chown -R $USER:www-data /home/user/public_html/blog
sudo chmod -R 775 /home/user/public_html/blog
sudo nano /etc/hosts
127.0.0.1 laravel.web
sudo apt install build-essential curl file git
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
Test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo eval" ($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval $($(brew --prefix)/bin/brew shellenv)" >>~/.profile
sudo apt install libnss3-tools
brew install mkcert
mkcert -install
mkcert laravel.web
sudo mkdir /etc/apache2/ssl
sudo mv laravel.web*.pem /etc/apache2/ssl
Open the laravel.web virtual host configuration file:
sudo nano /etc/apache2/sites-available/laravel.web.conf
<VirtualHost *:80>
ServerName laravel.web
RewriteEngine on
RewriteCond %{SERVER_NAME} =laravel.web
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName laravel.web
DocumentRoot /home/user/public_html/blog/public
<Directory /home/user/public_html/blog/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/laravel.web_error.log
CustomLog /var/log/apache2/laravel.web_access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/laravel.web.pem
SSLCertificateKeyFile /etc/apache2/ssl/laravel.web-key.pem
</VirtualHost>
</IfModule>
sudo a2enmod ssl
sudo systemctl restart apache2
sudo apt install mariadb-server
sudo mysql_secure_installation
Enter current password for root (enter for none): ENTER
Set root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
sudo mysql -u root -p
CREATE DATABASE blog;
CREATE USER 'userblog'@'localhost' IDENTIFIED BY 'passblog';
GRANT ALL PRIVILEGES ON blog.* TO 'userblog'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Open the .env file:
nano ~/public_html/blog/.env
DB_DATABASE=blog
DB_USERNAME=userblog
DB_PASSWORD=passblog
Run migrate to create a user table:
php artisan migrate
composer require laravel/jetstream
composer update
php artisan jetstream:install livewire
>>>>>>>>>>>>>>>
yum update && yum install httpd mariadb mariadb-server *yum os
aptitude update && aptitude install apache2 mariadb-server mariadb-client mariadb.common *debian
wget https://downloads.php.net/~ab/php-7.0.0RC1.tar.gz
tar xzf php-7.0.0RC1.tar.gz -C /opt
cd /opt/php-7.0.0RC1.tar.gz
./buildconf --force
# ./configure \
--prefix=$HOME/php7/usr \
--with-config-file-path=$HOME/php7/usr/etc \
--enable-mbstring \
--enable-zip \
--enable-bcmath \
--enable-pcntl \
--enable-ftp \
--enable-exif \
--enable-calendar \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-curl \
--with-mcrypt \
--with-iconv \
--with-gmp \
--with-pspell \
--with-gd \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-zlib-dir=/usr \
--with-xpm-dir=/usr \
--with-freetype-dir=/usr \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-openssl \
--with-pdo-mysql=/usr \
--with-gettext=/usr \
--with-zlib=/usr \
--with-bz2=/usr \
--with-recode=/usr \
--with-mysqli=/usr/bin/mysql_config \
--with-apxs2
#_configure: error: no acceptable C compiler found in $PATH see 'config.log' for more details
yum install gcc
aptitude install gcc
#_configure: error: xml2-config not found. Please check your libxml2 installation.
gcc
libxml2-devel
pkgconfig
openssl-devel
bzip2-devel
curl-devel
libpng-devel
libpng-devel
libjpeg-devel
libXpm-devel
freetype-devel
gmp-devel
libmcrypt-devel
mariadb-devel
aspell-devel
recode-devel
httpd-devel
yum install gcc libxml2-devel pkgconfig openssl-devel bzip2-devel libpng-devel libpng-devel libjpeg-devel libXpm-devel freetype-devel gmp-devel libmcrypt-devel mariadb-devel aspell-devel recode-devel httpd-devel
make
make install
#_debian
apt-get install make libxml2-dev libcurl4-openssl-dev libjpeg-dev libpng-dev libxpm-dev libmysqlclient-dev libicu-dev libfreetype6-dev libxslt-dev libssl-dev libbz2-dev libgmp-dev libmcrypt-dev libpspell-dev librecode-dev apache2-dev
ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h
make
make install
ls -l /opt/php-7.0.0RC1 | grep php.ini
cp /opt/php-7.0.0RC1/php.ini-development /usr/local/lib
/etc/httpd/conf/httpd.conf *yum
/etc/apache2/apache2.conf *deb
LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
#_ debi omit the LoadModule line & also need to remove & create the follow symbolic links to the indicated Apache modules
cd /etc/apache2
rm mods-enabled/mpm_event.conf
rm mods-enabled/mpm_event.load
ln -s mods-available/mpm_prefork.conf mpm_prefork.conf
ln -s mods-available/mpm_prefork.load mpm_prefork.load
# systemctl restart httpd [On CentOS 7 box]
# systemctl restart apache2 [On Debian 8 box]
---------------------
#yum -y update
#yum install net-snmp net-snmp-utils -y
#systemctl enable snmpd
#systemctl restart snmpd
#sudo yum install firewalld
#sudo systemctl enable firewalld
#mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig
#systemctl restart firewalld
#firewall-cmd --permanent --add-port=161/udp
#firewall-cmd --reload
#firewall-cmd --list-all
######echo -e "# sec.name source community\ncom2sec notConfigUser default @lawangs18\n
####\n# Second, map the security name into a group name:\n
# We do not want annoying "Connection from UDP: " messages in syslog.\n# If the following option is commented out, snmpd will print each incoming\n
# connection, which can be useful for debugging.\ndontLogTCPWrappersConnects yes" > /etc/snmp/snmpd.conf
cukcukcukcukcuk
https://tecadmin.net/install-laravel-framework-on-centos/
Setup Yum Repositories
First of all, you need to add REMI and EPEL rpm repositories in your system. these repositories have updated packages. Use one of the below commands as per your OS version and system architecture.
CentOS/RHEL 7:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-12.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
CentOS/RHEL 6:
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Install Apache, MySQL and PHP
Here is short instruction for the installation of LAMP stack. Its required to run the Laravel framework on your CentOS system. Use this guide for the detailed LAMP setup on CentOS
Install Apache
yum --enablerepo=remi,epel install httpd
yum --enablerepo=remi,epel install mysql-server
service mysqld start
/usr/bin/mysql_secure_installation
yum --enablerepo=remi,epel install php php-zip php-mysql php-mcrypt php-xml php-mbstring
service httpd restart
Install Composer
Composer is required for installing Laravel dependencies. So use below commands to download and use as a command in our system.
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/bin/composer
chmod +x /usr/bin/composer
Install Laravel
To download latest version of Laravel, Use below command to clone master repo of laravel from github.
cd /var/www
git clone https://github.com/laravel/laravel.git
Navigate to the Laravel code directory and use the composer to install all dependencies required for the Laravel framework.
cd /var/www/laravel
composer install
Dependency installation will take some time. After than set proper permissions on files.
chown -R apache.apache /var/www/laravel
chmod -R 755 /var/www/laravel
chmod -R 755 /var/www/laravel/storage
SELinux enabled systems also run the below command to allow write on storage directory.
chcon -R -t httpd_sys_rw_content_t /var/www/laravel/storage
Set Encryption Key
Laravel uses .evn file for environment configuration. Use .evn file for configuring all the environment variables for your application like the database, SMTP, security key, etc.
cp .env.example .env
Now set the 32 bit long random number encryption key, which used by the Illuminate encrypter service.
php artisan key:generate
Application key set successfully.
You can view the .env file to find the Application key is configured.
Create Apache Virtual Host
Now add a Virtual Host in your Apache configuration file to access Laravel framework from web browser. To do it edit Apache configuration file /etc/httpd/conf/httpd.conf and add below code at end of file
vim /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerName laravel.example.com
DocumentRoot /var/www/laravel/public
<Directory /var/www/laravel>
AllowOverride All
</Directory>
</VirtualHost>
Restart Apache service and access the Laravel framework using your favorite web browser and start developing a great web application.
service httpd restart
https://tecadmin.net/install-lamp-apache-mysql-and-php-on-centos-rhel-7/
https://tecadmin.net/install-lamp-apache-mysql-and-php-on-centos-rhel-7/
https://tecadmin.net/install-lamp-apache-mysql-and-php-on-centos-rhel-7/
LAMP stands for Linux, Apache, MySQL and PHP. Its is used for hosting websites written with PHP programming language and using MySQL as backend database server. This article will help you to install Apache 2.4, MySQL 8 and PHP 7.3 on CentOS 7 and RedHat 7 systems. You may also use video tutorial on Youtube for installation instruction’s.
Prerequsitis
The two most popular rpm repositories REMI and EPEL have most of the updated packages. They are also providing the latest packages for LAMP setup. Enable both repositories on your system using the following commands on your CentOS 7 system.
rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
Install Apache Server
Apache or HTTP is the most popular web server used on Linux based systems. Let’s install Apache web server using the following command by enabling EPEL and REMI yum repositories.
yum --enablerepo=epel,remi install httpd
Now start httpd service and enable to start on boot using commands.
systemctl enable httpd.service
systemctl start httpd.service
Install MySQL Server
First, add MySQL yum repository in your system using the following command. You may also visit repo.mysql.com to find repository rpms for other operating systems. The below command will work with CentOS and RedHat 7.
rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
The default MySQL 8 repository is enabled for installation. To change edit repository configuration file (/etc/yum.repos.d/mysql-community.repo) and enable/disable repositories as per requirements.
Then install the MySQL server and other dependency packages.
yum install mysql-server
After installation enable MySQL service and start it.
systemctl enable mysqld.service
systemctl start mysqld.service
The installer generated a temporary password for MySQL root user and copied to log file. You can find this password using the below command.
grep "A temporary password" /var/log/mysqld.log | tail -n1
[Some text hidden] A temporary password is generated for root@localhost: Eif;=YpBy2h#
Apply security on newly installed MySQL server. This will also prompt you to change the temporary password with a new password.
mysql_secure_installation
Enter password for user root: [Enter password here found in log file]
The existing password for the user account root has expired. Please set a new password.
New password: [Enter new password]
Re-enter new password: [Re-enter new password]
Change the password for root? - n
Remove anonymous users? - y
Disallow root login remotely? - y
Remove test database and access to it? - y
Reload privilege tables now? - y
MySQL has been installed on your system. After this install PHP.
Install PHP
Now, install PHP packages with enabling EPEL and REMI repositories using the following command.
yum --enablerepo=epel,remi-php74 install php
yum --enablerepo=remi-php74 list php-*
yum --enablerepo=remi-php74 install php-mysql php-xml php-xmlrpc php-soap php-gd
After installing php and other php modules restart Apache service.
systemctl restart httpd.service
Allow Port in Firewall
Finally open firewall ports for HTTP (80) and HTTPS (443) services using the following command.
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
php -v
httpd -v
mysql -v
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-centos-8
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-centos-8
dnf module list postgresql
Output
postgresql 9.6 client, server [d] PostgreSQL server and client module
postgresql 10 [d] client, server [d] PostgreSQL server and client module
postgresql 12 client, server
To enable the module stream for Postgres version 12, run the following command:
sudo dnf module enable postgresql:12
When prompted, press y and then ENTER to confirm that you want to enable the stream:
Output
====================================================================
Package Architecture Version Repository Size
====================================================================
Enabling module streams:
postgresql 12
Transaction Summary
====================================================================
Is this ok [y/N]: y
After enabling the version 12 module stream, you can install the postgresql-server package to install PostgreSQL 12 and all of its dependencies:
sudo dnf install postgresql-server
When given the prompt, confirm the installation by pressing y then ENTER:
Output
. . .
Install 4 Packages
Total download size: 16 M
Installed size: 62 M
Is this ok [y/N]: y
Now that the software is installed, you will perform some initialization steps to prepare a new database cluster for PostgreSQL.
Creating a New PostgreSQL Database Cluster
You have to create a new PostgreSQL database cluster before you can start creating tables and loading them with data. A database cluster is a collection of databases that are managed by a single server instance. Creating a database cluster consists of creating the directories in which the database data will be placed, generating the shared catalog tables, and creating the template1 and postgres databases.
The template1 database is a template of sorts used to create new databases; everything that is stored in template1, even objects you add yourself, will be placed in new databases when they’re created. The postgres database is a default database designed for use by users, utilities, and third-party applications.
The Postgres package we installed in the previous step comes with a handy script called postgresql-setup which helps with low-level database cluster administration. To create a database cluster, run the script using sudo and with the --initdb option:
sudo postgresql-setup --initdb
You will see the following output:
Output
* Initializing database in '/var/lib/pgsql/data'
* Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log
Now start the PostgreSQL service using systemctl:
sudo systemctl start postgresql
Then, use systemctl once more to enable the service to start up whenever the server boots:
sudo systemctl enable postgresql
This will give the following output
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /usr/lib/systemd/system/postgresql.service.
Using PostgreSQL Roles and Databases
PostgreSQL uses a concept called roles to handle client authentication and authorization. These are in some ways similar to regular Unix-style accounts, but Postgres does not distinguish between users and groups and instead prefers the more flexible term role.
Upon installation, Postgres is set up to use ident authentication, meaning that it associates Postgres roles with a matching Unix/Linux system account. If a role exists within Postgres, a Unix/Linux username with the same name is able to sign in as that role.
The installation procedure created a user account called postgres that is associated with the default postgres role. In order to use PostgreSQL, you can log in to that account.
There are a few ways to use this account to access the PostgreSQL prompt.
Switching Over to the postgres Account
Switch over to the postgres account on your server by typing:
sudo -i -u postgres
You can now access a Postgres prompt immediately by typing:
psql
This will log you into the PostgreSQL prompt, and from here you are free to interact with the database management system right away.
Exit out of the PostgreSQL prompt by typing:
\q
This will bring you back to the postgres account’s Linux command prompt. Now return to your original account with the following:
exit
Accessing a Postgres Prompt Without Switching Accounts
You can also run commands with the postgres account directly using sudo.
For instance, in the previous example, you were instructed to access the Postgres prompt by first switching to the postgres user and then running psql to open the Postgres prompt. As an alternative, you could do this in one step by running the single command psql as the postgres user with sudo, like this:
sudo -u postgres psql
This will log you directly into Postgres without the intermediary bash shell.
Again, you can exit the interactive Postgres session by typing:
\q
In this step, you used the postgres account to reach the psql prompt. But many use cases require more than one Postgres role. Read on to learn how to configure new roles.
Creating a New Role
Currently, you just have the postgres role configured within the database. You can create new roles from the command line with the createrole command. The --interactive flag will prompt you for the name of the new role and also ask whether it should have superuser permissions.
If you are logged in as the postgres account, you can create a new user by typing:
createuser --interactive
sudo -u postgres createuser --interactiveThe script will prompt you with some choices and, based on your responses, execute the necessary Postgres commands to create a user to your specifications. For this tutorial, create a role named sammy and give it superuser privileges by entering y when prompted:
Output
Enter name of role to add: sammy
Shall the new role be a superuser? (y/n) y
man createuser
Creating a New Database
Another assumption that the Postgres authentication system makes by default is that for any role used to log in, that role will have a database with the same name which it can access.
This means that if the user you created in the last section is called sammy, that role will attempt to connect to a database which is also called sammy by default. You can create such a database with the createdb command.
If you are logged in as the postgres account, you would type something like:
createdb sammy
If, instead, you prefer to use sudo for each command without switching from your normal account, you would type:
sudo -u postgres createdb sammy
This flexibility provides multiple paths for creating databases as needed.
Now that you’ve created a new database, you will log in to it with your new role.
Opening a Postgres Prompt with the New Role
To log in with ident-based authentication, you’ll need a Linux user with the same name as your Postgres role and database.
If you don’t have a matching Linux user available, you can create one with the adduser command. You will have to do this from your non-root account with sudo privileges (meaning, not logged in as the postgres user):
sudo adduser sammy
Once this new account is available, you can either switch over and then connect to the database by first typing:
sudo -i -u sammy
psql
sudo -u sammy psql
This command will log you in automatically.
If you want your user to connect to a different database, you can do so by including the -d flag and specifying the database, like this:
psql -d postgres
Once logged in, you can check your current connection information by typing:
\conninfo
This will show the following output:
Output
You are connected to database "sammy" as user "sammy" via socket in "/var/run/postgresql" at port "5432".
Creating and Deleting Tables
Now that you know how to connect to the PostgreSQL database system, you can learn some basic Postgres management tasks.
First, create a table to store some data. As an example, you will make a table that describes some playground equipment.
The basic syntax for this command is as follows:
CREATE TABLE table_name (
column_name1 col_type (field_length) column_constraints,
column_name2 col_type (field_length),
column_name3 col_type (field_length)
);
These commands give the table a name, and then define the columns as well as the column type and the max length of the field data. You can also optionally add table constraints for each column.
For demonstration purposes, create a simple table like this:
CREATE TABLE playground (
equip_id serial PRIMARY KEY,
type varchar (50) NOT NULL,
color varchar (25) NOT NULL,
location varchar(25) check (location in ('north', 'south', 'west', 'east', 'northeast', 'southeast', 'southwest', 'northwest')),
install_date date
);
This command will create a table that inventories playground equipment. It starts with an equipment ID, which is of the serial type. This data type is an auto-incrementing integer. You’ve also given this column the constraint of PRIMARY KEY, which means that the values must be unique and not null.
For two of the columns (equip_id and install_date), the command does not specify a field length. This is because some column types don’t require a set length because the length is implied by the type.
The next two lines create columns for the equipment type and color respectively, each of which cannot be empty. The line after these creates a location column and a constraint that requires the value to be one of eight possible values. The last line creates a date column that records the date on which you installed the equipment.
You can see your new table by typing:
\d
\dt
Adding, Querying, and Deleting Data in a Table
Now that you have a table, you can insert some data into it.
As an example, add a slide and a swing by calling the table you want to add to, naming the columns, and then providing data for each column, like this:
INSERT INTO playground (type, color, location, install_date) VALUES ('slide', 'blue', 'south', '2017-04-28');
INSERT INTO playground (type, color, location, install_date) VALUES ('swing', 'yellow', 'northwest', '2018-08-16');
SELECT * FROM playground;
DELETE FROM playground WHERE type = 'slide';
Adding and Deleting Columns from a Table
After creating a table, you can modify it to add or remove columns. Add a column to show the last maintenance visit for each piece of equipment by typing:
ALTER TABLE playground ADD last_maint date;
If you view your table information again, you will see the new column has been added (but no data has been entered):
SELECT * FROM playground;
Deleting a column is just as simple. If you find that your work crew uses a separate tool to keep track of maintenance history, you can delete the column by typing:
ALTER TABLE playground DROP last_maint;
This deletes the last_maint column and any values found within it, but leaves all the other data intact.
Having now added and deleted columns, you can try updating existing data in the final step.
Updating Data in a Table
So far, you’ve learned how to add records to a table and how to delete them, but this tutorial hasn’t yet covered how to modify existing entries.
You can update the values of an existing entry by querying for the record you want and setting the column to the value you wish to use. You can query for the swing record (this will match every swing in your table) and change its color to red:
UPDATE playground SET color = 'red' WHERE type = 'swing';
You can verify that the operation was successful by querying the data again:
SELECT * FROM playground;
https://www.digitalocean.com/community/tutorials/sqlite-vs-mysql-vs-postgresql-a-comparison-of-relational-database-management-systems
https://www.digitalocean.com/community/tutorials/introduction-to-queries-postgresql
https://www.tecmint.com/install-pgadmin4-in-centos-7/
https://www.tecmint.com/install-pgadmin4-in-centos-7/
yum -y install pgadmin4
# mv /etc/httpd/conf.d/pgadmin4.conf.sample /etc/httpd/conf.d/pgadmin4.conf
# vi /etc/httpd/conf.d/pgadmin4.conf
<VirtualHost *:80>
LoadModule wsgi_module modules/mod_wsgi.so
WSGIDaemonProcess pgadmin processes=1 threads=25
WSGIScriptAlias /pgadmin4 /usr/lib/python2.7/site-packages/pgadmin4-web/pgAdmin4.wsgi
<Directory /usr/lib/python2.7/site-packages/pgadmin4-web/>
WSGIProcessGroup pgadmin
WSGIApplicationGroup %{GLOBAL}
<IfModule mod_authz_core.c>
# Apache 2.4
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
</VirtualHost>
Next we will create logs and lib directories for pgAdmin4 and set their ownership:
# mkdir -p /var/lib/pgadmin4/
# mkdir -p /var/log/pgadmin4/
# chown -R apache:apache /var/lib/pgadmin4
# chown -R apache:apache /var/log/pgadmin4
# vi /usr/lib/python2.7/site-packages/pgadmin4-web/config_distro.py
And add the following lines:
LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin4/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin4/sessions'
STORAGE_DIR = '/var/lib/pgadmin4/storage'
Finally we will create our user account, with which we will authenticate in the web interface. To do this, run:
# python /usr/lib/python2.7/site-packages/pgadmin4-web/setup.py
Now you can access your server’s http://ip-address/pgadmin4 or http://localhost/pgadmin4 to reach the pgAdmin4 interface:
If you receive 403 error while accessing PgAdmin4 interface, you need to set the correct SELinux context on the following files.
# chcon -t httpd_sys_rw_content_t /var/log/pgadmin4 -R
# chcon -t httpd_sys_rw_content_t /var/lib/pgadmin4 -R
At your first login, you will need to add a new server to manage. Click on “Add New Server”. You will need to configure the PostgresQL connection. In the first tab “General”, enter the following settings:
Name – give name of the server you are configuring.
Comment – leave a comment to give description of the instance.
catat repo !!!
Repositories configuration:
On Fedora, standards repositories are enough, on Enterprise Linux (RHEL, CentOS) the Extra Packages for Enterprise Linux (EPEL) repository must be configured, and on RHEL the optional channel must be enabled.
Fedora 31
dnf install https://rpms.remirepo.net/fedora/remi-release-31.rpm
Fedora 30
dnf install https://rpms.remirepo.net/fedora/remi-release-30.rpm
RHEL version 8.1
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
RHEL version 7.7
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
subscription-manager repos --enable=rhel-7-server-optional-rpms
CentOS version 8.0
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
CentOS version 7.7
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
php module usage
With Fedora modular and RHEL / CentOS 8, you can simply use the remi-7.4 stream of the php module
dnf module reset php
dnf module install php:remi-7.4
remi-php74 repository activation
Needed packages are in the remi-safe (enabled by default) and remi-php74 repositories,
the latest is not enabled by default (administrator choice according to the desired PHP version).
RHEL or CentOS 7
yum install yum-utils
yum-config-manager --enable remi-php74
Fedora
dnf config-manager --set-enabled remi-php74
PHP upgrade
By choice, the packages have the same name than in the distribution, so a simple update is enough:
yum update
------------------------
https://ostechnix.com/install-apache-mariadb-php-lamp-stack-ubuntu-16-04/
Ansibel
https://www.tecmint.com/screen-command-examples-to-manage-linux-terminals/
sudo apt install apache2
sudo systemctl status apache2
sudo ufw app list
Apache
Apache Full
Apache Secure
OpenSSH
As you can see, Apache and OpenSSH applications have installed UFW profiles.
If you look into the “Apache Full” profile, you will see that it enables traffic to the ports 80 and 443:
sudo ufw app info "Apache Full"
Profile: Apache Full
Title: Web Server (HTTP,HTTPS)
Description: Apache v2 is the next generation of the omnipresent Apache web
server.
Ports:
80,443/tcp
sudo ufw allow in "Apache Full"
sudo apt install mariadb-server mariadb-client
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://sgp1.mirrors.digitalocean.com/mariadb/repo/10.3/ubuntu bionic main'
sudo apt update
sudo apt install mariadb-server
sudo systemctl status mysql
mysql_secure_installation
Enter current password for root (enter for none):
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Enter current password for root (enter for none):
You can't login set the password. You will see an error like below.
To fix this problem, log in as MySQL database administrator using command:
sudo mysql -u root
use mysql;
update user set plugin='' where User='root';
flush privileges;
\q
mysql_secure_installation
Enter current password for root (enter for none): # Press ENTER
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] # Press ENTER...
New password: # Enter password
Re-enter new password: # Re-enter password...
Password updated successfully!
PHP...
sudo apt install php libapache2-mod-php php-mysql
sudo vi /var/www/html/info.php
sudo systemctl restart apache2
sudo apt-cache search php- | less
sudo apt-cache show php-gd
sudo apt install php-gd
To install all modules (not necessary though), run:
sudo apt-get install php*
https://ostechnix.com/install-apache-mariadb-php-lamp-stack-on-arch-linux-2016/
https://ostechnix.com/install-nginx-mariadb-php-lemp-stack-on-arch-linux-2016/
https://www.tecmint.com/install-apache-mariadb-php-phpmyadmin-in-ubuntu-14-10/
sudo hostnamectl set-hostname yourFQDNname
sudo hostnamectl
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install apache2
http://your_server_IP
sudo apt-get install php5 php5-mysql php5-mcrypt php5-gd libapache2-mod-php5
sudo apt-cache search php5
sudo apt-cache show php5-module_name
sudo apt-get install mariadb-client mariadb-server
sudo mysql_secure_installation
mysql -u root -p
sudo apt-get install phpmyadmin
sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin
sudo service apache2 restart
http://your_server_IP/phpmyadmin
sudo nano /var/www/html/info.php
In order to be sure that Apache and MariaDB services are started after every system reboot, install sysv-rc-conf package that manages Ubuntu init scripts, then enable both services system-wide by running the following commands.
$ sudo apt-get install sysv-rc-conf
$ sudo sysv-rc-conf apache2 on
$ sudo sysv-rc-conf mysql on
https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-on-ubuntu-18-04-lamp/
https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-on-ubuntu-18-04-lamp/
In this tutorial, I will use the hostname server1.example.com with the IP address 192.168.1.100.
sudo -s
apt-get -y install mysql-server mysql-client
mysql_secure_installation
apt-get -y install mariadb-server mariadb-client
mysql_secure_installation
Enter current password for root (enter for none): <-- press enter
Set root password? [Y/n] <-- y
New password: <-- Enter the new MariaDB root password here
Re-enter new password: <-- Repeat the password
Remove anonymous users? [Y/n] <-- y
Disallow root login remotely? [Y/n] <-- y
Reload privilege tables now? [Y/n] <-- y
mysql -u root -p
apt-get -y install apache2
apt-get -y install php7.2 libapache2-mod-php7.2
systemctl restart apache2
nano /var/www/html/info.php
<?php
phpinfo();
chown www-data:www-data /var/www/html/info.php
As you see, PHP 7.2 is working, and it's working through the Apache 2.0 Handler, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP. MySQL is not listed there which means we don't have MySQL / MariaDB support in PHP yet.
Get MySQL / MariaDB support in PHP
To get MySQL support in PHP, we can install the php7.2-mysql package. It's a good idea to install some other PHP modules as well as you might need them for your applications. You can search for available PHP modules like this:
apt-cache search php7.2
apt-cache search php-
as not all PHP packages have the version number 7.2 in their name.
apt-get -y install php7.2-mysql php7.2-curl php7.2-gd php7.2-intl php-pear php-imagick php7.2-imap php-memcache php7.2-pspell php7.2-recode php7.2-sqlite3 php7.2-tidy php7.2-xmlrpc php7.2-xsl php7.2-mbstring php-gettext
systemctl restart apache2
Install the Opcache + APCu PHP cache to speed up PHP
PHP 7 ships with a built-in opcode cacher for caching and optimizing PHP intermediate code, it has the name 'opcache' and is available in the package php7.0-opcache. It is strongly recommended to have an Opcache installed to speed up your PHP page. Besides opcache, I will install APCu which is a compatibility wrapper for opcache to provide the functions of the APC cache, an often used caching system in PHP 5.x versions and many CMS systems still use it.
apt-get -y install php7.2-opcache php-apcu
Don't worry if it shows that Opcache is already installed.
systemctl restart apache2
Enable the SSL website in apache
SSL/ TLS is a security layer to encrypt the connection between the web browser and your server. Most web browsers start to show sites as insecure today when the connection between the server and the web browser is not encrypted with SSL. In this chapter, I will show you how to secure your website with SSL.
Execute the following commands on your server to enable SSL (https://) support. Run:
a2enmod ssl
a2ensite default-ssl
which enables the SSL module and adds a symlink in the /etc/apache2/sites-enabled folder to the file /etc/apache2/sites-available/default-ssl.conf to include it into the active apache configuration. Then restart apache to enable the new configuration:
systemctl restart apache2
apt-get -y install python3-certbot-apache
nano /etc/apache2/sites-available/000-default.conf
ServerName example.com
certbot --apache -d example.com
Accept the terms and conditions of the Let's Encrypt SSL authority.
Then choose if you want to redirect non-SSL requests to https:// automatically. I'll select yes here to avoid duplicate content problems when the website is available as http:// and https:// version.
The SSL certificate has been issued successfully.
When you access the website now with a browser, you will get redirected automatically to SSL and the green padlock in front of the URL bar in the browser shows that we are using a trusted SSL certificate now.
Let's encrypt Auto Renewal
Let's Encrypt SSL certificates are valid for a short period of 80 days only. Therefore a cronjob to auto-renew the SSL certificates is necessary that runs the certbot --renew command.
This cronjob get setup automatically when you install certbot, the cron file is /etc/cron.d/certbot. So there is nothing more to do here. If you like to know what the cronjob looks like, run the command:
/etc/cron.d/certbot
root@server1:~# cat /etc/cron.d/certbot
# /etc/cron.d/certbot: crontab entries for the certbot package
#
# Upstream recommends attempting renewal twice a day
#
# Eventually, this will be an opportunity to validate certificates
# haven't been revoked, etc. Renewal will only occur if expiration
# is within 30 days.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew
apt-get -y install phpmyadmin
Web server to configure automatically: <-- Select the option: apache2
Configure database for phpmyadmin with dbconfig-common? <-- Yes
MySQL application password for phpmyadmin: <-- Press enter, apt will create a random password automatically.
mysql -u root
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'howtoforge';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
Afterward, you can access phpMyAdmin under http://192.168.1.100/phpmyadmin/:
Virtual machine image download of this tutorial
This tutorial is available as ready to use virtual machine image in ovf/ova format that is compatible with VMWare and Virtualbox. The virtual machine image uses the following login details:
SSH / Shell Login
Username: administrator
Password: howtoforge
This user has sudo rights.
MySQL Login
Username: root
Password: howtoforge
The IP of the VM is 192.168.1.100, it can be changed in the file /etc/network/interfaces. Please change all the above passwords to secure the virtual machine.
Apache: http://httpd.apache.org/
PHP: http://www.php.net/
MySQL: http://www.mysql.com/
MariaDB: https://mariadb.com/
Ubuntu: http://www.ubuntu.com/
phpMyAdmin: http://www.phpmyadmin.net/
---------------------
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-20-04-id
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-20-04-id
Menginstal Apache dan Memperbarui Firewall
sudo apt update
sudo apt install apache2
Setelah instalasi selesai, Anda akan perlu menyesuaikan pengaturan firewall Anda untuk memperbolehkan lalu lintas HTTP. UFW memiliki berbagai profil aplikasi berbeda yang dapat Anda manfaatkan untuk menyelesaikannya. Untuk mendapatkan daftar semua profil aplikasi UFW yang tersedia, Anda dapat menjalankan:
sudo ufw app list
Berikut adalah makna dari setiap profil ini:
Apache: Profil ini hanya membuka porta 80 (lalu lintas web normal dan tidak terenkripsi).
Apache Full: Profil ini membuka baik porta 80 (lalu lintas web normal dan tidak terenkripsi) dan
porta 443 (lalu lintas terenkripsi TLS/SSL).
Apache Secure: Profile ini hanya membuka porta 443 (lalu lintas terenkripsi TLS/SSL).
Untuk saat ini, sebaiknya izinkan hanya koneksi pada porta 80, karena ini adalah instalasi Apache yang baru dan Anda belum memiliki sertifikat TLS/SSL yang dikonfigurasi untuk mengizinkan lalu lintas HTTPS di server Anda.
sudo ufw allow in "Apache"
sudo ufw status
http://your_server_ip
Cara Menemukan Alamat IP Publik Server Anda
Jika Anda tidak mengetahui alamat IP publik server Ada, ada sejumlah cara untuk mengetahuinya. Biasanya, ini adalah alamat yang digunakan untuk terhubung ke server Anda melalui SSH.
Ada beberapa cara untuk melakukannya dari baris perintah. Pertama, Anda dapat menggunakan alat iproute2 untuk mengetahui alamat IP dengan mengetik ini:
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
Ini akan menampilkan dua atau tiga baris tanggapan. Semua adalah alamat yang benar, tetapi komputer Anda mungkin hanya dapat menggunakan salah satunya, jadi silakan mencoba masing-masing alamat itu.
Cara alternatifnya adalah menggunakan utilitas curl untuk menghubungi pihak luar supaya memberitahukan bagaimana pihak luar melihat server Anda. Hal ini dilakukan dengan menanyakan alamat IP Anda kepada server tertentu:
curl http://icanhazip.com
Terlepas dari cara yang digunakan untuk mengetahui alamat IP Anda, ketik alamat IP pada bilah alamat di peramban web Anda untuk melihat laman Apache asali.
sudo apt install mysql-server
sudo mysql_secure_installation
Anda akan ditanya apakah Anda ingin mengonfigurasi VALIDATE PASSWORD PLUGIN.
Catatan: Mengaktifkan fitur ini merupakan keputusan yang Anda pertimbangkan sendiri. Jika diaktifkan, kata sandi yang tidak cocok dengan kriteria yang ditentukan akan ditolak oleh MySQL dengan suatu kesalahan. Akan lebih aman jika Anda tetap menonaktifkan validasi, tetapi Anda harus selalu menggunakan kata sandi yang kuat dan unik untuk kredensial basis data.
Jawab Y untuk ya, atau jawaban lain untuk melanjutkan tanpa mengaktifkan.
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No:
Jika Anda menjawab “ya”, Anda akan diminta untuk memilih tingkat validasi kata sandi. Harap ingat bahwa jika Anda memasukkan 2 sebagai tingkat terkuat, Anda akan menjumpai kesalahan saat berusaha menentukan kata sandi yang tidak mengandung angka, huruf kapital dan huruf kecil, serta karakter khusus, atau kata sandi yang berdasarkan pada kata-kata kamus umum.
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
Terlepas dari pilihan pengaturan VALIDATE PASSWORD PLUGIN, server Anda akan meminta Anda untuk memilih dan mengonfirmasi kata sandi untuk pengguna root MySQL. Ini tidak sama dengan root sistem. Pengguna root basis data adalah pengguna administratif dengan privilese penuh terhadap sistem basis data. Meskipun metode autentikasi asali untuk pengguna root MySQL mengecualikan penggunaan kata sandi, sekalipun kata kata sandi sudah dibuat, Anda tetap harus menentukan kata sandi yang kuat di sini sebagai langkah keamanan tambahan. Kita akan membahas hal ini sebentar lagi.
Jika Anda mengaktifkan validasi kata sandi, Anda akan diperlihatkan kekuatan kata sandi untuk kata sandi root yang baru saja Anda masukkan dan server Anda akan bertanya apakah Anda ingin melanjutkan dengan kata sandi itu. Jika Anda puas dengan kata sandi ini, tekan Y untuk “ya” di prompt:
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
Untuk pertanyaan lainnya, tekan Y dan tombol ENTER pada setiap pertanyaan. Ini akan menghapus sebagian pengguna anonim dan basis data percobaan, menonaktifkan log masuk root dari jarak jauh, dan memuat aturan-aturan baru ini sehingga MySQL segera menerapkan perubahan yang Anda buat.
Setelah Anda selesai, lakukan percobaan apakah Anda dapat melakukan log masuk ke konsol MySQL dengan mengetik:
sudo mysql
exit
Anda juga akan memerlukan libapache2-mod-php untuk memungkinkan Apache menangani berkas PHP. Paket PHP inti akan secara otomatis terinstal sebagai dependensi.
sudo apt install php libapache2-mod-php php-mysql
php -v
Menciptakan Hos Virtual untuk Situs Web Anda
Ketika menggunakan server web Apache, Anda bisa menciptakan hos virtual (serupa dengan blok server di Nginx) untuk merangkum detail konfigurasi dan menjadi hos dari lebih dari satu domain dari server tunggal. Dalam panduan ini, kita akan menyiapkan domain bernama your_domain, tetapi Anda harus menggantinya dengan nama domain Anda sendiri.
Catatan: Jika Anda menggunakan DigitalOcean sebagai penyedia hos DNS, lihat dokumen produk kami untuk instruksi mendetail tentang cara mempersiapkan nama domain baru dan mengarahkannya ke server Anda.
Apache pada Ubuntu 20.04 memiliki satu blok server yang aktif secara asali, yang dikonfigurasi untuk menyajikan dokumen-dokumen dari direktori /var/www/html. Meskipun ini berfungsi baik untuk situs tunggal, ini bisa menjadi sulit dijalankan jika Anda menjadi hos dari beberapa situs. Alih-alih memodifikasi /var/www/html, kita akan menciptakan suatu struktur direktori dalam /var/www untuk situs your_domain, dengan membiarkan /var/www/html sebagai direktori asali yang akan ditampilkan jika permintaan klien tidak cocok dengan situs lain.
Buat direktori untuk your_domain sebagai berikut:
sudo mkdir /var/www/your_domain
Selanjutnya, tentukan kepemilikan direktori dengan variabel lingkungan $USER, yang akan merujuk pada pengguna sistem Anda saat ini:
sudo chown -R $USER:$USER /var/www/your_domain
Kemudian, buka berkas konfigurasi baru dalam direktori sites-available Apache dengan menggunakan editor baris perintah yang Anda sukai. Di sini, kita akan menggunakan nano:
sudo nano /etc/apache2/sites-available/your_domain.conf
Ini akan menciptakan berkas kosong yang baru. Tempelkan konfigurasi dasar berikut:
/etc/apache2/sites-available/your_domain.conf
<VirtualHost *:80>
ServerName your_domain
ServerAlias www.your_domain
ServerAdmin webmaster@localhost
DocumentRoot /var/www/your_domain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Dengan konfigurasi VirtualHost ini, kita menyuruh Apache untuk menyajikan your_domain menggunakan /var/www/your_domain sebagai direktori root web. Jika Anda ingin menguji Apache tanpa nama domain, Anda dapat menghapus atau memberikan komentar pada opsi ServerName dan ServerAlias dengan menambahkan karakter # di depan masing-masing baris opsi.
Anda dapat menggunakan a2ensite untuk mengaktifkan hos virtual yang baru:
sudo a2ensite your_domain
Anda mungkin ingin menonaktifkan situs web asali yang terinstal dengan Apache. Ini diperlukan jika Anda tidak menggunakan nama domain khusus, karena dalam hal ini, konfigurasi asali Apache akan menimpa hos virtual Anda. Untuk menonaktifkan situs web asali Apache, ketikkan:
sudo a2dissite 000-default
Untuk memastikan berkas konfigurasi Anda tidak berisi kesalahan sintaks, jalankan:
sudo apache2ctl configtest
Terakhir, muat ulang Apache agar perubahan ini diterapkan:
sudo systemctl reload apache2
Situs web Anda yang baru kini sudah aktif, tetapi root web /var/www/your_domain masih kosong.
Buat berkas index.html di dalam lokasi itu sehingga kita dapat menguji apakah hos virtual bekerja sesuai harapan:
nano /var/www/your_domain/index.html
Sertakan konten berikut di dalam berkas ini:
<html>
<head>
<title>your_domain website</title>
</head>
<body>
<h1>Hello World!</h1>
<p>This is the landing page of <strong>your_domain</strong>.</p>
</body>
</html>
Anda dapat meninggalkan berkas ini di lokasinya saat ini sebagai laman landas sementara untuk aplikasi Anda sampai Anda menyiapkan berkas index.php untuk menggantinya. Setelah Anda melakukannya, ingat untuk menghapus atau mengganti nama berkas index.html dari root dokumen Anda, karena berkas ini lebih diutamakan daripada berkas index.php secara asali.
Catatan Tentang DirectoryIndex pada Apache
Dengan pengaturan DirectoryIndex asali pada Apache, berkas yang diberi nama index.html akan selalu lebih diutamakan daripada berkas index.php. Ini berguna untuk menyiapkan laman pemeliharaan di aplikasi PHP, dengan menciptakan berkas index.html sementara yang mengandung suatu pesan informatif bagi pengunjung. Karena lebih diutamakan daripada laman index.php, laman ini akan menjadi laman landas untuk aplikasi. Setelah pemeliharaan selesai, index.html diubah namanya atau dihapus dari root dokumen, sehingga mengembalikan laman aplikasi reguler.
sudo nano /etc/apache2/mods-enabled/dir.conf
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
sudo systemctl reload apache2
sudo rm /var/www/your_domain/info.php
Menguji Koneksi Basis Data dari PHP (Opsional)
Saat menyusun tulisan ini, pustaka PHP MySQL asli mysqlndtidak mendukung caching_sha2_authentication, metode autentikasi asali untuk MySQL 8. Kita akan perlu menciptakan pengguna baru dengan metode autentikasi mysql_native_password agar dapat terhubung ke basis data MySQL dari PHP.
Kita akan menciptakan basis data bernama example_database dan pengguna bernama example_user, tetapi Anda dapat mengganti nama-nama ini dengan nilai yang berbeda.
Pertama, hubungkan ke konsol MySQL menggunakan akun root:
sudo mysql
CREATE DATABASE example_database;
CREATE USER 'example_user'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
GRANT ALL ON example_database.* TO 'example_user'@'%';
exit
mysql -u example_user -p
CREATE TABLE example_database.todo_list (
item_id INT AUTO_INCREMENT,
content VARCHAR(255),
PRIMARY KEY(item_id)
);
INSERT INTO example_database.todo_list (content) VALUES ("My first important item");
SELECT * FROM example_database.todo_list;
nano /var/www/your_domain/todo_list.php
<?php
$user = "example_user";
$password = "password";
$database = "example_database";
$table = "todo_list";
try {
$db = new PDO("mysql:host=localhost;dbname=$database", $user, $password);
echo "<h2>TODO</h2><ol>";
foreach($db->query("SELECT content FROM $table") as $row) {
echo "<li>" . $row['content'] . "</li>";
}
echo "</ol>";
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
http://your_domain_or_IP/todo_list.php
https://httpd.apache.org/docs/current/vhosts/
https://www.howtoforge.com/tutorial/ubuntu-lts-minimal-server/
Preliminary Note
In this tutorial, I use the hostname server1.example.com with the IP address 192.168.0.100 and the gateway 192.168.0.1 These settings might differ for you, so you have to replace them where appropriate.
........
https://www.niagahoster.co.id/blog/cara-install-lemp-di-ubuntu/
LEMP adalah singkatan dari Linux, Nginx, MariaDB, dan PHP. Fungsi LEMP adalah untuk membuat server website dan membantu agar aplikasi menjadi dinamis. Fungsinya sama seperti dengan XAMPP yang ada di sistem operasi Windows.
Langkah 1 : Menginstall Nginx dan Memperbarui Firewall
Nginx adalah web server HTTP dan proxy dengan kode open source yang bisa juga berfungsi sebagai proxy IMAP/POP3. Kenapa menggunakan Nginx? Karena Nginx menawarkan penggunaan memori yang kecil dengan konkurensi yang tinggi. Sehingga akan mempercepat Anda dalam menyelesaikan semua proses di server. Berikut ini adalah langkah-langkah cara update CentOS 7 dan install Nginx.
sudo apt-get update && apt-get upgrade
sudo apt-get install nginx
Terkadang, dalam beberapa kasus halaman default Nginx tidak muncul. Ini dapat disebabkan oleh pengaturan firewall yang diterapkan pada server. Untuk menanggulangi hal ini, Anda perlu install UFW guna mengatur Nginx agar menerima permintaan web pada port 80 dan port 443 di firewall. Oleh karena itu, langkah selanjutnya kami akan memberikan panduan instalasi UFW.
Install UFW
Uncomplicated Firewall (UFW) merupakan kumpulan perintah yang digunakan untuk konfigurasi iptables di Ubuntu. UFW sudah tersedia di Ubuntu dan secara default sudah terinstall di dalamnya.
Untuk melakukan instalasi UFW, gunakan perintah berikut.
sudo apt-get install ufw
Setelah itu, berikan izin pada traffic HTTP dan HTTPS agar bisa melewati firewall
sudo ufw allow http
sudo ufw allow https
ufw –help
sudo systemctl restart nginx
sudo systemctl status nginx
sudo apt install mariadb-server
sudo mysql_secure_installation
Keempat, Anda akan diminta untuk membatasi akses root dari localhost saja. Ini untuk memperkecil kemungkinan orang lain menebak kata sandi root Anda. Klik Y untuk membatasi root di localhost.
sudo mariadb
GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'admin1234' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;
mariadb -u admin -p
sudo apt install php-fpm php-mysql
https://www.niagahoster.co.id/blog/cara-install-wordpress-menggunakan-nginx-di-centos-7/
https://www.niagahoster.co.id/blog/cara-install-wordpress-menggunakan-nginx-di-ubuntu/
https://www.niagahoster.co.id/blog/cara-install-lemp-di-debian/
https://langittutorial.blogspot.com/2017/12/cara-install-dan-menggunakan-respin-remastering-tool-ubuntu-16.html
https://storage.googleapis.com/kubernetes-release/release/stable.txt
https://musaamin.web.id/cara-install-dan-setting-xampp-for-linux/
https://musaamin.web.id/cara-install-dan-setting-xampp-for-linux/
https://langittutorial.blogspot.com/2017/12/cara-install-dan-menggunakan-respin-remastering-tool-ubuntu-16.html
https://musaamin.web.id/cara-install-nextcloud-client-ubuntu/
https://musaamin.web.id/cara-install-nextcloud-client-ubuntu/
https://musaamin.web.id/cara-install-mysql55-ubuntu1804/
groupadd mysql
useradd -g mysql mysql
tar xzvf mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.5.62-linux-glibc2.12-x86_64 /usr/local/mysql
cd /usr/local/mysql
chown -R mysql:mysql *
Install paket dependensi libaio1.
apt install libaio1
scripts/mysql_install_db --user=mysql
cp support-files/my-medium.cnf /etc/my.cnf
Copy file konfigurasi service mysql-server.
bin/mysqld_safe --user=mysql &
cp support-files/mysql.server /etc/init.d/mysql.server
bin/mysqladmin -u root password 'rahasia'
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
reboot
update-rc.d -f mysql.server defaults
/etc/init.d/mysql.server start
/etc/init.d/mysql.server status
mysql -u root -p
https://www.youtube.com/c/musaamin/videos
https://www.youtube.com/c/musaamin/videos
install lampp
sudo /opt/lampp/lampp start
Starting XAMPP for Linux 7.2.18-1...
XAMPP: Starting Apache...fail.
XAMPP: Another web server is already running.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.
sudo systemctl stop apache2
sudo systemctl disable apache2
sudo systemctl stop mysql
sudo systemctl disable mysql
File konfigurasi XAMPP:
Apache configuration file: /opt/lampp/etc/httpd.conf, /opt/lampp/etc/extra/httpd-xampp.conf
PHP configuration file: /opt/lampp/etc/php.ini
MySQL configuration file: /opt/lampp/etc/my.cnf
ProFTPD configuration file: /opt/lampp/etc/proftpd.conf
Direktori penting XAMPP:
Direktori Document Root: /opt/lampp/htdocs
Direktori database: /opt/lampp/var/mysql
Direktori konfigurasi: /opt/lampp/etc
cd /opt/lampp/htdocs
sudo mkdir webku.com
sudo chown $USER.$USER webku.com
sudo gedit /opt/lampp/etc/httpd.conf
# Virtual hosts
#Include etc/extra/httpd-vhosts.conf
TO.....
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
Selanjutnya buka file konfigurasi virtual hosts httpd-vhosts.conf .....
sudo gedit /opt/lampp/etc/extra/httpd-vhosts.conf
Before ...
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/opt/lampp/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/opt/lampp/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
AFTER ...
<VirtualHost *:80>
ServerName localhost
DocumentRoot /opt/lampp/htdocs
ErrorLog "logs/localhost.error.log"
CustomLog "logs/localhost.access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerName webku.com
DocumentRoot /opt/lampp/htdocs/webku.com
ErrorLog "logs/webku.com.error.log"
CustomLog "logs/webku.com.access.log" common
</VirtualHost>
sudo gedit /etc/hosts
127.0.0.1 webku.com
sudo /opt/lampp/lampp reloadapache
https://musaamin.web.id/cara-install-dan-setting-xampp-for-linux/
https://musaamin.web.id/cara-install-dan-setting-xampp-for-linux/
https://musaamin.web.id/cara-install-sistem-informasi-desa-opensid-di-ubuntu-18-04/
https://musaamin.web.id/cara-install-sistem-informasi-desa-opensid-di-ubuntu-18-04/
sudo apt install apache2 -y
cd /etc/apache2/sites-available
sudo nano desaindah.id.conf
<VirtualHost *:80>
ServerName www.desaindah.id
ServerAlias desaindah.id
DocumentRoot /var/www/desaindah.id
<Directory /var/www/desaindah.id>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/desaindah.id.error.log
CustomLog /var/log/apache2/desaindah.id.access.log combined
</VirtualHost>
sudo a2ensite desaindah.id.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
sudo systemctl status apache2
cd /var/www
sudo mkdir desaindah.id
sudo nano desaindah.id/test.html
sudo rm /var/www/desaindah.id/test.html
sudo apt install php php-common php-mysql php-gd php-cli libapache2-mod-php -y
sudo apt install mariadb-server mariadb-client -y
sudo mysql_secure_installation
Enter current password for root (enter for none): ENTER
Set root password? [Y/n] y
New password: PASSWORD_ROOT
Re-enter new password: MASUKKAN_ULANG_PASSWORD_ROOT
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
sudo mysql -u root -p
create database opensid;
create user 'user_opensid'@'localhost' identified by 'pass_opensid';
grant all privileges on opensid.* to 'user_opensid'@'localhost';
flush privileges;
wget https://github.com/OpenSID/OpenSID/archive/v19.07.zip -O OpenSID-v19.07.zip
unzip OpenSID*.zip
sudo cp -Rv OpenSID-19.07/* /var/www/desaindah.id/
cd /var/www/desaindah.id
sudo cp -Rv desa-contoh desa
sudo chown -R $USER:www-data ../desaindah.id
sudo chmod -R 775 ../desaindah.id
mysql -u user_opensid -p opensid < desaindah.id/contoh_data_awal_20190701.sql
nano desa/config/database.php
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'user_opensid';
$db['default']['password'] = 'pass_opensid';
$db['default']['database'] = 'opensid';
Akses laman admin OpenSID http://desaindah.id/index.php/siteman, username = admin, password = sid304.
https://github.com/OpenSID/OpenSID
https://github.com/OpenSID/OpenSID/wiki
https://demo.opensid.or.id/
https://www.facebook.com/groups/opensid
https://www.howtoforge.com/tutorial/ubuntu-lts-minimal-server/
https://www.howtoforge.com/tutorial/ubuntu-lts-minimal-server/
https://www.howtoforge.com/ubuntu_lamp_for_newbies
sudo apt-get install apache2
http://localhost/
sudo apt-get install php5 libapache2-mod-php5
sudo /etc/init.d/apache2 restart
sudo gedit /var/www/testphp.php
<?php phpinfo(); ?>
sudo apt-get install mysql-server
gksudo gedit /etc/mysql/my.cnf
bind-address = 127.0.0.1
mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
gksudo gedit /etc/php5/apache2/php.ini
;extension=mysql.so
extension=mysql.so
sudo /etc/init.d/apache2 restart
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mariadb-php-lamp-stack-debian9
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mariadb-php-lamp-stack-debian9
sudo apt update
sudo apt install apache2
sudo ufw app list
sudo ufw app info "WWW Full"
sudo ufw allow in "WWW Full"
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
sudo apt install curl
curl http://icanhazip.com
sudo apt install mariadb-server
sudo mysql_secure_installation
sudo mariadb
GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
mariadb -u admin -p
sudo apt install php libapache2-mod-php php-mysql
sudo nano /etc/apache2/mods-enabled/dir.conf
/etc/apache2/mods-enabled/dir.conf
<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>
sudo systemctl restart apache2
apt search php- | less
apt show package_name
apt show php-cli
sudo apt install php-cli
sudo apt install package1 package2 ...
sudo nano /var/www/html/info.php
http://your_server_ip/info.php
sudo rm /var/www/html/info.php
https://medium.com/@dataq/instalasi-linux-apache-mysql-php-lamp-stack-pada-ubuntu-16-04-b243d3048b35
https://medium.com/@dataq/instalasi-php-apache-module-pada-ubuntu-16-04-481d288a909d
https://medium.com/@dataq/instalasi-apache-dan-php-fpm-pada-ubuntu-16-04-cd8900b5d529
1. Instalasi Apache
$ sudo apt update
$ sudo apt install apache2
alamat IP atau alamat domain server anda tersebut, misalkan http://mydomain.com/ atau http://104.16.123.127/.
Konfig firewall
sudo ufw app list
sudo ufw app info "Apache Full"
Untuk mengijinkan incoming packet dengan port dan protocol dalam application profile Apache Full, jalankan perintah:
sudo ufw allow in "Apache Full"
Jangan lupa untuk mengijinkan pula incoming packet dengan application profile OpenSSH dengan perintah:
sudo ufw allow in "OpenSSH"
$ sudo ufw status
$ sudo ufw enable
3. Menyembunyikan Informasi Terkait Apache
Menyembunyikan informasi terkait web server Apache, seperti versi Apache dan sistem operasi, sebenarnya bersifat optional karena informasi tersebut bukanlah sebuah vulnerability. Namun menyembunyikan informasi ini adalah langkah pencegahan untuk mempersulit penyerang dalam menemukan vulnerability yang ada pada aplikasi yang terpasang pada server.
Ada dua konfigurasi Apache yang perlu kita ubah, yaitu ServerSignature dan ServerTokens. Bukalah file /etc/apache2/conf-available/security.conf kemudian ubahlah konfigurasiServerTokensmenjadi:
ServerTokens Prod
dan konfigurasi ServerSignature menjadi:
ServerSignature Off
Simpan perubahan tersebut lalu restart service Apache dengan perintah:
$ sudo systemctl restart apache2.service
https://medium.com/tag/web-server
https://medium.com/tag/web-server
https://blog.panoply.io/a-comparative-vmariadb-vs-mysql
sudo apt-get update
sudo apt-get install mysql-server
mysql_secure_installation
mysql -u root -p
https://akaabachi.medium.com/respect-of-the-kill-how-to-properly-terminate-your-linux-processes-99f6025f2e53
$ sudo apt-get update
$ sudo apt-get install mariadb-server
$ sudo mysql_secure_installation
Secara default user root menggunakan unix_socket untuk autentikasi, sehingga kita dapat login menggunakan user root tanpa password. Anda cukup menekan enter ketika anda diminta memasukkan current password for root. Anda juga tidak perlu merubah password root ketika menemui opsi Set root password?. Jawablah tiap pertanyaan pada yang muncul sesuai dengan tingkat keamanan yang anda inginkan. Berikut adalah contoh konfigurasi yang saya rekomendasikan:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.Enter current password for root (enter for none):
OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.Set root password? [Y/n] n
... skipping.By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.Remove anonymous users? [Y/n] Y
... Success!Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] Y
... Success!By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.Remove test database and access to it? [Y/n] Y
- Dropping te