Php pseudo-static and php mysql apache configuration details

Source: Internet
Author: User
Tags ini memory usage mysql tutorial php mysql php mysql tutorial php tutorial

Php Tutorial pseudo-static and php mysql tutorial apache configuration details

Configuration process:

(1) http. conf

 

Run php directly as a module of apache. I added two sentences to it:

Loadmodule php5_module "e:/php/php5apache2. dll"

Addtype application/x-httpd-php. php

I created a www directory under the e: apache2 directory to store my site files. In http. conf, I changed the following sentence:

Change documentroot "e:/apache2/htdocs" to documentroot "e:/apache2/www"

Run the following statement under documentroot "e:/apache2/www":

Code: [copy to clipboard]

Options followsymlinks

Allowoverride none

Changed:

Code: [copy to clipboard]

Options indexes followsymlinks
Allowoverride none

Set the default apache characters to simplified Chinese characters:

Adddefacharcharset gb2312

Modify the default homepage of a directory:

After directoryindex, write the file name you want to set as the homepage, for example, index.html index. php.

Restart apache


(2) php. ini

Copy php. ini-dist to c: Change it to php. ini in windows. (you have installed php before)

Then, I modified the following parts:

Extension_dir = "e: phpext" (specify the Directory of the dynamic connection Library. The dynamic connection Library Directory of php5 is different from that of php4, this is detailed in its document structure)

Remove the semicolon in the following sentence

; Extension = php_dba.dll

; Extension = php_dbase.dll

; Extension = php_gd2.dll

; Extension = php_imap.dll

; Extension = php_mysql.dll

Next, we modified some file uploads and the maximum memory usage limit:

Memory_limit = 20 m

Post_max_size = 20 m

Upload_max_filesize = 20 m

Modify php. ini and restart apache.


Copy libmysql. dll, php5apache2. dll, and php5ts. dll in the php directory to c:/windows/system32. Otherwise, the mysql dynamic connection library cannot be loaded normally.
Copy libmysql. dll, php5apache2. dll, and php5ts. dll in the php directory to apache/bin. Otherwise, the mysql dynamic connection library cannot be loaded normally.


Php pseudo-static


Mod_rewrite is a very powerful feature of apache, which can implement pseudo-static pages. The following describes how to use it in detail! Useful for beginners!

1. Check whether apache supports mod_rewrite.

Use the phpinfo () function provided by php to view the environment configuration, and use ctrl + f to find "loaded modules", which lists all modules enabled by apache2handler. If "mod_rewrite" is included ", this parameter is supported and does not need to be set.

If "mod_rewrite" is not enabled, open httpd in the directory of your apache installation directory "/apache/conf. in the conf file, use ctrl + f to find "loadmodule rewrite_module" and delete.

If not found, add "loadmodule rewrite_module modules/mod_rewrite.so" to the last row in the "loadmodule" area, and then restart the apache server.

2. Enable the apache server to support. htaccess

How can I enable my local apache server to support ". htaccess? In fact, you only need to modify the httpd. conf settings of apache to enable apache to support. htaccess. Open the httpd. conf file (where? In the conf Directory of the apache Directory.

Options followsymlinks

Allowoverride none

Change

Options followsymlinks

Allowoverride all

You can.

3. Create a. htaccess file

If it is on a windows platform, I don't know how to create it at the beginning ". "htaccess" file, because this file does not actually have a file name and only has a file extension. You cannot create this file in a common way. Don't worry. I will tell you three methods right away: you can create an htaccess.txt text file first (of course, the name of the text file can be retrieved as needed) in the three types of scripts. Then, you can rename the file in three ways:

(1) open it in Notepad, click "save as", and enter ". htaccess" in the file name window. Note that the entire green section contains English quotation marks, and click "save.

(2) go to the cmd command window, switch to the folder where the htaccess.txt file is just created, enter the command: rename htaccess.txt. htaccess, and then click enter.

(32.16connect to the folder where htaccess.txt is located through ftpand rename it through ftp software.

4. rewrite rule learning

After creating a new. htaccess file, we will write the following content into it:

Rewriteengine on # rewriteengine is the rewrite engine switch on is to turn off

Rewriterule ([0-9] {1,}) $ index. php? Id = $1

Rewriterule: rewriterule is a rewrite rule that supports regular expressions. The above ([0-9] {1,}) is composed of numbers, and $ Is the End sign, the description ends with a number!

Now we can implement pseudo-static pages. Write down the rules below:

<Ifmodule mod_rewrite.c> # write in liunx

Rewriteengine on

Rewriterule (%a-za-z%}1,%}-(%0-9%}1,%}.html $ index. php? Action = $1 & id = $2

</Ifmodule>


([A-za-z000000001, 00000000-(%0-9000000001, 00000000.html $ is the rule, index. php? Action = $1 & id = $2 is the format to be replaced. $1 indicates the matching value of the first parenthesis, and $2 indicates the second.

Related Article

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.