Install Apache and PHP in Linux; Apache + PHP + MySQL Configuration Guide

Source: Internet
Author: User

1. Apache
Download the source code package of Apache for Linux on the following page
Http://www.apache.org/dist/httpd /;
Save to the/home/XX directory. XX is a self-built folder. I created a WJ folder.

command list:
Cd/home/WJ
tar-zxvf httpd-2.0.54.tar.gz
music httpd-2.0.54 apache
Cd apache
. /configure -- prefix =/usr/local/apache2 -- enable-module = So
make install
install Apache to/usr/local/Apache and configure apache supports DSO mode
2.php
download the source package of PHP for Linux on the following page
http://www.php.net/downloads.php;
Save to the/home/WJ directory
command list:
Cd/home/WJ
tar-zxvf php-5.0.4.tar.gz
music php-5.0.4 php
Cd php
. /configure -- prefix =/usr/local/PhP5 -- with-apxs2 =/usr/local/apache2/bin/apxs -- With-config-file-Path =/usr/local/lib -- enable-track-vars -- With-XML -- With-mysql
make install
where Apache and MySQL are changed based on the directory name you installed, my options are =/usr/local/apache2/bin/apxs and MySQL
cp php. ini-Dist/usr/local/lib/PHP. INI
install PHP in DSO mode to/usr/local/PHP and set the configuration file directory to/usr/local/lib to enable mysql. XML support
3. configure
VI/usr/local/Apache/CONF/httpd. conf
Configure Apache as follows
# change the serveradmin mailto: linux@linuxidc.com line to your mailbox address

# DocumentRoot "/home/httpd/html/" here is the main directory of the HTML file
# Same as above
# options followsymlinks Multiviews for security, remove "indexes"
#< br> # directoryindex default. PHP default. phtml default. php3 default.html default.htm
# Set the default file name order of apache
# addtype application/X-httpd-PHP. PHP. phtml. php3. INC
# addtype application/X-httpd-PHP-source. PHPs
# Set the PHP file suffix
Save the disk and exit
VI/usr/local/Li B/PHP. INI
# register-golbals = on
save disk and exit
4. start the service
/usr/local/Apache/bin/apachectl start
5. test
then write a PHP test page info. PHP: The content is as follows
<〈? Php
phpinfo ();
?>
if it is normal, you should be able to see the PHP information. Congratulations, Apche + MySQL + PHP has been installed successfully.
6. Apache Automatic startup-
the following uses self-starting Apache as an example.
self-starting script:
/usr/local/Apache/bin/apachectl start
the file is located in/etc/rc. d/init. d. The name is apached, which must be executable.
# chmod + x/etc/rc. d/init. d/apached // set the file attributes to executable
# ln-S/etc/rc. d/init. d/apached/etc/rc3.d/s90apache // create a soft connection. Shortcut:
# ln-S/etc/rc. d/init. d/apached/etc/rc0.d/k20apache

Detailed introduction: Apache + PHP + MySQL configuration strategy

I. system requirements:

The system passed the redhat7.2 test.

Ii. server software requirements:

1: Download Apache Web Server http://www.apache.org/

2. Go to the PHP Web site to download the PHP parser http://www.php.net/

3. Download the MySQL http://sourceforge.net/projects/mysql/ from the MySQL website

Iii. Install and debug Web Server

Download the above files and put them in the same directory. I will put them under/usr/local and use the tar command to unpack the files.

Tar zxvf apache_1.3.12.tar.gz
Tar zxvf php-4.0.6.tar.gz
Tar zxvf mysql-3.22.40.tar.gz

For ease of installation, it is recommended to name the Directory

# Mv apache_1.3.12 Apache
# Music php-4.0.6 PHP
# Music mysql-3.22.40 MySQL

Install MySQL

4. Install MySQL before installing Web Services

CD MySQL
./Configure
Make
Make install

Depending on the machine performance, the compilation process takes some time. After compilation, the system installs MySQL under/usr/local by default.

After the installation is complete, start the MySQL process.
CD/usr/local/bin

./Mysql_install_db (install the basic MySQL database)

./Safe_mysqld & (starts the process and transfers it to the background)

Here MySQL is installed. Run./MySQL to check whether the database can be connected. If it is normal, you can see this interface.

Welcome to the MySQL monitor. commands end with; or G.
Your MySQL connection ID is 880 to server version: 3.22.40
Type 'help' for help.
Mysql>

Congratulations, you have installed MySQL.

For MySQL usage, refer to his doc document.

5. Integrate Apache and PhP4

This is the key and the most difficult step for all the work. It may be because of such errors during the installation of different versions. You can modify the version information accordingly.

CD Apache

./Configure

This is dispensable, but I have to make this step

CD ../PHP
./Configure -- With-mysql =/usr/local -- With-Apache =/usr/local/Apache -- enable-track-vars
Make
Make install
CD ../Apache
./Configure -- activate-module = src/modules/PhP4/libphp4.a
Make
Make install

This step is to install the Apache web service. You can refer to./configure-help to add the required modules or install the service by referring to the installation manual.

