Web server at home.

Started by Hitesh Patel, Jul 04, 2022, 03:23 AM

Previous topic - Next topic

Hitesh PatelTopic starter

I read similar topics, well, nothing new, so I decided to ask for help, I want to create a web server at home to host my site, but not locally.
With general access !! Domain, PHP, mSQL, etc., etc. How to set it up? Help newbie please.


Install CentOS Linux 32/64 bit ,depending on the server parameters, after installation update the OS with the standard repositories already registered by typing the command in the shell under root:
yum update then install the LAMP packages:
yum install httpd httpd-devel httpd-tools mysql mysql-server php php-cli php-common php-gd php-mysql php-xml php-mbstring php-mcrypt then start apache and mysql with the command:
/etc/init.d/httpd start
/etc/init.d/mysqld start

LAMP is ready. Well and read documentation. Good luck.
    The following users thanked this post: Sevad


To create a home server with shared access, you will need a computer with good system characteristics to pull the load, an external IP address, as well as installing and configuring programs with which the server will work. There are a lot of similar instructions on the Internet. There are no easy tips here. You need to figure it out step by step so that in the end the home server works stably and can pull heavy loads.


And I don't understand. What for?
You will need a channel from more than one provider, with good bandwidth, you will need power backup, you will need the server itself. It will take a lot of time to support purely technical issues.
It's easier to use regular hosting, or VPS...


What's the point of bothering so much? If only you want to transfer work to your home?) And so first decide on the axis, if you know Linux, then it's better to do it on it, if not, then take up Windows, but you'll have to work so that it works fine with a lot of simultaneous connections. In general, this is a particularly thankless task.


Installing the Apache web server and PHP language
In order to install a webserver on your computer, you will need some software. All the software that we will use is completely free from birth and is available on the net for free download. This, you see, is good, especially considering that there are very few free programs (especially of such a serious level) for Windows. It's also great that you don't have to download pirated software and surf the net looking for crĐ°cks/serial numbers and the like.

Apache webserver
Apache is a program that acts as an http server. It is with its help that the web server will function. This program performs all the necessary functions, most of the network resources work under its leadership. Ours is no exception, due to the flexibility and versatility of Apache, we will use that particular server. In the future, you will see how easy it is to use this program at home and how wide possibilities it provides. Before you start installing the server, you need to download Apache right away. As a version of Apache, I suggest using 1.3.12, which has a full set of features and at the same time is not complicated by improvements that are unnecessary at that stage. In addition, it is about 2 MB smaller than the newer versions.

PHP programming language
It is that program that will give you the opportunity to use PHP scripts on websites created within the Apache server. As a version, I recommend PHP 4.3.4 as the most promising and stable version. In addition, that version contains rich features compared to the previous ones.

As you can see, both programs are quite large. However, nothing can be done about it, especially since by downloading them once you will save them for a long time and will be able to use them in the future. So, if everything is loaded, you can proceed to the installation.

For the operation of the server and all our further projects, it is advisable to allocate a separate disk on your computer. Of course, you don't have to buy a new hard drive, we'll have enough virtual disk capabilities. What is a virtual disk? This is an imitation of a hard drive in the system. If you are familiar with the possibilities of MS-DOS, then you already understand what I mean. The virtual disk has its own separate name in the system (for instance, the F: drive) and uses a regular directory on the main disk as its root directory. A virtual disk is created with the following MS-DOS command:
subst F: C:\server

Where F: is the name of the virtual drive and C:\server is the folder on the main drive that will be the root directory of the new drive F. Now let's create a new drive. To do this, follow these steps (only for Windows 95-98. See below for how that is done in other versions):

Create a folder "server" on drive C:. Open the "Run" menu in Windows, which is located on the "Start" button and type the line "subst F: C:\server". This should open a window with the root directory of your new drive. Please note that both here and below, I will use the F: drive as the server and the C:\server folder as the root directory of that drive. I strongly advise you to use exactly these parameters so that there is no confusion during installation later. In the following instances, I will assume that everything is set up in that way.

Please note that the virtual disk disappears after a reboot and the subst command must be re-executed. In order not to call this command every time, you need to write it to the autoexec.bat file, which is located in the root directory of the system drive. This file contains a list of all programs that need to be run when the system boots. So, open that file in Notepad and write the following line at the very end:

subst F: C:\server

However, that may not work on some operating systems (eg Windows ME, XP...). This is due to the fact that the autoexec.bat file belongs to the MS-DOS system, and in later versions of Windows it simply does not exist. In this case, do the following. Create a file "subst.bat" and write in it just one, all the same line "subst F: C:\server". Now place that file in the root directory and add its shortcut to startup. This approach will cause the batch file subst.bat to be executed each time Windows starts. But here comes an awkward moment. When you run the file, an MS-DOS emulation window should open in which the file will be executed. It is not very convenient to close that window every time you start the system. So it might be better to run the subst.bat file separately if necessary.

All is ready? Then let's continue with the installation. The first thing we need to do is install the Apache web server. The program you downloaded is an installer and copies all the necessary files by itself. However, everything is not going so smoothly and it will not be enough just to complete all the installation steps. To set up the server exactly the way we want it, let's proceed as follows.

