Apache + PHP Configuration

Source: Internet
Author: User
Tags sha1

The Apache and PHP have been reconfigured for work. I thought I had configured it, but I forgot about it. Moreover, there is no record. From my own point of view, the lack of such training, from the national education system, does not seem to have been a scientific record of training. Chinese porcelain is famous because of the early development, various kinds of craftsmen inspiration, exquisite, and then all kinds of lost, leaving only a beautiful object, and not how to make the record again. I don't know seismograph's internal structure now, do you? Perhaps they do not have the habit of recording, perhaps they do not want to let others know, do not want to let others learn their own housekeeping skills. In the history of Chinese personalities, the latter is of great possibility. It's not that they don't have the habit of recording, but they don't want to record it. The counter-view has now surpassed China and is in the top of the world's German porcelain, in the era of Augustus, in order to imitation Chinese porcelain, conducted more than 30,000 experiments, and recorded. Reproducible, verifiable, and falsified, this is science. Need training, thinking, action.

============== Double Line ===============================

Apache Installation and configuration detailed installation

Official website: http://www.apache.org/

Top-level menu found: Download

In the link below select the official recommended first, Tsinghua's mirror server:

http://mirrors.tuna.tsinghua.edu.cn/apache/

A list of directories appears, Ctrl + F, find httpd, and click Enter.

If you want to see more information, search Apache HTTP Server Download Page, or you can open http://httpd.apache.org/download.cgi directly

On this page, we can see some instructions and details, various download methods. Here, only the download method of files for Windows system is described.

In the most obvious position of the page, there is a

    • 2.4.29 (Released 2017-10-23)

Click to jump to the section corresponding to this page. As follows:

    • source:httpd-2.4.29.tar.bz2 [PGP] [MD5] [SHA1] [SHA256]
    • source:httpd-2.4.29.tar.gz [PGP] [MD5] [SHA1] [SHA256]
    • Binaries
    • Security and Official patches
    • Other files
    • Files for Microsoft Windows

is the source code and installation file download link. Apache server itself does not store files, all through third-party servers published, presumably because the world's traffic is too large, as a nonprofit organization, powerless and no need to maintain.

If you click on binaries, and then go to directory browsing, and then go back to the third party server, so, direct point a number of third parties vendors, or files for Microsoft Windows, the two links are the same, A list of third parties appears:

    • Apachehaus
    • Apache Lounge
    • BitNami WAMP Stack
    • Wampserver
    • Xampp

If you want a pure Apache server, choose the top two, the next three is the integration of MySQL and PHP version.

After downloading, unzip, I put in the C:/apache24 directory.

Configuration

Open the Apache24/conf directory and open the httpd.conf file with a text editor.

Find " serverroot "${srvroot}" "

(Note: Because there are some tags in the file with quotation marks, so all need to find, all are marked in Chinese brackets, so that the difference, use only to find the contents of the brackets inside, the same below)

The ${srvroot} "is a variable in the Apache configuration file, and its previous sentence is define Srvroot"/apache24 ", meaning that the value of the Srvroot variable is defined as/apache24,

Here we adjust according to the actual situation, changed to define Srvroot "C:/apache24", which is the absolute path of our Apache installation directory.

In this configuration file, a lot of ${srvroot} variables are used to set the Apache installation path, such as DocumentRoot, so it is better to use this variable, you do not have to change everywhere.

Find "Listen 80", here is the default, if not necessary, do not have to modify.

Find "ServerName"

ServerName localhost:80

Here is the name of the main site, the site domain name, modified according to the actual situation

Find "ServerAdmin"

ServerAdmin [email protected]

Here is the administrator's e-mail address, which automatically sends logs to administrators.

Find "DocumentRoot"

DocumentRoot "${srvroot}/htdocs"

Here is the root directory of the site, Srvroot is the previously defined installation directory, can be adjusted according to the actual situation. Can be set outside the installation directory.

Find "<directory/>"

Change the require all denied under it to require all granted

Finally, using the Httpd.exe file for installation, you can cmd into the D:\Apache24\bin directory execution, or any directory D:\Apache24\bin\httpd.exe.

Httpd-k install-n "Apache24"

The custom alias is inside the quotation marks.

If you need to delete this service:

Httpd-k uninstall-n "Apache2.4"

At this point, Apache configuration is complete. At this time with http://localhost, should be able to access.

