PHP Tutorial: install and configure the PHP server in Linux

Source: Internet
Author: User
The Apache configuration file is/usr/local/lib/php. ini. Compile the php. ini file to configure PHP options. Note that after the installation is complete, the register_globals variable is set to Off by default and needs to be changed to On. Otherwise, PHP will not be able to read post data.

1, # cp httpd-2.0.47.tar.gz to/usr/local/
2. # tar zxvf php-4.3.3.tar.gz
3, # cd php-4.3.3
4, #./configure -- with-mysql -- with-apxs2 =/usr/local/apache/bin/apxs
#./Configure-with-apache =/path/to/apache/dir-with-mysql =/usr/local/mysql
5. # make
6. # make install)
7. # cp php. ini-dist/usr/local/lib/php. ini
8. # vi/usr/local/apache2/conf/httpd. conf
9. add the following under AddType application/x-tar.tgz:
AddType application/x-httpd-php. php
LoadModule php4_module/var/www/modules/libphp4.so (if not, add)
10. # vi/usr/local/apache2/htdocs/test. php
Echo phpinfo ();
?>
11. browse http: // ip/test. php. Displays php information. Congratulations! this step is successful.

Basic configuration of PHP and Apache after installation
1. Apache configuration
The Apache configuration file is/usr/local/apache2/conf/httpd. conf. Compile the httpd. conf file and add the following lines at the end of the file:
LoadModule php4_module modules/libphp4.so
AddType application/x-httpd-php. php. php3
At the same time, the DirectoryIndex is changed:

DirectoryIndex index.htm
DirectoryIndex index.html
DirectoryIndex index. php
DirectoryIndex index. php3
DirectoryIndex index. php4

Apache has rich configuration content. for other Apache related configurations, see related Apache documents.
2. PHP configuration
The Apache configuration file is/usr/local/lib/php. ini. Compile the php. ini file to configure PHP options. Note that after the installation is complete, the register_globals variable is set to Off by default and needs to be changed to On. Otherwise, PHP will not be able to read post data.
Zlib. output_compression = On
Register_globals = On
For other PHP options, see related documents.
3. test
You can write a simple php file to test the installation. The file contains the following lines:
Keep it as/usr/local/apache2/htdocs/info. php, start Apache, and then browse in the browser.

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.