CentOS Apache configuration details

  
 

LAMP required software and its structure httpd mysql mysql-Server php php-devel php-mysql can be installed with rpm package, or directly with yum installation #yum install httpd mysql-server php php-devel php-mysql first to understand The relevant structure of this version of apache 2.0, in order to know how to deal with our web page data /etc/httpd/conf/httpd.conf: the most important configuration file, but many other distributions will split this file into several small files. Manage different parameters separately. But the main configuration file is still named after this file. /etc/httpd/conf.d/*.conf: One of the features of CentOS. If you don't want to modify the original configuration file httpd.conf, you can separate your own extra parameters, and when you start apache, this The file will be read into the main configuration file. /usr/lib/httpd/modules: apache supports a lot of modules, so the modules you want to use are placed in this directory by default /var/www/html: here is the default directory of CentOS <;Home"; /var/www/error: If the host is set incorrectly, or the data requested by the browser is wrong, the error message appearing on the browser is the default information of this directory. /var/www/icons: Provide some small icons for apache /var/www/cgi-bin: default to some executable CGI programs placed in the directory /var/log/httpd: the default apache log files are placed here, For sites with high traffic, this directory should be very careful, because this file can easily become very large, you need enough space /usr/sbin/apachectl: This is the main executable file of Apache, this executable file is actually Shell script, which can actively detect some settings on the system, so that you can start Apache more easily /usr/sbin/httpd: This is the main apache binary /usr/bin/htpasswd: when you want to login some When you are on a web page, you need to enter your account number and password. Then Apache itself provides a basic way to protect passwords. The generation of this password is achieved through this command. As for MySQL, you need to know several important directories and files: /etc/my.cnf: This is the configuration file of Mysql, including the mysql database you want to use. The optimization, or some additional parameter specification for mysql, can be implemented in this file /usr/lib/mysql: This directory is where the MySQL database is placed. When starting any MySQL server, please remember Back up this directory completely when you back up.

In addition, in PHP
, you should know the following documents. /usr/lib/httpd/modules/libphp4.so: PHP provides the module for apache. This relationship can be used to design the most important file of the php program language on the apache page /etc/httpd/conf.d/php.conf : Do you want to manually write the module to Httpd.conf? No, because the system has actively written the php settings parameters into this file, and this file will be read in when apache restarts. /etc/php.ini: This is PHP's main configuration file, including whether PHP can allow users to upload files, whether it can allow certain low-security flags, etc., to be set in this configuration file. /etc/php.d/mysql.ini /usr/lib/php4/mysql.so: Whether PHP can support the MySQL interface depends on these two files. These two files are /usr/bin/phpize /usr/include/php provided by php-mysql: if you want to install a PHP accelerator in the future to speed up browsing, then this file and directory need to exist. Otherwise the accelerator software will not work. Basic settings of httpd.conf First, you need to have a full hostname in /etc/hosts, otherwise you will be prompted to find the full hostname when you restart the apache service. The basic settings of httpd.conf are like this: <Setting Items> Related parameters in the setting items...</Settings> For example, you want to provide for the homepage /var/www/html For additional features, you can do the following: <Directory "/var/www/html">Options Indexes...</Directory>

Settings for the host environment# Vi /etc/httpd/conf/httpd.confServerTokens OS# This project tells the client the version of the WWW server and the operating system
, no need to adapt it# if you don't want to tell too much host information, this will The project's OS is changed to Minor

ServerRoot "/etc/httpd"# This is the topmost directory of the settings file, usually using an absolute path. Some of the following data settings use a relative path when # is with this directory setting The value of the lower directory does not need to be changed. ServerRoot sets the absolute path of the Apache installation. TimeOut sets the maximum waiting time for the server to receive the completion. KeepAlive sets whether the server enables the continuous request function. The real server generally needs to enable the port setting http. clothes The default port. User/Group Sets the executor and group of the server program. This is generally apache. Let's do a few experiments for Apache. 1. We test to change the default website directory to the root directory and create a new /root/website directory #mkdir - p /root/website#echo "website page" >> /root/website/index.html#vi /etc/httpd/conf/httpd.conf find DocumentRoot "/var/www/html" this paragraph //apache root directory change the /var/www/html directory to /root/website in the <Directory "/var/www/html"> //definition apache /var/www/html this area /Var /www /html changed to /root /website so we will change the default path of apahce and then restart the service #service httpd restart //here when you restart the service, you may report an error, said the directory can not be found, this Mainly due to selinux caused by how to solve it? There are 2 ways to turn off selinux #setenforce 0 or change the selinux attribute of the /root/website file, so that it matches the httpd server requirements? We can copy the selinux attribute #chcon -R --reference /var/www/html /root/website in /var/www/html directory and then restart the service, then you will see that it is not reported, but you go to visit localhost When you find out that access is denied, why? Mainly because your /root permissions are 750, ahache this user does not have permission to access, you need to change the permissions, you can change #chmod -R 755 /root and then go to visit Found normal

Copyright © Windows knowledge All Rights Reserved