Kategorien
Allgemein

Nodejs und NPM auf Centos7 (deinstallieren/installieren)

sudo rm -rf /var/cache/yum
sudo yum remove -y nodejs
sudo rm /etc/yum.repos.d/nodesource*
sudo yum clean all

Nodejs herunterladen

#using this command for Node version 12
curl --silent --location https://rpm.nodesource.com/setup_12.x | sudo bash -

Nodejs installieren

sudo yum -y install nodejs

Kategorien
Allgemein

WordPress Passwort auf Datenbank zurücksetzen

md5.js

const data = "dei neues passwort";
const crypto = require('crypto');
let pw = crypto.createHash('md5').update(data).digest("hex");
console.log(pw);

node md5.js
64cdb8cf6e3e8a848c0b32751ec4def2

Das neue Passwort das nun MD5-Hash generiert ist, kann nun in der WordPress Datenbank direkt eingefügt werden.

Hinweis: Plain-Text Passwörter fünktionieren in WordPress nicht.

Kategorien
Allgemein

Nodejs Server on Centos

1. Apache installieren

sudo yum -y install httpd

2. Bevor wir Apache konfigurieren, machen wir ein Backup der Konfigurationsdatei

cp /etc/httpd/conf/httpd.conf ~/httpd.conf.backup

/etc/httpd/conf/httpd.conf

3. Virtual Host einrichten

Document-Ordner anlegen
sudo mkdir -p /var/www/project/public_html

Eigentümer der Ordners anpassen
sudo chown -R $USER:$USER /var/www/project/public_html

Rechte der Ordner anpassen
sudo chmod -R 755 /var/www


Es gibt mehrere Möglichkeiten Virtuelle Host zu steuern, wir 
arbeiten mit 2 Ordner "sites-available" und "sites-enabled",
um unsere Projekte zu aktivieren oder zu deaktivieren.

sudo mkdir /etc/httpd/sites-available
sudo mkdir /etc/httpd/sites-enabled

