Configuring Apache(httpd) with php

The main Apache configuration file is: / usr/local/apache2/conf/httpd.conf ...

The main Apache configuration file is: / usr/local/apache2/conf/httpd.conf

Configure httpd and php steps

Httpd main configuration file / usr/local/apache2.4/conf/httpd.conf
vim /usr/local/apache2.4/conf/httpd.conf / / modify the following four places
ServerName
Require all denied
AddType application/x-httpd-php .php
DirectoryIndex index.html index.php
/usr/local/apache2.4/bin/apachectl -t / / test syntax
/usr/local/apache2.4/bin/apachectl start / / start the service
The specific steps are as follows:

Start Apache before configuration
[root@dl-001 conf]# /usr/local/apache2.4/bin/apachectl restart httpd: Could not reliably determine the server's fully qualified domain name, using fe80::50e7:255d:8ff7:2d3d for ServerName httpd not running, trying to start

terms of settlement:

Step 1
[root@dl-001 ~]# vim /usr/local/apache2.4/conf/httpd.conf 99 LoadModule alias_module modules/mod_alias.so 100 LoadModule rewrite_module modules/mod_rewrite.so 101 LoadModule php5_module modules/libphp5.so 102 #Loadmodule php7_module modules / libphp7. So / / because two versions of PHP are downloaded, one needs to be commented. ....................................... ..................................... 140 # ServerName gives the name and port that the server uses to identify itself. 141 # This can often be determined automatically, but we recommend you specify 142 # it explicitly to prevent problems during startup. 143 # 144 # If your host doesn't have a registered DNS name, enter its IP address here. 145 # 146 ServerName www.example.com:80 //Remove#(this line is annotated by default)
[root@dl-001 conf]# /usr/local/apache2.4/bin/apachectl restart / / start Apache again [root@dl-001 conf]# ps -aux|grep httpd / / view the process (start successfully) root 5657 0.0 1.2 315668 12156 ? Ss 18:19 0:00 /usr/local/apache2.4/bin/httpd -k restart daemon 5669 0.0 0.6 315668 6504 ? S 18:23 0:00 /usr/local/apache2.4/bin/httpd -k restart daemon 5670 0.0 0.6 315668 6504 ? S 18:23 0:00 /usr/local/apache2.4/bin/httpd -k restart daemon 5671 0.0 0.6 315668 6504 ? S 18:23 0:00 /usr/local/apache2.4/bin/httpd -k restart daemon 5672 0.0 0.6 315668 6504 ? S 18:23 0:00 /usr/local/apache2.4/bin/httpd -k restart daemon 5673 0.0 0.6 315668 6504 ? S 18:23 0:00 /usr/local/apache2.4/bin/httpd -k restart root 5675 0.0 0.0 112680 976 pts/1 R+ 18:23 0:00 grep --color=auto httpd
Step 2

Virtual machine: [root @ dl-001 conf] × iptables - I input - P TCP – dport 80 -j ACCEPT
//Temporarily add the rule of listening to port 80

Physical machine: enable telnet command start in win7 control panel control panel program start or close Windows function select telnet client

ping 192.168.114.128 //Check whether ip is connected ping 192.168.114.128 80 //Check whether the port is open

Note: you can use a browser to directly access the local virtual machine IP.

Step 3 (note version)
[root@dl-001 ~]# vim /usr/local/apache2.4/conf/httpd.conf <Directory /> AllowOverride none Require all granted //Changed to granted 2.4.27Version of Apache </Directory> <Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Allow from all //Deny to Allow 2.4.29Version of Apache </Directory>
Step 4
//Check configuration for syntax errors [root@dl-001 ~]# /usr/local/apache2.4/bin/apachectl -t Syntax OK //Reload profile [root@dl-001 ~]# /usr/local/apache2.4/bin/apachectl graceful

Note: this command will not restart the service, only load the contents of the configuration file.

Step 5
[root@dl-001 ~]# vim /usr/local/apache2.4/conf/httpd.conf AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php //Add this line. Can't parse without adding PHP # <IfModule dir_module> DirectoryIndex index.html index.php //Add index.php </IfModule> #

3 May 2020, 20:33 | Views: 9096

Add new comment

For adding a comment, please log in
or create account

0 comments