Installing Apache
Run the Apache setup file. After launching the installer, press the "NEXT" and "YES" buttons until the turn reaches the installation path. The default path is "C:\Program Files\Apache Group\Apache". This does not suit us at all - you need to install Apache on a freshly allocated drive F. To do this, click "Browse" and specify the path "f:\usr\apache" (if there is no such directory, the system will ask if you need to create it, to which answer in the affirmative). Why exactly "F:\usr\apache"? The fact is that the "usr" directory on the server is a service directory, lying separately from the directories where website files and other elements of the server are located. The "usr" directory on the server is like the "Windows\System" directory in Windows. You will encounter that directory later when administering your server. Press "NEXT", select "Typical" - the usual installation. We wait a couple more times for "NEXT" and the server is finally installed on our computer, copying the files. All! You have just installed a personal web server on your computer, where you can create an unlimited number of websites with unlimited possibilities.

However, with the creation of websites, we will wait for now. Before that, you still need to install PHP and configure a lot of things in your server settings. This is not difficult - today we will not delve into serious Apache settings (this, by the way, is a topic for a whole book!), We will only perform the actions necessary and sufficient for us to fully operate the home server.

Installing PHP
Let's continue. This is no longer an installer - it's a regular ZIP archive. Create a "php" folder in the same "F:\usr\" directory and unzip it into the resulting "F:\usr\php" directory.

Now look at the contents of the "F:\usr\php" directory. Do you see the php.exe file, along with the ddl, extensions, java, Mibs, etc. folders? Yes? Excellent! Congratulations, PHP is ready to execute your commands. It remains only to introduce Apache to PHP - they, by the way, form a perfectly working pair.

Setting up the Apache server and PHP
Done with software installation. Now let's move on to setting them up. First of all, you need to find the "php.ini-dist" file in the "F:\usr\php" directory and copy it to the C:\Windows folder, and rename it in the new location to the "php.ini" file. As a result, you should get the file "C:\Windows\php.ini". Let's leave it as it is, without changing anything in it, and move on to configuring Apache. Everything is a little more complicated here.

Open the file "F:\usr\apache\conf\httpd.conf" in some text editor, such as Notepad. This is a very important file that contains all your server settings. It requires several parameters to be set. Let's start.

1. Find the line "#ServerName new.host.name" in the httpd.conf file. Change it to the line "Servername localhost". Note that the "#" sign at the beginning of the line is removed.

2. Next find the line "DocumentRoot "f:/usr/apache/htdocs" and change it to "DocumentRoot "f:/project/www". Notice the _missing_ slash at the end.

3. Now find the line "<Directory "f:/usr/apache/htdocs">" and change it to "<Directory "f:/project/www">. The slash is missing again.

4. Also find and change the line "ErrorLog logs/error.log" to the line "ErrorLog F:/project/logs/error.log" and the line "CustomLog logs/access.log common" to "CustomLog F:/project/logs /access.log common".

5. Now go to the very end of the httpd.conf file and enter the following lines into it:

ScriptAlias /php/ "f:/usr/php/" AddType application/x-httpd-php .php .phtml .php4 Action application/x-httpd-php "/php/php.exe"

These lines add to the Apache settings the ability to execute files with the extension .php, .phtml or .php4 as programs written in PHP (PHP scripts).

6. Now create a directory "F:\project", and in it two directories "www" and "logs". As a result, you should get a directory tree like this:

All! Congratulations, you have installed and configured a full-fledged http server with PHP support. Now it's up to the small thing - to learn how to turn the server on and off, as well as test it a little. This is what we will do next.

Working with the Apache server
When installing the server, the installer created a folder called "Apache Web Server" in the Main Menu ("Start" button, then "Programs"). This folder contains several shortcuts. We will need the following ones:

Start Apache - to start the server
Stop Apache - to stop the server

If you wish, you can copy them to the Desktop to be able to quickly start and shut down the server.

We move on and come to the most important moment - starting the server. If you have performed all of the above steps, then you will definitely overcome that stage without problems. But before launching, I would like to suggest that you do one more thing to make sure that your server works.

So, create in the folder "F:\project\www\" a file called "index.html" with the following content:

<head><title>Server Main Page</title></head>
<body bgcolor=#ffffff>
Congratulations, the server is up and running!<br>
Test PHP: <a href="test.php">test.php</a>
Create a file there called "test.php" with the following content:
That's all, finally you can start the server. We solemnly launch the Start Apache shortcut. This opens a black window like an MS-DOS window with a single inscription "Apache/1.3.12 (Win32) running...". This means that the server has successfully started and is currently running. The window does not need to be closed, it is the Apache workbench and is closed using the "Stop Apache" shortcut, which shuts down the server.
So the server is running. What's next? Open your browser and type in the address "". Remember, you do not need to be connected to the Internet at that time! You should see the greeting already typed, i.e. file code "index.html". Follow the link leading to the "test.php" file. What do you see? The browser should output a fairly large file with a bunch of different designations and a proud heading "PHP Version 4.3.4" along with the PHP logo. This is the result of our little "test.php" script, or rather the phpinfo() function we wrote in it. This function displays all the PHP settings installed on the system.

If all that seemed complicated and incomprehensible to you, do not be alarmed. Further it will be much easier, just for the first time it was necessary to install and configure everything in order to work. Now you have the necessary minimum, which is quite enough to successfully start working with the server.

Separately, I want to turn to advanced users who, I'm sure, read (or will read) my article. First of all - if you're not satisfied with the amount of information (and explanations to it) about configuring Apache and various PHP directives - don't blame me too much. My goal in that topic was to provide beginners with a launching pad for their learning and first project. In the future I will try to continue that topic.



You need to download and install Windows Server on your machine, then register a domain, download the programs you need, for the same mySQL, configure them. After actually creating the page, CSS. Then, if you want, you can advertise the site.