home       inleiding       sysadmin       services       links       bash       werk       nothing      

>> mrt 2018: -6- mysql, wordpress en php

  1. wordpress
    • download wordpress from http://wordpress.org
    • unzip (you get one big directory wordpress)
    • put the entire folder in your Public (the entire directory) with filezilla.
  2. php
    I did not install PHP yet. So I have to install and test this on CentOS7:
    sudo yum install php php-mysql
    I want to test php. Lets put a php source as an index.php in the default website:
    <h2>Today is
    echo date('l jS \of F Y h:i:s A');
    <br /><br />
    <b>So who do you think you are, ...?</b>
    <br /><br />
    // print output
    echo "My name is $hostname but most people call me <b>The Server</b>!";

    I restart httpd on centos
    sudo systemctl restart httpd
    next I test in firefox: http://10.104.xyz.uvw/index.php
    ... and I get this:

    Today is Friday 16th of March 2018 12:36:37 PM
    So who do you think you are, ...?
    My name is cOS74-T06-2 but most people call me The Server!


  3. mySQL
    On the server we need a mySQL client ...
    We can install (the whole bunch) with
    sudo yum install mysql
    Next we install the mySQL server on our separate ubuntu ...
    user@ubu164-S06-1:~$ sudo apt install mysql-server
    don't forget to give a root password ...
    configure the mysql server for access from centOS:
    • edit the file mysql.cnf:
      $ sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
      and comment out the following line ...
      bind-address =
      thus it will become
      # bind-address =
      and save.
      next restart your mysql service ...
      `$ sudo systemctl restart mysql
      test from another machine outside with telnet ...
      user@lap17 ~ $ telnet 3306
      Connected to
      Escape character is '^]'.
      ... 8KAH7mysql_native_password

      The CONNECT proves that your server is listening at port 3306.
      create a user to connect from outside ...
      login to mysql:
      $ mysql -u root -p -h localhost
      Enter password:

      Welcome to the MySQL monitor.  Commands end with ; or \g.
      Your MySQL connection id is 7
      Server version: 5.7.21-0ubuntu0.16.04.1 (Ubuntu)

      mysql> CREATE USER 'wp2'@'' IDENTIFIED BY 'sdf12345';
      Query OK, 0 rows affected (0.00 sec)
       Query OK, 0 rows affected (0.00 sec)
      In the above refers to the machine that will connect to this mySQL-server, or in other words our centOS7 mysql-client.
      test from outside ...
      [student@cOS74-T06-2 html]$ mysql -u wp2 -h -p

      Enter password: 
      Welcome to the MariaDB monitor.  Commands end with ; or \g.
      Your MySQL connection id is 8
      Server version: 5.7.21-0ubuntu0.16.04.1 (Ubuntu)
      Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
      MySQL [(none)]> 

      oh yes, it works ...
      create a database for wordpress
      still logged on (as just tested above ...) type the following
      MySQL [(none)]> create database wordpress4bob;
      Query OK, 1 row affected (0.02 sec)
      remember your useraccount, password, the mysql-server's ip-address and the database name to install wordpress ....
      wordpress on centos
      When you point your browser to wordpress ... you get an install page ...


      click let's go


      fill in the right fields and click submit
      I got 100 times: "The database connection cannot be established ... "
      after looking at many useless advice, the following worked ...
      [student@cOS74-T06-2 wordpress]
      $ sudo setsebool -P httpd_can_network_connect 1
      next i got ...


      and pasted what was asked as user bob in the right file ...

      [bob@cOS74-T06-2 wordpress]$ cd 
      [bob@cOS74-T06-2 ~]$ cd Public/wordpress/
      [bob@cOS74-T06-2 wordpress]$ pwd
      [bob@cOS74-T06-2 wordpress]$ vi wp-config.php

      next i clicked
      Run the installation


      one more click on install wordpress ...
      and i finally got a wordpress site ...