How to install apache php and mysql on windows 7 with cygwin.

How To set up your PHP Server at home on Microsoft Windows.

Get Cygwin from Cygwin.com and install it with httpd (Apache webserver) and also get your httpd-php module from the Cygwin installer for free. Free software is the source of internet technologies that the big tech companies copy and sell.
Pro-Tip:: a. You’ll probably need to add to your bashrc the “Set path=$path;/usr/sbin” line to allow your bash shell to type "httpd" and start the webserver. To shut the webserver down you can find the program "apachectl" (apache control.)

2) Get your Apache server to run.

You can use.bashrc alias to shortcut httpd “ –f “ F flag to set up your customized httpd.conf. You’ll need to edit the httpd.conf file to do:
  1. Httpd has a root directory where it’s server files go. This is in /etc/httpd
  2. Httpd has a Servername (127.0.0.1)
  3. Httpd also has a ServerRoot so set that to somewhere in your Home (~/) I suggest apache.
  4. Httpd also has a DocumentRoot, this is where the www.myweb.com/index.htm will be. So that’s like the root. I suggest ~/apache/docroot.
  5. Just follow the errors until ps shows httpd is running in the background.
  6. I have to chmod 777 my /var/run files. So that httpd could edit that .pid file.
  7. Edit the LoadModule to include php7_module libphp7.so
  8. Edit the SetHandler .php files for that x-http-php module (look it up)
    • <FilesMatch \.php$>
    • SetHandler application/x-httpd-php
    • </FilesMatch>
More info at tecmint.com/install...

Test your new server

To see if your webserver is up, place a “index.html” file in the DocumentRoot folder, and then in your computer’s webbrowser visit http://localhost:80/

troubleshooting the server

If ps (task manager) shows httpd is running, and your httpd.conf file has your correct local IP (found by running "ipconfig"). The problem is your firewall.
Try:
  • Configure your firewall
    1. Set the application httpd.exe in /usr/sbin to be allowed to use the thing.
    2. Set the inbound and outbound rules to allow httpd on port 80.
  • Disable your firewall. (I did this and it worked fine because the house LAN is behind the router firewall. )

Now your web server is operational.

And you can use .php files with <?Php code. For free , not a cent dropped. and all on your Windows, with Cygwin.

Now you need to enable MySQL to give your website some long-term memory.

For that you need to get Cygwin installer to install:
  1. mysql-server (MariaDB) (mysqld)
  2. and php_mysqli extension.
  3. And mysql (the client)

Install MySQLd

Next look in /usr/bin/ and install the mysqld with “mysql_install_db”
Now you can start the mysqld server anytime with the script “/usr/bin/mysqld_safe &”

troubleshooting the mysqld at first

You might want to permit yourself with "chmod 777" the entire folder /var/lib/
Then you might want to run “mysql_secure_installation” only once… Now you can look at the test DB by using “mysql -uroot” and use the MySQL query "SHOW DATABASES;"

Now you're ready to learn MySQL and learn PHP at home.

To learn MySQL, first on the curriculum is

  1. Entity Relationship diagrams. A Database that stores tables is called an entity. When you can organize an entity (school or business) into tables (clients, students, teachers, subjects) and then each table into entries (rows) and types (columns). Example the table is called students. Each row on the table is a person. Each person has a name and age. Another table is teacher. Each row is a person , and each person has a subject and a surname . Then you can draw the database and have a clear idea of the relationship between tables (such as between student and subject and teacher. )
  2. You can edit the way mysqld runs by editing /etc/my.cnf.d/server.cnf but if your php has trouble connecting use the proper IP address and leave the user and password blank. Atleast for your root at home trials.
  3. You should run through the QUERY commands with mysql. And get to read the documentations on www.php.net/class.mysqli
  4. 4) All of the SQL ‘commands’ are lumped into three topics: data manipulation language. Data definition language (DDL), data control language.
  5. Here is one blog that is particularly clear

To learn PHP, well it’s just like a programming language for server side changes to your pages. Before the server sends the page through http ip to your browser.

How to learn php for free?

https://www.w3schools.com/php/default.asp I got some $50 for lifetime subscription to programming hub app with spelling mistakes and jokes.

What to do to get your php and mysql pages running

  1. On your Cygwin run the background server “mysqld &” and then start up your httpd server.
  2. To test, start your “mysql” client, and if it connects, type in “SHOW DATABASES;” or “Status”
  3. On your test.php page first you’ll want to connect with :
    • a. $b = new mysqli(‘192.168.1.69:3305’, ‘user’,’password’,’databasename’);
    • b. To find the issue you can use $b->connection_errno() with $bmysqli->connection_error(); Your mysql wont work until you use the actual MySqlD and MySql client, with “mysql –uroot” and learn to create databases and revoke users. Then you can create the details needed for ‘user’ ‘asswork’ ‘databasename’
  4. Next you can start client “mysql –uroot” this puts the client in the server’s root user , and now you can have ‘system admin’ privileges.
    1. a. Type in “SHOW PRIVILEGES;” to show who has what privilege.
  5. b. Type “CREATE USER ‘Bobette’@’localhost’ IDENTIFIED BY’password’;” to create the user. Now your clients (php pages) can log in with a user “Bobette” and be more securer and actually do things like create a database or create a table, etc.
  6. Then “CREATE DATABASE okramemory;”
  7. Then “GRANT ALL PRIVILEGES ON okramemory.* TO Bobette@localhost IDENTIFIED BY ‘password’;
  8. Now, you have a database with users, you can test if the php connection is made by the line $b = new mysqli(‘localhost’, ‘Bobette’, ‘password’, ‘okramemory’);
  9. Now you have full control of MySQL queries. You can use $b->query(“create table okracurry”) to make your own table.
  10. g. But you will want to use mysql->prepare to use the safer web-safe ‘prepared statements’ which allow you to use data inputted via the internet without excess checking for any funny business.

Comments

Popular posts from this blog

The smallest ℝeal number in Mathematics and Αlpha and Ωmega

Jesus' "love your neighbour as yourself" law and Calculus integration.

Prompt-driven Programming