2018年6月6日 星期三

Linux Apache MySQL PHP on CentOS 7.4 (LAMP)


CentOS
cat /etc/*release
CentOS Linux release 7.5.1804 (Core)

EPEL
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
sudo yum -y install epel-release

nano
sudo yum -y install nano

MariaDB
sudo yum -y install mariadb-server mariadb
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
mysql_secure_installation
[Enter] the default empty password
[Y] to set root pasword
[Enter Password]
[Confirm Password]
[Y] to remove anonymous users
[Y] to disallow root login remotely
[Y] to remove test database
[Y] to reload privilege tables to apply changes now

Apache
sudo yum -y install httpd
sudo systemctl start httpd.service
sudo systemctl enable httpd.service
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

Test
http://172.31.118.243/

Remi for PHP 7
sudo rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum install -y yum-utils
sudo yum update -y
sudo yum repolist all | grep PHP
sudo yum-config-manager --enable remi-php72
sudo yum repolist all | grep PHP
sudo yum install -y php php-opcache
sudo systemctl restart httpd.service

PHP File
ls /var/www/html/
sudo nano /var/www/html/info.php
<?php
phpinfo();
http://172.31.118.243/info.php

Support MySQL in PHP
sudo yum search php | grep mysql
php72-php-mysqlnd
sudo yum search php | grep pdo
php72-php-pdo
sudo yum install -y php72-php-mysqlnd php72-php-pdo
sudo yum -y install php-mysqlnd php-pdo
sudo yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel
sudo systemctl restart httpd.service
http://172.31.118.243/info.php

phpMyAdmin
sudo yum install -y phpMyAdmin
sudo nano /etc/httpd/conf.d/phpMyAdmin.conf
[locate <Directory /usr/share/phpMyAdmin/><IfModule mod_authz_core.c>]
[remove <requireAny /> tag, add "Require all granted"]
sudo nano /etc/phpMyAdmin/config.inc.php
[change auth_type from cookie to http]
sudo systemctl restart httpd.service
http://172.31.118.243/phpmyadmin/

Server Side Code

cat b.php
<?php
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
$time = date('r');
echo "data: The server time is: {$time}\n\nretry: 333\n\n";
flush();
?>

cat a.html
<!DOCTYPE html>
<html>
<body>
<h1>Getting server updates</h1>
<div id="result"></div>
<script>
if(typeof(EventSource) !== "undefined") {
    var source = new EventSource("b.php");
    source.onmessage = function(event) {
        document.getElementById("result").innerHTML += event.data + "<br>";
    };
} else {
    document.getElementById("result").innerHTML = "Sorry, your browser does not support server-sent events...";
}
</script>
</body>
</html>

 http://172.31.118.243/a.html



沒有留言:

張貼留言

2023 Promox on Morefine N6000 16GB 512GB

2023 Promox on Morefine N6000 16GB 512GB Software Etcher 100MB (not but can be rufus-4.3.exe 1.4MB) Proxmox VE 7.4 ISO Installer (1st ISO re...