Apache soll die Konfiguration kennen
sudo nano /etc/httpd/conf/httpd.conf
Am Ende der apache-conf hinzufügen
IncludeOptional sites-enabled/*.conf
Virtual-Host erstellen
sudo nano /etc/httpd/sites-available/project.conf

<VirtualHost *:80>
 ServerName www.project.com
 ServerAlias project.com
 DocumentRoot /var/www/project.com/public_html
 ErrorLog /var/www/project.com/error.log
 CustomLog /var/www/project.com/requests.log combined
 ProxyRequests off
    <Proxy *>
            Order deny,allow
            Allow from all
    </Proxy>
    <Location />
            ProxyPass http://localhost:<PORT>/
            ProxyPassReverse http://localhost:<PORT>/
    </Location>
</VirtualHost>


Symbolischen Link erstellen in sites-enabled
sudo ln -s /etc/httpd/sites-available/project.conf /etc/httpd/sites-enabled/project.conf

Apache neu starten
sudo apachectl restart

Now let's understand what is going on here. First you're telling Apache to use this given location of the ProxyPass if someone is requesting something from port 80 instead of given them the specific file in your server instead you are redirecting them to the actual IP:PORT which you used to access before

4.  Editieren der /etc/hosts

127.0.0.1 localhost
127.0.1.1 guest-desktop
99.99.99.99 project.de www.project.de

5. Aktivere Apache-Dienste nach dem Booten und Reload der falls  Änderungen gemacht wurden

sudo systemctl enable httpd.service
sudo systemctl restart httpd.service

6. Create Nodejs Server erstellen und dann als Service starten

Create the node.js server whereever you want, perhaps in your Document-Root /var/www/project

const http = require('http');
const hostname = '0.0.0.0'; // listen on all ports const port = 1337;

http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n'); }).listen(port, hostname, () => {
console.log(Server running at http://${hostname}:${port}/`);
});

Create Service File

nano /etc/systemd/system/nodeserver.service

[Unit]
Description=Node.js Example Server #Requires=After=mysql.service # Requires the mysql service to run first

[Service]
ExecStart=/usr/bin/node /opt/myserver/server.js
# Required on some systems
#WorkingDirectory=/opt/nodeserver
Restart=always # Restart service after 10 seconds if node service crashes RestartSec=10
# Output to syslog
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nodejs-example
#User=<alternate user>
#Group=<alternate group>
Environment=NODE_ENV=production PORT=1337

[Install]
WantedBy=multi-user.target

Enable the Service
systemctl enable nodeserver.service
Created symlink from /etc/systemd/system/multi-user.target.wants/nodeserver.service to /etc/systemd/system/nodeserver.service.
Start Service
systemctl start nodeserver.service

Service really started?

systemctl status nodeserver.service

● nodeserver.service – Node.js Example Server
Loaded: loaded (/etc/systemd/system/nodeserver.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2019-12-22 16:20:10 CET; 26min ago
Main PID: 9015 (node)
Tasks: 6
Memory: 8.1M
CGroup: /system.slice/nodeserver.service
└─9015 /usr/bin/node /opt/nodeserver/server.js

Dec 22 16:20:10 vmd20xxx.contaboserver.net systemd[1]: Started Node.js Example Server.
Dec 22 16:20:11 vmd20xxx.contaboserver.net nodejs-example[9015]: Server running at http://0.0.0.0:1337/

Security / testing

Of course this service would run as root, which you probably shouldn’t be doing, so you can edit /etc/systemd/system/nodeserver.service to run it as a different user depending on your system. If you make any changes to the service file, you will need to do a

systemctl daemon-reload

before reloading the service:

systemctl restart nodeserver.service

I always suggest doing a systemctl status nodeserver.service after edits and a restart to ensure the service is running as expected.

Now finally we can test how systemd restarts the process if it unexpectedly dies (thanks Mark for the suggestion). We will manually „kill“ the running process by finding its Process ID (pid), and note how systemd automatically restart it again:

ps -ef | grep server.js     # find the current pid
kill 12345                  # kill the process by its pid reported above
ps -ef | grep server.js     # notice node process is immediately respawned with a different pid

Quelle für Nodejsserver als Service
https://www.axllent.org/docs/view/nodejs-service-with-systemd/

Kategorien
Befehle Mysql,MariaDB

MySQL und MariaDB: User anlegen und Rechte zuweisen

User anlegen und Rechte zuweisen

mysql -u root -p
select * from mysql;
CREATE USER 'newUser'@'localhost' IDENTIFIED BY 'securePassword';
CREATE DATABASE  newDatabase;
GRANT ALL PRIVILEGES ON newDatabase. * TO 'newUser'@'localhost';
FLUSH PRIVILEGES;

User mit Root-Rechten

CREATE USER 'admin'@'localhost' identified by 'securepassword!!!';

GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' with grant option;

FLUSH PRIVILEGES;

exit

service mysql restart
Kategorien
Allgemein

LAMP Installation in Centos

1. Apache installieren

sudo yum -y install httpd

2. Bevor wir Apache konfigurieren, machen wir ein Backup der Konfigurationsdatei

cp /etc/httpd/conf/httpd.conf ~/httpd.conf.backup

/etc/httpd/conf/httpd.conf

3. Virtual Host einrichten

Document-Ordner anlegen
sudo mkdir -p /var/www/project/public_html

Eigentümer der Ordners anpassen
sudo chown -R $USER:$USER /var/www/project/public_html

Rechte der Ordner anpassen
sudo chmod -R 755 /var/www


Es gibt mehrere Möglichkeiten Virtuelle Host zu steuern, wir 
arbeiten mit 2 Ordner "sites-available" und "sites-enabled",
um unsere Projekte zu aktivieren oder zu deaktivieren.

sudo mkdir /etc/httpd/sites-available
sudo mkdir /etc/httpd/sites-enabled

Apache soll die Konfiguration kennen
sudo nano /etc/httpd/conf/httpd.conf
Am Ende der apache-conf hinzufügen
IncludeOptional sites-enabled/*.conf
Virtual-Host erstellen
sudo nano /etc/httpd/sites-available/project.conf

<VirtualHost *:80>
 ServerName www.project.com
 ServerAlias project.com
 DocumentRoot /var/www/project.com/public_html
 ErrorLog /var/www/project.com/error.log
 CustomLog /var/www/project.com/requests.log combined
</VirtualHost>


Symbolischen Link erstellen in sites-enabled
sudo ln -s /etc/httpd/sites-available/project.conf /etc/httpd/sites-enabled/project.conf

Apache neu starten
sudo apachectl restart

4.  Editieren der /etc/hosts

127.0.0.1 localhost
127.0.1.1 guest-desktop
99.99.99.99 project.de www.project.de

 

5. Aktivere Apache-Dienste nach dem Booten und Reload der falls  Änderungen gemacht wurden

sudo systemctl enable httpd.service
sudo systemctl restart httpd.service
Kategorien
Allgemein

Your PHP installation appears to be missing the MySQL extension which is required by WordPress

Nach dem Update auf php 7.0 kommt die besagte Fehlermeldung. Wir haben zwar PHP geupdatet jedoch muss das Paket php-mysql geupdatet werden.

sudo apt-get install php-mysql oder

sudo yum install php-mysql