Configuring Apache with PHP

Source: Internet
Author: User

Configuration file for ★apache

/usr/local/apache2/conf/httpd.conf

/usr/local/apache2/bin/apachectl-l can list all the static modules, namely the HTTPD kernel modules

[Email protected] ~]#/usr/local/apache2/bin/apachectl-l
Compiled in Modules:
Core.c
Mod_so.c
Http_core.c
EVENT.C 2.0 and 2.2 default to Prefork mode, using child process (worker; 2.4 Default to Event mode)

    • Change Mode:

cd/usr/local/src/httpd-2.2.16

[Email protected] httpd-2.2.16]#/configure--help |grep MPM
--WITH-MPM=MPM Choose The process model for Apache to use.
Mpm={beos|event|worker|prefork|mpmt_os2}

Specify the pattern at compile time

/usr/local/apache2/bin/apachectl-m can list modules of shared type

/usr/local/apache2/bin/apachectl-t can see if there are any errors in syntax

Mistakes, no errors, no restarts.

/usr/local/apache2/bin/apachectl-graceful can reload the configuration file

Cat/usr/local/apache2/build/config.nice can see the options when compiling Apache

★ Configure Apache with PHP

Vim/usr/local/apache2/conf/httpd.conf

Found: AddType application/x-gzip. gz. tgz
Add below the line: AddType application/x-httpd-php. php

Found: <ifmodule dir_module>
DirectoryIndex index.html
</IfModule>
Modified to: <ifmodule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>

Found: #ServerName www.example.com:80
Modified to: ServerName localhost:80

★ Test Parsing PHP

Write a PHP script named 1.php

[Email protected] httpd-2.2.16]# vim/usr/local/apache2/htdocs/1.php

[Email protected] httpd-2.2.16]# cat/usr/local/apache2/htdocs/1.php
<?php
Echo baidu.com;
?>

Enter the IP address in the local browser/1.php

found that although PHP normal parsing, but the display content is baiducom, the script is written. not shown. This is because. In the PHP script is a connector, if you want it to really display. Need to add single quotes (echo ' baidu.com ')

Phpinfo () can display PHP-related configuration

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/59/4A/wKioL1TPI3WxCS_NAAJUymOJ_Sk125.jpg "title=" 73z_$) iiv{b1unn%y$) N (}m.png "alt=" Wkiol1tpi3wxcs_naajuymoj_sk125.jpg "/>

We can see that the loaded configuration file is displayed as (none) because there are no related profiles under/usr/local/php/etc

[Email protected] httpd-2.2.16]# ls/usr/local/php/etc
Pear.conf

We can copy one, under the source package file we can filter

[email protected] php-5.3.28]# ls |grep php.ini
Php.ini-development <== test Environment
Php.ini-production <== Production Environment

[email protected] php-5.3.28]# CP Php.ini-production/usr/local/php/etc/php.ini

We need to reboot. Apache,[[email protected] php-5.3.28]#/etc/init.d/apachectl restart

Refresh the page we found that it had changed.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/59/4D/wKiom1TPJGvwwxjWAAB3NrALcXM270.jpg "title=" cdvl$g $I 6nwttlvhaxwb%qb.png "alt=" Wkiom1tpjgvwwxjwaab3nralcxm270.jpg "/>

Testing under the command line

    • [[email protected] php-5.3.28]# cd/usr/local/php <== into this directory

    • [[email protected] php]#/usr/local/php/bin/php-m can list all the loaded modules, are statically compiled in

    • [[email protected] php]#/usr/local/php/bin/php-i can view phpinfo

To view the profile, you can/usr/local/php/bin/php-i |grep-i ' configuration file '

    • [[email protected] php]#/usr/local/php/bin/php-i |grep-i ' Configuration File '
      Configuration File (php.ini) Path = = /usr/local/php/etc
      Loaded Configuration File =/usr/local/php/etc/php.ini

    • [[email protected] php]#/usr/local/php/bin/php-v can view version

    • [[email protected] php]#/usr/local/php/bin/php-i |head can see the compilation options for PHP

    • [Email protected] php]# curl-x192.168.16.100:80 yueyue.com/index.html

      If the actual PHP source code, that PHP does not resolve the normal, need to check the configuration file

Troubleshooting methods when parsing is not normal

    • /usr/local/php/bin/php-m
      See if there is no php5_module module, if no second step

    • View ls/usr/local/apache2/modules/libphp5.so This directory has no this file

      If you have this file but do not have the module in the first step, ldd/usr/local/apache2/modules/libphp5.so

      See if there is a problem (if ****==> not found is present), this command is used to query which library files are dependent


Configuring Apache with PHP

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.