Install Apache Server2.4.17 under Linux system. Let's just say that I'm not going to explain the Linux command because I'm not talking about Linux commands. There is a need to pay attention to the place, I will, nothing worthy of attention, I can not. There is how to upload the compression package to the Linux system, I do not explain, or that sentence: online tutorial too much! Finally, make sure your Linux is connected to the web!
- 1
First of all, in my usual style, take a look at a small section of official documentation:
The following requirements exist for building Apache httpd:
APR and Apr-util
Make sure the APR and Apr-util already installed on your system.
Perl-compatible Regular Expressions Library (PCRE)
This library is required and not longer bundled with httpd.
Disk Space
Make sure has at least MB of temporary free disk space available.
Ansi-c Compiler and Build System
Make sure Ansi-c compiler installed. The GNU C compiler (GCC) from the Free Software Foundation (FSF) is recommended.
Accurate time keeping
Elements of the HTTP protocol is expressed as the time of day. So, it's time to investigate setting some time synchronization facility on your system. Usually the ntpdate or XNTPD programs is used for this purpose which is based on the Network time Protocol (NTP).
Let me translate:
To compile Apache httpd, the following requirements exist:
APR and Apr-util
Make sure the APR and Apr-util are already installed on your system.
Perl-compatible Regular Expressions Library (PCRE)
This library is required, but it is no longer bundled with httpd.
Disk Space
Make sure you have at least 50MB of temporary free disk space available.
Ansi-c Compiler and Build System
Make sure you have a ansi-c compiler installed. It is recommended to use the GNU C Compiler (GCC) written by the Free Software Foundation (FSF).
Accurate time keeping
The elements of the HTTP protocol are represented in a single day of time. So, it's time to refer to some of the clocks in your system to sync your device's settings. Usually a program based on Network Time Protocol (NTP) ntpdate or xntpd is used to do such a thing.
Through the official documentation we learned that before installing Apache2.4 we had to install APR, Apr-util and Pcre.
- 2
Whether you are installing APR, Apr-util, Pcre, or Apache server or some other software, in short, if the source is installed, then you need a ansi-c compiler. If you don't have one, use Yum to put it in, since GCC is recommended, so let's have a gcc. Execute command: Yum install-y gcc. If you're bored, you can try to install GCC on your own without relying on Yum, and I'm sure you'll be cool!
- 3
The next step is to install APR, Apr-util, and Pcre. Before installing, see how to download them. First look at the APR and apr-util download, we can go to http://apr.apache.org to download, see the following two pictures:
Let's see how to download the Pcre. You can go to http://www.pcre.org to download, see the following four pictures:
Upload the downloaded 3 compressed packages to your Linux system. I uploaded it to my Linux system under the/mysoft directory. Enter this directory: Cd/mysoft. Let's unpack the APR and look at the files in the/mysoft directory and execute the command in turn:
Gzip-d apr-1.5.2.tar.gz
TAR-XF Apr-1.5.2.tar
Ls-l
You can see that the/mysoft directory has more than one directory apr-1.5.2.
Enter the apr-1.5.2 directory: CD./apr-1.5.2/. Then, the APR of the source installation, in turn, execute the command:
./configure
Make
Make install
After the installation is complete, we can see the information as shown in the make install process, we can see the APR installation path/USR/LOCAL/APR. Of course, you can also use the--prefix= directory option to specify an installation directory.
Next, let's unpack the apr-util and look at the files in the/mysoft directory and execute the commands in turn:
Gzip-d apr-util-1.5.4.tar.gz
TAR-XF Apr-util-1.5.4.tar
Ls-l
You can see that the/mysoft directory has more than one directory apr-util-1.5.4.
Enter the apr-util-1.5.4 directory: CD./apr-util-1.5.4/. Then, for apr-util source installation, execute the command in turn:
./configure--WITH-APR=/USR/LOCAL/APR
Make
Make install
When installing Apr-util, you need to specify the installation path of APR, so you need to bring the option--WITH-APR=/USR/LOCAL/APR, if you do not bring this option, you will see the error prompt when configure.
Next, let's install Pcre. First, unpack the pcre and look at the files in the/mysoft directory and execute the commands in turn:
Gzip-d pcre-8.36.tar.gz
TAR-XF Pcre-8.36.tar
Ls-l
You can see that the/mysoft directory has more than one directory pcre-8.36.
Enter the pcre-8.36 directory: CD./pcre-8.36/. Then, do the pcre-8.36 source installation, but when you execute the./configure, you will see the prompt shown:
Configure:error:You need a C + + compiler for C + + support
Don't worry, Yum comes in handy and executes commands: Yum install-y gcc gcc-c++.
After the gcc-c++ installation is complete, we continue our pcre-8.36 source installation and execute the command in turn:
./configure
Make
Make install
At this point, ready to work, start preparing to install Apache Server2.4, first of all, to see how to download Apache2.4, we can go to http://httpd.apache.org to download, see.
Before installing Apache, let's look at a small piece of official documentation:
--enable-mods-shared=module-list
Defines a list of modules to be enabled and build as dynamic shared modules. This mean, these module has the to is loaded dynamically by using the LoadModule directive. Module-list is a space separated LIST of modulenames enclosed by quotation marks. The module names is given without the preceding mod_. For example:
--enable-mods-shared= ' headers rewrite DAV '
Additionally you can use the special keywords Reallyall, all, most, few and none. For example,
--enable-mods-shared=most would compile most modules and build them as DSO modules
--enable-mods-shared=few would only compile a very basic set of modules
The default set is most.
The LoadModule directives for the chosen modules would be a automatically generated in the main configuration file. By default, all those directives is commented out except for the modules that is either required or explicitly selec Ted by a Configure--enable-foo argument. You can change the set of loaded modules by activating or deactivating the LoadModule directives in httpd.conf. In addition the LoadModule directives for all built modules can be activated via the Configure option--enable-load-all-mo Dules.
--enable-mods-static=module-list
This option behaves similar to--enable-mods-shared, but would link the given modules statically. This mean, these modules is always being present while running httpd. They need not being loaded with LoadModule.
--enable-modules=module-list
This option behaves like to--enable-mods-shared, and would also link the given modules dynamically. The Special keyword None disables the build of all modules.
Let me translate:
--enable-mods-shared=module-list
Defines a list of modules to be enabled, and these modules are compiled with dynamic shared modules. This means that these modules need to be dynamically loaded by using the loadmodule instruction. Module-list is a list of module names that are enclosed in quotation marks and separated by spaces. These module names are given in the form of a mod_ that is removed from the front. For example:
--enable-mods-shared= ' headers rewrite DAV '
You can also use the Special keyword reallyall,all,most,few and none. For example:
--enable-mods-shared=most compile most of the modules and compile them as dynamic shared modules
--enable-mods-shared=few only compiles a relatively basic set of modules
The default keyword is most.
For selected modules, the loadmodule instruction is automatically generated in the primary configuration file. By default, all of these instructions are commented out, except for some required or explicitly specified modules through a--enable-foo parameter. You can change the settings of the loaded module in the httpd.conf file by activating or unregistering the loadmodule instruction. In addition, the LoadModule instructions for all compiled modules can be activated by configuring the option--enable-load-all-modules.
--enable-mods-static=module-list
This configuration option behaves like--enable-mods-shared, but statically links the given module. This means that these modules are always present when running httpd. They do not need to be loaded with loadmodule instructions.
--enable-modules=module-list
This configuration option behaves similarly to--enable-mods-shared and dynamically links the given module. You can disable all modules that you want to compile by using the Special keyword none.
More content everyone can go to the official website to see, here I will not speak more. Go to the point, unpack the httpd, and look at the files in the/mysoft directory, executing the commands in turn:
Gzip-d httpd-2.4.17.tar.gz
TAR-XF Httpd-2.4.17.tar
Ls-l
You can see that the/mysoft directory has more than one directory httpd-2.4.17.
- 14
Enter the httpd-2.4.17 directory: CD./httpd-2.4.17/. Then, perform the Apache source installation and execute the command in turn:
./configure--enable-mods-shared=all
Make
Make install
Apache is installed by default in the/usr/local/apache2 directory. Also, here you can use
--prefix= Directory Name
To specify an installation directory, for example:
./configure--prefix=/usr/mydir--enable-mods-shared=all
- 15
Apache has successfully installed and now starts the HTTPD service. Execute command:
/usr/local/apache2/bin/apachectl-k start.
You will find that the HTTPD service does not start, but instead there is an error message as shown:
AH00558:httpd:Could not reliably determine the server ' s fully qualified domain name, using Localhost.localdomain. Set the ' ServerName ' directive globally to suppress this message
- 16
The above error message occurs because servername in profile httpd.conf is not modified.
We use VIM to open the httpd.conf configuration file and execute the command:
Vi/usr/local/apache2/conf/httpd.conf
Set VIM to perform a search without case sensitivity and execute the command:
: Set IC
Search for the "servername" string and execute the command:
/ServerName
When you find ServerName, press the a key to edit. Remove the # number before servername, and change the string after servername to: LOCALHOST:80, as shown in.
When the modification is complete, press ESC to switch from edit mode to command mode, and then execute the Save Exit command:
: Wq
- 17
Before starting httpd, let's create a soft link (the equivalent of a shortcut under Windows), otherwise it's hard to lose a long string each time you restart Apache.
Create a soft link for httpd and check to see if the soft link was created successfully and execute the command sequentially:
Ln-s/usr/local/apache2/bin/apachectl/mylinks/httpd.
Ls-l/mylinks
Come on, start the httpd service, execute the command:/mylinks/httpd-k start
- 18
Before testing whether Apache is working properly, let's look at the state of the firewall:
Systemctl Status Firewalld
If you are running in running, turn it off:
Systemctl Stop Firewalld
Then, check to see if the firewall is turned off:
Systemctl Status Firewalld
If you are in a dead state, it is turned off.
If you want to not start the firewall every time the system starts, you can execute the command:
Systemctl Disable FIREWALLD
Similarly, if you want to start the firewall every time the system starts, you can execute the command:
Systemctl Enable Firewalld
- 19
After the firewall shuts down, take a look at your system's IP address: ifconfig-a. You can see that my IP is 192.168.0.104.
- 20
Open the browser and enter in the Address bar: 192.168.0.104, carriage return. can see it works!