whereis apache2
安装apache
卸载原有的安装包
[root@ORALCE11G etc]# rpm -qa | grep httpd httpd-tools-2.4.6-93.el7.centos.x86_64 httpd-2.4.6-93.el7.centos.x86_64 [root@ORALCE11G etc]# [root@ORALCE11G etc]# rpm -e --nodeps httpd-tools-2.4.6-93.el7.centos.x86_64 [root@ORALCE11G etc]# rpm -e --nodeps httpd-2.4.6-93.el7.centos.x86_64 [root@ORALCE11G etc]# rpm -qa | grep httpd [root@ORALCE11G etc]#
使用yum安装
[root@ORALCE11G etc]# yum install -y httpd 已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. Loading mirror speeds from cached hostfile base | 3.6 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/3): updates/x86_64/primary_db | 8.8 MB 00:00:01 (2/3): epel/x86_64/updateinfo | 1.0 MB 00:00:01 (3/3): epel/x86_64/primary_db | 6.9 MB 00:00:05 正在解决依赖关系 --> 正在检查事务 ---> 软件包 httpd.x86_64.0.2.4.6-97.el7.centos 将被 安装 --> 正在处理依赖关系 httpd-tools = 2.4.6-97.el7.centos,它被软件包 httpd-2.4.6-97.el7.centos.x86_64 需要 --> 正在检查事务 ---> 软件包 httpd-tools.x86_64.0.2.4.6-97.el7.centos 将被 安装 --> 解决依赖关系完成 依赖关系解决 ================================================================================= Package 架构 版本 源 大小 ================================================================================= 正在安装: httpd x86_64 2.4.6-97.el7.centos updates 2.7 M 为依赖而安装: httpd-tools x86_64 2.4.6-97.el7.centos updates 93 k 事务概要 ================================================================================= 安装 1 软件包 (+1 依赖软件包) 总下载量:2.8 M 安装大小:9.5 M Downloading packages: (1/2): httpd-2.4.6-97.el7.centos.x86_64.rpm | 2.7 MB 00:00:00 (2/2): httpd-tools-2.4.6-97.el7.centos.x86_64.rpm | 93 kB 00:00:00 --------------------------------------------------------------------------------- 总计 2.7 MB/s | 2.8 MB 00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction 警告:RPM 数据库已被非 yum 程序修改。 ** 发现 1 个已存在的 RPM 数据库问题, ‘yum check‘ 输出如下: rhn-check-2.0.2-17.el7.noarch 有缺少的需求 yum-rhn-plugin >= (‘0‘, ‘1.6.4‘, ‘1‘) 正在安装 : httpd-tools-2.4.6-97.el7.centos.x86_64 1/2 正在安装 : httpd-2.4.6-97.el7.centos.x86_64 2/2 验证中 : httpd-2.4.6-97.el7.centos.x86_64 1/2 验证中 : httpd-tools-2.4.6-97.el7.centos.x86_64 2/2 已安装: httpd.x86_64 0:2.4.6-97.el7.centos 作为依赖被安装: httpd-tools.x86_64 0:2.4.6-97.el7.centos 完毕!
查看安装包
[root@ORALCE11G etc]# rpm -qa | grep httpd httpd-2.4.6-97.el7.centos.x86_64 httpd-tools-2.4.6-97.el7.centos.x86_64 [root@ORALCE11G etc]#
启动服务
[root@ORALCE11G etc]# service httpd status Redirecting to /bin/systemctl status httpd.service ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since 四 2021-06-17 17:46:00 CST; 4s ago Docs: man:httpd(8) man:apachectl(8) Main PID: 5294 (httpd) Status: "Processing requests..." CGroup: /system.slice/httpd.service ├─5294 /usr/sbin/httpd -DFOREGROUND ├─5295 /usr/sbin/httpd -DFOREGROUND ├─5296 /usr/sbin/httpd -DFOREGROUND ├─5297 /usr/sbin/httpd -DFOREGROUND ├─5298 /usr/sbin/httpd -DFOREGROUND └─5299 /usr/sbin/httpd -DFOREGROUND 6月 17 17:45:59 ORALCE11G systemd[1]: Starting The Apache HTTP Server... 6月 17 17:45:59 ORALCE11G httpd[5294]: AH00558: httpd: Could not reliably d...ge 6月 17 17:46:00 ORALCE11G systemd[1]: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full. [root@ORALCE11G etc]#
配置文件
1 [root@ORALCE11G etc]# cat /etc/httpd/conf/httpd.conf 2 # 3 # This is the main Apache HTTP server configuration file. It contains the 4 # configuration directives that give the server its instructions. 5 # See <URL:http://httpd.apache.org/docs/2.4/> for detailed information. 6 # In particular, see 7 # <URL:http://httpd.apache.org/docs/2.4/mod/directives.html> 8 # for a discussion of each configuration directive. 9 # 10 # Do NOT simply read the instructions in here without understanding 11 # what they do. They‘re here only as hints or reminders. If you are unsure 12 # consult the online docs. You have been warned. 13 # 14 # Configuration and logfile names: If the filenames you specify for many 15 # of the server‘s control files begin with "/" (or "drive:/" for Win32), the 16 # server will use that explicit path. If the filenames do *not* begin 17 # with "/", the value of ServerRoot is prepended -- so ‘log/access_log‘ 18 # with ServerRoot set to ‘/www‘ will be interpreted by the 19 # server as ‘/www/log/access_log‘, where as ‘/log/access_log‘ will be 20 # interpreted as ‘/log/access_log‘. 21 22 # 23 # ServerRoot: The top of the directory tree under which the server‘s 24 # configuration, error, and log files are kept. 25 # 26 # Do not add a slash at the end of the directory path. If you point 27 # ServerRoot at a non-local disk, be sure to specify a local disk on the 28 # Mutex directive, if file-based mutexes are used. If you wish to share the 29 # same ServerRoot for multiple httpd daemons, you will need to change at 30 # least PidFile. 31 # 32 ServerRoot "/etc/httpd" 33 34 # 35 # Listen: Allows you to bind Apache to specific IP addresses and/or 36 # ports, instead of the default. See also the <VirtualHost> 37 # directive. 38 # 39 # Change this to Listen on specific IP addresses as shown below to 40 # prevent Apache from glomming onto all bound IP addresses. 41 # 42 #Listen 12.34.56.78:80 43 Listen 80 44 45 # 46 # Dynamic Shared Object (DSO) Support 47 # 48 # To be able to use the functionality of a module which was built as a DSO you 49 # have to place corresponding `LoadModule‘ lines at this location so the 50 # directives contained in it are actually available _before_ they are used. 51 # Statically compiled modules (those listed by `httpd -l‘) do not need 52 # to be loaded here. 53 # 54 # Example: 55 # LoadModule foo_module modules/mod_foo.so 56 # 57 Include conf.modules.d/*.conf 58 59 # 60 # If you wish httpd to run as a different user or group, you must run 61 # httpd as root initially and it will switch. 62 # 63 # User/Group: The name (or #number) of the user/group to run httpd as. 64 # It is usually good practice to create a dedicated user and group for 65 # running httpd, as with most system services. 66 # 67 User apache 68 Group apache 69 70 # ‘Main‘ server configuration 71 # 72 # The directives in this section set up the values used by the ‘main‘ 73 # server, which responds to any requests that aren‘t handled by a 74 # <VirtualHost> definition. These values also provide defaults for 75 # any <VirtualHost> containers you may define later in the file. 76 # 77 # All of these directives may appear inside <VirtualHost> containers, 78 # in which case these default settings will be overridden for the 79 # virtual host being defined. 80 # 81 82 # 83 # ServerAdmin: Your address, where problems with the server should be 84 # e-mailed. This address appears on some server-generated pages, such 85 # as error documents. e.g. admin@your-domain.com 86 # 87 ServerAdmin root@localhost 88 89 # 90 # ServerName gives the name and port that the server uses to identify itself. 91 # This can often be determined automatically, but we recommend you specify 92 # it explicitly to prevent problems during startup. 93 # 94 # If your host doesn‘t have a registered DNS name, enter its IP address here. 95 # 96 #ServerName www.example.com:80 97 98 # 99 # Deny access to the entirety of your server‘s filesystem. You must 100 # explicitly permit access to web content directories in other 101 # <Directory> blocks below. 102 # 103 <Directory /> 104 AllowOverride none 105 Require all denied 106 </Directory> 107 108 # 109 # Note that from this point forward you must specifically allow 110 # particular features to be enabled - so if something‘s not working as 111 # you might expect, make sure that you have specifically enabled it 112 # below. 113 # 114 115 # 116 # DocumentRoot: The directory out of which you will serve your 117 # documents. By default, all requests are taken from this directory, but 118 # symbolic links and aliases may be used to point to other locations. 119 # 120 DocumentRoot "/var/www/html" 121 122 # 123 # Relax access to content within /var/www. 124 # 125 <Directory "/var/www"> 126 AllowOverride None 127 # Allow open access: 128 Require all granted 129 </Directory> 130 131 # Further relax access to the default document root: 132 <Directory "/var/www/html"> 133 # 134 # Possible values for the Options directive are "None", "All", 135 # or any combination of: 136 # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews 137 # 138 # Note that "MultiViews" must be named *explicitly* --- "Options All" 139 # doesn‘t give it to you. 140 # 141 # The Options directive is both complicated and important. Please see 142 # http://httpd.apache.org/docs/2.4/mod/core.html#options 143 # for more information. 144 # 145 Options Indexes FollowSymLinks 146 147 # 148 # AllowOverride controls what directives may be placed in .htaccess files. 149 # It can be "All", "None", or any combination of the keywords: 150 # Options FileInfo AuthConfig Limit 151 # 152 AllowOverride None 153 154 # 155 # Controls who can get stuff from this server. 156 # 157 Require all granted 158 </Directory> 159 160 # 161 # DirectoryIndex: sets the file that Apache will serve if a directory 162 # is requested. 163 # 164 <IfModule dir_module> 165 DirectoryIndex index.html 166 </IfModule> 167 168 # 169 # The following lines prevent .htaccess and .htpasswd files from being 170 # viewed by Web clients. 171 # 172 <Files ".ht*"> 173 Require all denied 174 </Files> 175 176 # 177 # ErrorLog: The location of the error log file. 178 # If you do not specify an ErrorLog directive within a <VirtualHost> 179 # container, error messages relating to that virtual host will be 180 # logged here. If you *do* define an error logfile for a <VirtualHost> 181 # container, that host‘s errors will be logged there and not here. 182 # 183 ErrorLog "logs/error_log" 184 185 # 186 # LogLevel: Control the number of messages logged to the error_log. 187 # Possible values include: debug, info, notice, warn, error, crit, 188 # alert, emerg. 189 # 190 LogLevel warn 191 192 <IfModule log_config_module> 193 # 194 # The following directives define some format nicknames for use with 195 # a CustomLog directive (see below). 196 # 197 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined 198 LogFormat "%h %l %u %t \"%r\" %>s %b" common 199 200 <IfModule logio_module> 201 # You need to enable mod_logio.c to use %I and %O 202 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio 203 </IfModule> 204 205 # 206 # The location and format of the access logfile (Common Logfile Format). 207 # If you do not define any access logfiles within a <VirtualHost> 208 # container, they will be logged here. Contrariwise, if you *do* 209 # define per-<VirtualHost> access logfiles, transactions will be 210 # logged therein and *not* in this file. 211 # 212 #CustomLog "logs/access_log" common 213 214 # 215 # If you prefer a logfile with access, agent, and referer information 216 # (Combined Logfile Format) you can use the following directive. 217 # 218 CustomLog "logs/access_log" combined 219 </IfModule> 220 221 <IfModule alias_module> 222 # 223 # Redirect: Allows you to tell clients about documents that used to 224 # exist in your server‘s namespace, but do not anymore. The client 225 # will make a new request for the document at its new location. 226 # Example: 227 # Redirect permanent /foo http://www.example.com/bar 228 229 # 230 # Alias: Maps web paths into filesystem paths and is used to 231 # access content that does not live under the DocumentRoot. 232 # Example: 233 # Alias /webpath /full/filesystem/path 234 # 235 # If you include a trailing / on /webpath then the server will 236 # require it to be present in the URL. You will also likely 237 # need to provide a <Directory> section to allow access to 238 # the filesystem path. 239 240 # 241 # ScriptAlias: This controls which directories contain server scripts. 242 # ScriptAliases are essentially the same as Aliases, except that 243 # documents in the target directory are treated as applications and 244 # run by the server when requested rather than as documents sent to the 245 # client. The same rules about trailing "/" apply to ScriptAlias 246 # directives as to Alias. 247 # 248 ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" 249 250 </IfModule> 251 252 # 253 # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased 254 # CGI directory exists, if you have that configured. 255 # 256 <Directory "/var/www/cgi-bin"> 257 AllowOverride None 258 Options None 259 Require all granted 260 </Directory> 261 262 <IfModule mime_module> 263 # 264 # TypesConfig points to the file containing the list of mappings from 265 # filename extension to MIME-type. 266 # 267 TypesConfig /etc/mime.types 268 269 # 270 # AddType allows you to add to or override the MIME configuration 271 # file specified in TypesConfig for specific file types. 272 # 273 #AddType application/x-gzip .tgz 274 # 275 # AddEncoding allows you to have certain browsers uncompress 276 # information on the fly. Note: Not all browsers support this. 277 # 278 #AddEncoding x-compress .Z 279 #AddEncoding x-gzip .gz .tgz 280 # 281 # If the AddEncoding directives above are commented-out, then you 282 # probably should define those extensions to indicate media types: 283 # 284 AddType application/x-compress .Z 285 AddType application/x-gzip .gz .tgz 286 287 # 288 # AddHandler allows you to map certain file extensions to "handlers": 289 # actions unrelated to filetype. These can be either built into the server 290 # or added with the Action directive (see below) 291 # 292 # To use CGI scripts outside of ScriptAliased directories: 293 # (You will also need to add "ExecCGI" to the "Options" directive.) 294 # 295 #AddHandler cgi-script .cgi 296 297 # For type maps (negotiated resources): 298 #AddHandler type-map var 299 300 # 301 # Filters allow you to process content before it is sent to the client. 302 # 303 # To parse .shtml files for server-side includes (SSI): 304 # (You will also need to add "Includes" to the "Options" directive.) 305 # 306 AddType text/html .shtml 307 AddOutputFilter INCLUDES .shtml 308 </IfModule> 309 310 # 311 # Specify a default charset for all content served; this enables 312 # interpretation of all content as UTF-8 by default. To use the 313 # default browser choice (ISO-8859-1), or to allow the META tags 314 # in HTML content to override this choice, comment out this 315 # directive: 316 # 317 AddDefaultCharset UTF-8 318 319 <IfModule mime_magic_module> 320 # 321 # The mod_mime_magic module allows the server to use various hints from the 322 # contents of the file itself to determine its type. The MIMEMagicFile 323 # directive tells the module where the hint definitions are located. 324 # 325 MIMEMagicFile conf/magic 326 </IfModule> 327 328 # 329 # Customizable error responses come in three flavors: 330 # 1) plain text 2) local redirects 3) external redirects 331 # 332 # Some examples: 333 #ErrorDocument 500 "The server made a boo boo." 334 #ErrorDocument 404 /missing.html 335 #ErrorDocument 404 "/cgi-bin/missing_handler.pl" 336 #ErrorDocument 402 http://www.example.com/subscription_info.html 337 # 338 339 # 340 # EnableMMAP and EnableSendfile: On systems that support it, 341 # memory-mapping or the sendfile syscall may be used to deliver 342 # files. This usually improves server performance, but must 343 # be turned off when serving from networked-mounted 344 # filesystems or if support for these functions is otherwise 345 # broken on your system. 346 # Defaults if commented: EnableMMAP On, EnableSendfile Off 347 # 348 #EnableMMAP off 349 EnableSendfile on 350 351 # Supplemental configuration 352 # 353 # Load config files in the "/etc/httpd/conf.d" directory, if any. 354 IncludeOptional conf.d/*.conf 355 [root@ORALCE11G etc]#
远程访问
默认端口号为80
修改端口号并重启
service httpd restart
设置开机自启