0% found this document useful (0 votes)
13 views5 pages

Setup Mysql As Usual

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

Setup Mysql As Usual

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

SETUP MYSQL, APACHE, AND PHP.

SETUP MYSQL AS USUAL.

1. download Apache:
 Go to the Apache Lounge website and download the latest version of Apache HTTP
Server.
2. Extract Apache:
 Extract the downloaded ZIP file to a directory of your choice (e.g., C:\Apache24).
3. Configure Apache:
 Open the C:\Apache24\conf\httpd.conf file in a text editor.
 Find the ServerRoot directive and set it to the directory where you extracted Apache,
e.g., ServerRoot "C:/Apache24".
 Find the DocumentRoot directive and set it to your desired web directory, e.g.,
DocumentRoot "C:/Apache24/htdocs".
 Adjust the Directory directive to match the DocumentRoot

<Directory "C:/Apache24/htdocs">
...
</Directory>

Install Apache as a service:


 Open a Command Prompt with Administrator privileges.
 Navigate to the bin directory of your Apache installation, e.g., cd C:\Apache24\bin.
 Run the following command to install Apache as a service:

httpd.exe -k install

Start Apache:
 You can start Apache by using the Command Prompt
httpd.exe -k start
1. Open the Apache Configuration File:
SETUP MYSQL, APACHE, AND PHP.

 Locate the httpd.conf file in the Apache conf directory (e.g., C:\Apache24\conf\
httpd.conf).
 Open the httpd.conf file in a text editor such as Notepad.
2. Set the ServerName Directive:
 Search for the ServerName directive in the httpd.conf file. It might be commented out
by default.
 If the directive is commented out (preceded by a #), uncomment it by removing the #.
 Set the ServerName directive to localhost or to your server’s domain name if you have
one. For example:

ServerName localhost

1.
 If the ServerName directive does not exist, you can add it anywhere in the httpd.conf
file. A good place to add it is near the top, just below the ServerRoot directive.
2. Save the Configuration File:
 Save the changes to the httpd.conf file and close the text editor.
3. Restart Apache:
 Open a Command Prompt with Administrator privileges.
 Navigate to the Apache bin directory (e.g., C:\Apache24\bin) and run the following
command:

httpd.exe -k restart

1. Download PHP:
 Go to the PHP for Windows website and download the latest thread-safe version of PHP.

1. Extract PHP:

 Extract the downloaded ZIP file to a directory of your choice, such as C:\
php.
SETUP MYSQL, APACHE, AND PHP.

2. Configure Apache to Use PHP:

 Open the Apache configuration file httpd.conf located in the conf directory
of your Apache installation, e.g., C:\Apache24\conf\httpd.conf.
 Add the following lines to the end of the httpd.conf file to configure PHP
with Apache

# PHP configuration
LoadModule php_module "C:/php/php8apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "C:/php"

 Adjust the paths if you installed PHP in a different directory.

Edit PHP Configuration:

 Rename php.ini-development to php.ini in the PHP directory ( C:\php).


 Open the php.ini file in a text editor and make any necessary configuration
changes. At a minimum, you may need to set the extension_dir directive to the ext
directory inside your PHP installation, e.g.:

extension_dir = "ext"

Enable necessary extensions by uncommenting the corresponding lines (remove the leading ;), for
example:

extension=mysqli

Restart Apache:
 Restart the Apache server to apply the changes. You can do this from the Services management
console or by running the following command in the Command Prompt with administrator
privileges:
SETUP MYSQL, APACHE, AND PHP.

httpd.exe -k restart

Log in to MySQL:

 Open a Command Prompt and navigate to the MySQL bin directory.


 Log in to MySQL as root:

mysql -u root -p

Create a Database and User Table:


 Execute the following SQL commands to create a database and a table for storing user
credentials:

LOGIN DATABASE CODE

CREATE DATABASE loginDB;

USE loginDB;

CREATE TABLE users (


id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL,
password VARCHAR(255) NOT NULL
);

INSERT INTO users (username, password) VALUES ('testuser', SHA2('testpassword', 256));

 This creates a simple users table with a hashed password for secure storage.
SETUP MYSQL, APACHE, AND PHP.

You might also like