If the extranet is inaccessible, turn off the firewall or set port 80 to pass and try.

Configuration of the virtual site

Include httpd-vhosts.conf in http.conf

# Virtual Hosts

Include conf/extra/httpd-vhosts.conf

Configuring in Httpd-vhost.conf

(1) IP-based virtual host

Modify the Hosts file to add 3 domain names to the corresponding

192.168.1.11 www.test1.com

192.168.1.12 www.test2.com

192.168.1.13 www.test3.com

Establish the root directory of the hosting file for the virtual host, as

Www/test1/1.html

Www/test2/2.html

Www/test3/3.html

The following configuration is performed in httpd-vhosts.conf

<virtualhost 192.188.1.11:80>

ServerName www.test1.com

DocumentRoot "Www/test1"

<directory "Www/test1" >

Options Indexs Followsyslinks

AllowOverride None

Order Allow deny

Allow from all

DirectoryIndex index.html index.htm index.php

</Directory>

</VirtualHost>

<virtualhost 192.168.1.12:80>

ServerName www.test2.com

documentroot/www/test2/

<directory "/www/test2" >

Options Indexes FollowSymLinks

AllowOverride None

Order Allow,deny

Allow from all

</Directory>

</VirtualHost>

<virtualhost 192.168.1.13:80>

ServerName www.test3.com

documentroot/www/test3/

<directory "/www/test3" >

Options Indexes FollowSymLinks

AllowOverride None

Order Allow,deny

Allow from all

</Directory>

</VirtualHost>

(2) based on host name

Set the domain name mapping for the same host

192.168.1.10 www.test1.com

192.168.1.10 www.test2.com

192.168.1.10 www.test3.com

Set the root directory where the Web page resides

Www/test1/1.html

Www/test2/2.html

Www/test3/3.html

When using a domain-based virtual host, you must specify the IP address and possible access port of the server to allow the host to accept the request and

Use the Namevirtualhost directive to configure, if all the IP on the server is used, it can be used to represent,

The IP specified in Namevirtualhost does not allow the server to listen to this IP

Then configure <VirtualHost>

If you configure a virtual host on an existing Web server, you must also configure <VIRTUALHOST> for the existing virtual host, where

ServerName and DocumentRoot contain content that is consistent with the global content and should be placed at the front of the configuration file.

Configuration as the default host

Namevirtualhost:80

<VirtualHost:80>

ServerName www.test1.com

DocumentRoot "Www/test2"

<directory "Www/test1" >

Options Indexs FollowSymLinks

AllowOverride None

Order Allow,deny

Allow from all

</Directory>

</VirtualHost>

<VirtualHost:80>

ServerName www.test2.com

DocumentRoot "Www/test2"

<directory "Www/test2" >

Options Indexs FollowSymLinks

AllowOverride None

Order Allow,deny

Allow from all

</Directory>

</VirtualHost>

<VirtualHost:80>

ServerName www.test3.com

DocumentRoot "Www/test3"

<directory "Www/test3" >

Options Indexs FollowSymLinks

AllowOverride None

Order Allow,deny

Allow from all

</Directory>

</VirtualHost>

(3) Port-based

Modify Httpd.conf

Set to

Listen 8001

Listen 8002

Modify the virtual host profile httpd-vhosts.conf

<VirtualHost:8001>

ServerName www.test1.com

DocumentRoot "Www/test1"

</VirtualHost>

<VirtualHost:8002>

ServerName www.test2.com

DocumentRoot "Www/test2"

</VirtualHost>

PHP Configuration

The configuration file is Php-development.ini and Php-dist.ini in the PHP directory, changing the Php-development.ini to php.ini during development

1. Module Loading:

Extension = Php_mysql.dll

2. Modify the directory of the module

Extension_dir = "D:/php/ext"

You can also add d:/php, d:/php/ext to the system environment variable, where it is best to use absolute paths

3. Configure PHP in Apache

Change httpd.conf

Add PHP Module

LoadModule Php7_module "D:/php/php7apache2_4.dll

Configuring the Php.in Path

Phpinidir "d:/php"

Configure AddType

AddType application/x-httpd-php. php

AddType application/x-httpd-php. txt

4. register_globals = OFF Sets whether to turn on global variables

If set to On

Arguments that have been get/post submitted can be used directly with a variable call, it is recommended not to open

5. Set time zone: Date.timezone =PRC

6. Set session

Apache + PHP configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.