Copy the PHP configuration file to the corresponding directory.

CD ../PHP

Cp php. ini-Dist/usr/local/lib/PHP. ini

PHP. ini does not need to be modified. You can refer to the relevant instructions for modification.

After configuring PHP, configure Apache Web server. Configure httpd. conf first.

CD/usr/local/Apache/Conf

VI httpd. conf

Modify the following content for PHP:

# Addtype application/X-httpd-PHP. php

# Addtype application/X-httpd-PHP-source. PHPs

Remove the annotator of the above two lines and determine the suffix of the PHP document based on the actual situation. According to the needs of horde, we recommend that you change the first line to the following form:

Addtype application/X-httpd-PHP. php. php3. htm. phtml. PhP4

In addition, you need to modify the default home page type. We recommend that you change directoryindex index.htm to the following:

Directoryindex index.htm index.html index. php3 index. php default. php

New MySQL + Apache + PhP Linux Installation Guide

The old version of the new version is still somewhat different. Now post the steps

Installation steps:

1. MySQL

Download the MySQL for Linux RPM package on the following page
Http://www.mysql.com/downloads/down...3.52-1.i386.rpm
Http://www.mysql.com/downloads/down...3.52-1.i386.rpm

Save to the/home/tmp directory

Command list:

CD/home/tmp
Rpm-IVH MySQL-3.23.52-1.i386.rpm # Install MySQL Server
Rpm-IVH MySQL-client-3.23.52-1.i386.rpm # Install MYSQL client
/Usr/MySQL/safe_mysqld & # Start MySQL Server
MySQL # runs the mysql client and opens the root user's remote access permission. For debugging
Use MySQL
Update user set host = '%' where user = 'root' and host <> 'localhost ';
Flush privileges;
Quit

MySQL installation is now complete

2. Apache

Download the source code package of Apache for Linux on the following page

Http://www.apache.org/dist/httpd/apache_1.3.26.tar.gz

Save to the/home/tmp directory

Command list:

CD/home/tmp
Tar-zxvf apache_1.3.26.tar.gz
MV apache_1.3.26.tar.gz Apache
CD Apache
./Configure -- prefix =/usr/local/Apache -- enable-module = so
Make
Make install

Install Apache to/usr/local/Apache and configure Apache to support DSO

3. php

Download the PHP for Linux source code package on the following page

Http://www.php.net/get_download.php? Df1_php-4.2.3.tar.gz

Save to the/home/tmp directory

Command list:

CD/home/tmp
Tar-zxvf php-4.2.3.tar.gz
Music php-4.2.3.tar.gz PHP
CD PHP
. /Configure -- prefix =/usr/local/PHP -- With-apxs =/usr/local/Apache/bin/apxs -- With-config-file-Path =/usr/local/ lib -- enable-track-vars -- With-XML -- With-MySQL
Make
Make install
Cp php. ini-Dist/usr/local/lib/PHP. ini

Install PHP in DSO mode to/usr/local/PHP and set the configuration file directory to/usr/local/lib to enable mysql. xml supports

4. Configuration

VI/usr/local/Apache/CONF/httpd. conf
Configure Apache as follows:
# Change a line of serveradmin q3boy@younet.com to your mailbox address

# DocumentRoot "/home/httpd/html/" is the main directory of the HTML file.

# Same as above

# Options followsymlinks Multiviews for security reasons, remove "indexes"

#
# Directoryindex default. php default. phtml default. php3 default.html default.htm
#
# Set the default file name order of Apache

# Addtype application/X-httpd-PHP. php. phtml. php3. inc
# Addtype application/X-httpd-PHP-source. PHPs
# Set the PHP file suffix

Save disk and exit

VI/usr/local/lib/PHP. ini
# Register-golbals = on

Save disk and exit

5. Start the service
/Usr/local/Apache/bin/apachectl start

6. Remarks
The default maximum number of processes in Apache Linux is 256. No matter how httpd. conf is modified, the limit cannot be exceeded. To increase this limit, edit/home/tmp/Apache/src/include/httpd before compiling Apache. h. Change the line # define hard_server_limit 256 to # define hard_server_limit 2048 and then compile Apache,

In Apache 1.3.26, mod_so does not seem to be the default module. -- Enable-module = so must be added during compilation. I did not add this parameter during the first compilation. As a result, apxs cannot be found during PHP compilation.

The default configuration file path in PHP 4.2.3 seems to have changed. The -- With-config-file-Path =/usr/local/lib parameter must be added during compilation. It is useless after I compile PHP. ini for the first time. Last resort. You can only add this parameter.

P.s. it is not guaranteed that the steps described in this article apply to other versions

Appendix: Related Documents

PHP:
Http://www.php.net/get_download.php? Df1_php-4.2.3.tar.gz
Apache:
Http://www.apache.org/dist/httpd/apache_1.3.26.tar.gz
MySQL Server:
Http://www.mysql.com/downloads/down...3.52-1.i386.rpm
Mysql client:
Http://www.mysql.com/downloads/down...3.52-1.i386.rpm

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.