02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Setting your php ini file for production

Setting your php ini file for production is simple. the first step is we want to locate one that is already configured we will find it in the php project github page. By the end of this lesson your php will be secured and ready for production.

Video Transcript

00:00Okay, so let me go back into the browser.
00:04What I'm gonna do is I'm gonna go to Google
00:06and I'll just type php.ini production.
00:11And it's gonna take me to GitHub
00:14which is exactly where I wanna go.
00:16So I'm just gonna go right into there.
00:18Now by default it's gonna show me the latest,
00:20latest version and currently PHP is already
00:22in PHP version 5.6.
00:24But we wanna make sure that we're gonna download
00:27the configurations that are right for our current build
00:30which were in version 5.33, 5.33.
00:34So I'm gonna click here on the branch master on GitHub
00:38and just scroll through to find the closest version
00:41that we can to 5.33.
00:44So I see it goes up all the way to 5.33.29.
00:49So I'm gonna click away on that.
00:51That works for me.
00:52And that's gonna take me to the version
00:54that was from 2012 which is awesome.
00:57Now I wanna see the raw file
00:59because this is literally the,
01:00and notice by the way, this is the INI production.
01:04We just don't have it on our server.
01:06So all I really have to do is just select everything here
01:08and copy it and paste it into my server as a new file
01:11which we'll do immediately.
01:12But I wanna talk about just one more thing
01:14if I'm already talking about this.
01:15So right we were talking about display errors
01:17to display them or not.
01:19Now if I actually set the display errors up here,
01:22there might be another display error
01:24somewhere down this file.
01:25It's a massive file.
01:26So that's why it's kind of like probably easier also
01:28to do these modifications out of your server
01:32because literally what happened
01:33if I would display errors set to true
01:35but later down the line it's set to false,
01:37to set to off, then we wouldn't see them anyways.
01:40You can see, so one of the stuff that we wanna do
01:42is probably be much easier for us to do these edits locally,
01:46copy the file, have a local version of the file
01:49and then paste it right into our server
01:51once we have everything configured.
01:52So what I'm gonna do now is now that we have
01:54the actual secured file that we wanna have
01:58and if in the future ever at some scenario
02:01we need to change something then we could always go back
02:03and we know how to do it.
02:04So I'm gonna just copy this production file
02:06because it's really the default version for our 3.3
02:10or in our case the server could only show us
02:12all the way up to 5.3.29
02:14which there wouldn't be a major difference between the two.
02:17So I'm gonna go back into my server
02:19and I'm gonna go ahead and rename our php.ini file
02:23by calling the sudo command
02:25and we're gonna call the mv to move the file
02:28and which file we're gonna move,
02:29we're gonna move the etc.php.ini
02:34and where do we wanna move it to?
02:35Let's move it to etc.php.ini dash default.
02:42So that way we're making sure
02:44that we're not getting rid of it completely
02:46and next step is literally what we wanna do
02:48is we wanna go back into that php.ini file.
02:51This time around when we'll get there
02:52it's gonna be completely empty.
02:54I'm gonna move into insert mode.
02:56Now what I wanna do is I wanna paste the file
02:58but don't click on command V
03:00or really your best approach to do that
03:03is right clicking and then pasting
03:06but once we're in insert mode
03:08I'm gonna just right click and then click on paste
03:10but I just wanna make sure
03:11that I really have what I want selected
03:13so I'm gonna select everything here, copy it
03:16and now when I'm back into my server
03:18I'm just gonna right click once we're in insert mode
03:23I'm gonna click on paste.
03:24Now an important note because this is quite a big file
03:28it might take a little bit of time.
03:29Don't worry about it because you're communicating
03:31to a server right now.
03:32It's not a local configuration.
03:34So this could take up to a minute, two minutes.
03:37It might take even more than that.
03:39So what I recommend is just take a breather,
03:41read an article, wait for it to happen,
03:44come back after five minutes, two minutes,
03:46here we go, our file has,
03:48everything has completed pasting inside.
03:51So all that's left for me to do is click on escape
03:54and I'm gonna then click on the colon,
03:56I'm gonna write it in, I'm gonna quit
03:58and now I've updated my php.ini
04:01to be a production ready file.
04:04Now last thing that I have left to do
04:05is to restart my service.
04:07So again, let me just find it.
04:11Here we go, service, HTTP restart
04:15and I'm gonna restart my server and there we go.
04:17That's all we have to do to move our server
04:20into a production level with all the configurations
04:23that PHP recommends that you have on your server
04:26and there you go, okay?
04:30So this is basically making sure
04:33that information is not automatically
04:36exiting your environment.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!