2 | How to Install a Local Server for PHP | 2023 | Learn PHP Full Course for Beginners
Summary
TLDRThis video tutorial guides viewers on setting up a local server for PHP development using XAMPP, a popular and easy-to-install software. It addresses common concerns about server installation and reassures viewers of its simplicity. The tutorial covers downloading XAMPP from apachefriends.org, installing it on Windows, and configuring it to run PHP and MySQL services. It also demonstrates creating a new PHP file in Visual Studio Code, setting the PHP executable path, and testing PHP code execution on a local server, concluding with a teaser for the next video on PHP syntax.
Takeaways
- π Setting up a local server is essential for developing websites using PHP and should not be intimidating.
- π οΈ There are various server software options available such as LAMP, VAMP, XAMPP, and WAMP.
- π The tutorial recommends using XAMPP (Apache, MySQL, PHP, Perl) for its ease of setup and familiarity.
- π» XAMPP can be downloaded from apachefriends.org, offering versions for Windows, Linux, and macOS.
- π₯ Download and install the appropriate XAMPP version for your operating system, ensuring to note the installation location.
- π§ After installation, configure the XAMPP control panel and start the Apache and MySQL services to run PHP locally.
- π The 'htdocs' folder in XAMPP is where you can create and manage your local websites.
- π Access your local server by typing 'localhost' in your browser to view the default XAMPP page or your PHP websites.
- π¬ PHP files can be created by renaming HTML files to '.php' and can contain both HTML and PHP code.
- π₯οΈ If using Visual Studio Code, ensure PHP is set up correctly by configuring the PHP executable path in settings.
- π PHP code within a PHP file can be executed on the server, as demonstrated by the 'echo "Hello World";' example.
Q & A
What is the purpose of installing a local server on your computer for PHP development?
-Installing a local server allows you to run a website using PHP on your computer without uploading it to the internet, making it easy to work on your website offline.
Why might some people be scared of installing a server on their computer?
-Some people might be scared due to misconceptions about the complexity or potential risks of installing a server, but the script clarifies that setting up a server is a common and straightforward process in web development.
What are some of the different server software options mentioned in the script?
-The script mentions LAMP, VAMP, XAMPP, and LIMP as different server software options available for setting up a local server.
Why does the speaker recommend using XAMPP for setting up a local server?
-The speaker recommends XAMPP because it's easy to set up and they have been using it for many years, making them comfortable with its functionality.
How can one obtain XAMPP for setting up a local server?
-XAMPP can be downloaded from the Apache Friends website, and the script provides a link to the website for easy access.
What are the two services that need to be running in XAMPP to get PHP working?
-The two services that need to be running are the Apache server, which runs PHP, and the MySQL server, which provides access to the database.
Where should the 'htdocs' folder be located in relation to the XAMPP installation directory?
-The 'htdocs' folder should be located within the XAMPP installation directory, typically found in the C drive or a specified installation directory.
What is the significance of the 'localhost' URL when working with a local server?
-Typing 'localhost' in the browser URL directs you to the default page served by the local server, which in the case of XAMPP, is the 'htdocs' folder where your websites are stored.
How can you create a new website within the XAMPP server?
-You can create a new website by creating a new folder within the 'htdocs' directory and then adding PHP files to it, which will be accessible via the 'localhost' URL with the folder's name.
What is the difference between creating a PHP file and an HTML file when setting up a website?
-While both PHP and HTML files can contain HTML code, PHP files allow for the execution of PHP code, which can dynamically generate content for the website.
Why might Visual Studio Code show a 'cannot validate' message when working with PHP?
-Visual Studio Code may show a 'cannot validate' message if it cannot find the PHP executable path. This can be resolved by manually setting the path to the PHP installation within the editor's settings.
Outlines
π» Setting Up a Local Server for PHP Development
The paragraph discusses the process of setting up a local server on a computer to develop websites using PHP. It reassures users that installing a server is safe and common practice among web developers. The narrator introduces various server options like LAMP, MAMP, XAMPP, and WAMP, and mentions Docker. The chosen server for the tutorial is XAMPP due to its ease of setup and familiarity. The tutorial guides users to download XAMPP from apachefriends.org, select the appropriate version for their operating system, and install it on their computer. It emphasizes the importance of noting the installation location and provides a step-by-step guide through the installation process, including handling potential pop-ups and setting up the server to run PHP and MySQL services.
π Creating and Configuring a PHP Website Locally
This paragraph explains how to create and configure a PHP website using the XAMPP server. It details the process of deleting the default files in the 'htdocs' folder and creating a new folder for the user's website. The narrator demonstrates how to access the local server through the browser by typing 'localhost' and shows how to create multiple websites within the server. The tutorial then moves on to setting up the website in a preferred code editor, such as Visual Studio Code, and creating an 'index.php' file. It highlights the difference between HTML and PHP files and provides a solution for a common issue where Visual Studio Code might not recognize the PHP installation, guiding users to manually set the PHP executable path within the editor's settings.
π§ Testing PHP Code and Preparing for Further Tutorials
The final paragraph demonstrates testing PHP code by writing a simple 'echo' statement within PHP tags in an HTML file. It shows how to save the file, refresh the website in the browser, and see the output 'hello world', confirming that the PHP server is running correctly. The paragraph concludes by mentioning that the next video will cover PHP syntax, allowing users to write PHP code effectively within their websites. The tutorial ends on a positive note, expressing gratitude and anticipation for the continuation of the learning process.
Mindmap
Keywords
π‘Local Server
π‘PHP
π‘XAMPP
π‘Apache Server
π‘MySQL Server
π‘LAMP Stack
π‘Docker
π‘localhost
π‘Visual Studio Code
π‘PHP Syntax
Highlights
Installing a local server is essential for setting up a PHP website.
Local server installation is a common practice among web developers and should not be feared.
Various server software options exist, such as LAMP, VAMP, XAMPP, and LIMP.
Docker is another method mentioned for setting up a server environment.
XAMPP is chosen for its ease of setup and familiarity to the presenter.
ApacheFriends.org is a resource for downloading the XAMPP server software.
XAMPP allows running a PHP website locally without uploading to the internet.
Different versions of XAMPP are available for Windows, Linux, and Mac.
The installation process for XAMPP is straightforward and quick.
It's important to note the installation location for future configuration changes.
After installation, the XAMPP control panel can be accessed to start the Apache and MySQL services.
Docking the XAMPP control panel for easy access is recommended.
The htdocs folder in XAMPP is where websites are created and managed.
Creating a new folder in htdocs allows for the setup of a new local website.
PHP files can be created by changing the extension from .html to .php.
Visual Studio Code may require manual configuration to recognize the PHP executable.
A PHP file allows for both HTML and PHP code, maintaining website functionality.
The presenter demonstrates creating a simple PHP file that outputs 'Hello World'.
Next steps include learning PHP syntax for proper website development.
Transcripts
so in order to set up a website using
PHP we have to install what is called a
local server and there's a lot of
different software out there in the
internet that you can get in order to
install a local server on your computer
I do know that some people are a little
bit scared when it comes to installing a
server on your computer and I just want
to point out that there's nothing to be
scared of everything is going to be fine
and you're not going to install any sort
of viruses anything setting up a server
is something that is actually quite easy
to do and anyone that does websites do
it quite frequently so it's not
something that new people should be
scared of doing it's something that
takes a couple of minutes to do and then
you have something running on your
computer so when it comes to installing
a server there's many different servers
you can choose from you have lamp Vamp
xampp limp there's many different kinds
of servers I did also hear about
something called Docker from one of my
subscribers in the last video so it's
just interesting to see that there's so
many different ways to do it what we're
going to use however is a server called
exam and the argument I have for using
exam is that it's easy to set up and
it's the one I've been using for many
years I'm just really comfortable using
exam amp so going inside your computer
you can see that we have this website
here that I just found called
apachefriends.org I'll go ahead and
leave a link to it so you can actually
see it on screen here basically this is
just going to be a piece of software
that you're going to download that we're
going to start and then it's going to
run our server on our computer this
means that we can actually run a website
that is using PHP on our computer
without having to upload our website to
the Internet so this makes it very easy
to just work on our website offline on
our computer just like if it were to
just make a HTML website as you can see
we have a couple of different versions
We can install in here we have for
Windows Linux and mac and you can also
see what version we're going to install
in this case here this is going to be
release 8.2.0 which is the PHP version
that we're going to run on This Server
here so once you've figured out what
operating system you're sitting on I bet
you probably know already you're going
to go and click the button for that one
so I'm going to click windows then it's
going to install the program for you and
if it doesn't you're just going to go
ahead and click up here where it says
click here
then we're going to accept the Privacy
pop-up and then we're just going to go
and download the latest version which is
8.2.0 so we have the latest version of
PHP here so I'm going to go and download
it now once you have it downloaded
you're just going to go ahead and double
click it so we can make sure to install
it on our computer and it is important
that you take note of where exactly you
are installing it since we will have to
go in and do a couple of changes to it
now if you do get a pop-up like this
don't worry too much about it since this
is only going to be relevant if we were
to install this inside our program files
inside our main drive so with that I'm
just going to click OK and then we're
going to choose where we want to install
this program so we're going to make sure
all these are ticked on and then I'm
going to click next then I'm going to
select where I want to install this now
as you can see I have it inside my C
drive but not inside my program file so
I can just go and install it directly on
the C drive so I'm just going to go and
do that click next then I'm going to
choose a language in this case it's
going to be English
and then we can just go ahead and make
it set up our program on our computer so
it's just going to unpack and install
now if you do insist that you want to
install this inside your program files
then I do have a link in the description
where you can go in and actually make
sure there's no warnings popping up when
you try to run this program inside the
program files but like I said if you
just installed it directly inside the C
drive like I did here we're not going to
have any sort of issues now once you
have it installed it's going to ask if
you want to start the control panel now
if you want to wait with later for now
let's just go ahead and not do that
because I do want to show where exactly
this is installed so you can just open
it up from inside your computer so with
that I'm going to click finish and then
you're going to go into a installed
xampp which is inside in my case the C
drive so I'm going to go into this PC
inside my C drive then I'm going to go
down to the bottom here and then you can
see I have X amp inside the XM folder
we're going to have the actual server
files which means that we can scroll
down to the bottom and actually run this
control panel that we were just asked
about so we can just go and click the
xamppdashcontrol.exe open it up and then
you can see we have a little software in
here now the important thing for you to
know about in here is that we have two
services that we need in order to
actually get PHP working one is going to
be the Apache server which is the one
that we need in order to actually run
PHP and the second one is the MySQL
server which is used in order to get
access to our database so what I can do
is I can start these two and then you
can see we have them running another tip
that I have for you is to make sure that
you go down and actually dock this at
the bottom since this is the program
you're going to have to start every
single time you need to start working on
your website this means that we need to
go down actually dot get or pin it to a
taskbar so you have easy access to it
next time with this running we now need
to set up our website inside This Server
here which is very easy to do so we're
going to go back inside our folder where
we have X amp installed and then you're
going to go up to the top here and then
you're going to go inside the folder
called 8T Docs
now in here you're going to find a bunch
of files and these are just mainly to
welcome you into the XM software so if I
were to go inside my browser here and
inside the URL I'm going to type
localhost and then you can see we get
this little website here and this is
basically what we see with these files
inside the HC docs folder this is
basically what this is so we don't
really need to have this so what I can
do is I can go back inside our folder
then I'm just going to delete all the
files that we have in here now the
important thing for you to know about
this folder here is that this is going
to be the place where you start creating
your websites every time you want to
create a new website inside This Server
here so what we can do is we can go and
create a new root folder so I'm going to
right click and say I want to create a
new folder I can call this one my
website just to give it some kind of
name of course you're more than welcome
to call whatever you want it to be but
in my case I'm just going to call it my
website
and now what you're going to notice is
that inside the browser I can go back
inside and type localhost and then you
can see we get a list of all the
different websites that I have inside
this folder here this means that if I
were to create a second website go in
here create a second one my second
website then you can see if I were to
refresh in here we now have a new
website that we can open up using this
server here so if I were to click my
website you can now see that we have
this website open so going inside your
preferred editor in my case this is
going to be Visual Studio code I'm going
to go ahead and create my first file
which means that I'm going to save this
file inside this folder that I just
created a very good advice for you is to
go inside and actually dock the HD docs
folder on the side over here so I have
quick access to it so what I can do is I
can go ahead and go inside find xampp
take my HD docs folder and dock it over
here in the side so in this sort of way
I have quick access to it whenever I
have to open my folders here so I can
click it go in here let's just go and
delete that second website since we
don't have actually need it I'm going to
go inside my root folder and create a
index dot PHP now this is the moment
where some people are going to get
confused if it came directly from my
HTML course because when it comes to PHP
we want to make sure that instead of
creating HTML files we create a PHP file
the main difference here is that we
actually allow for PHP to be run inside
these files here you can still write
HTML just like you can before so you
don't need to freak out about your
website breaking or anything like that
or not being able to write HTML inside
these files just because it's called dot
PHP and the same thing goes if you have
an existing website that you want to
convert into a PHP website you can just
take all the different HTML files that
you have and just change the extension
from HTML to PHP on those and it's going
to work inside your server and it's not
going to break anything by the way I
should say that because some people do
worry that it is going to break
something so I have to say it with this
file here I'm going to save it and then
you can see we have this front page here
so if I were to go back inside my
website I can refresh my website and
then you can see we get a completely
blank page and that's because right now
we have the index file running inside
our server now depending on the editor
you're using because in some cases the
editor is just going to work straight
away but if you are using visual studio
code it may ask you something down here
at the bottom it says cannot validate
since a PHP installation could not be
found this is a very typical thing when
you have a new version of Visual Studio
code so if you have not set up PHP
already inside this software you are
going to have to set it up manually
inside this text editor here so what you
can do if you were quick enough is to
make sure you opened up the link it gave
you if not then we're going to go up
into file go down to preferences go
inside your settings then you're going
to click on extensions and then you're
going to go down to PHP and from in here
you can actually set it to where you
want to have the executable path set up
inside a Json file so go to click this
you can now see that we have this one
line called
psp.validate.executable path and this is
where we need to set in the link for our
PHP installation which is again inside
the exam folder so if I were to go back
inside the exam folder go back you can
see we have a folder in here called PHP
so I'm going to click it and then you
can see we have a PHP dot exe file down
here at the bottom this is the one we
need to link to inside this executable
path inside Visual Studio code so what I
can do is I can copy my path here go
back inside paste it inside the double
quotes and then we're going to write
backslash PHP dot exe now if you copied
the path directly like I did here you
want to make sure these are not
backslashes but instead forward slashes
otherwise you're going to get an error
message
and once you did this you're just going
to go and save the file and then you can
close it down and now we have it set up
so that we can actually find the PHP
version that we're using once we start
creating a PHP website so just to kind
of test this out let's go ahead and
start up a regular HTML website now I'm
just going to zoom in for you so you can
actually see what is going on here and
what I'm going to do is I'm going to go
inside the body tags and create a pair
of PHP tags which we use in order to
write PHP inside a website so what I can
do is I can write angle bracket question
mark PHP question mark angle bracket and
then anything that goes in between here
is going to be considered as PHP so just
to follow a very popular tradition here
let's go ahead and go inside and write
Echo
double quotes hello world
close it off with a semicolon save it go
inside our website
refresh it and then you can see we get
hello world so with that we now know
that we have a server running so we can
actually write PHP code inside our
website and have it display inside the
browser and with that in the next video
we're going to talk a bit about PHP
syntax so we can actually write PHP
properly inside our website so hope you
enjoyed and I'll see you in the next
video
[Music]
thank you
[Music]
Browse More Related Video
How To Install PHP & What Are Web Servers - PHP 8 Tutorial
4 | PHP Variable and Data Type Tutorial | 2023 | Learn PHP Full Course for Beginners
Docker Setup for Local WordPress Development
KhoΓ‘ hα»c lαΊp trΓ¬nh PHP&MYSQL - BΓ i 48: Upload File PHP
PHP For Beginners, Ep 5 - Conditionals and Booleans
PHP For Beginners, Ep 3 - Your First PHP Tag
5.0 / 5 (0 votes)