Install and configure the Apache + PHP + MySQL + phpMyAdmin source package in Linux

Source: Internet
Author: User
Tags php and mysql

1. Install apache2.2.22
1. Go to the official website to download http://httpd.apache.org/download.cgi
2. Decompress
Tar-zxvf httpd-2.2.22.tar.gz
3. Create the target folder (note that all of the following operations are performed under the root user)
Mkdir/usr/local/apache2
That is to say, wait for the installed apache2 to be installed in this folder.
4. Configuration
Return to the original decompressed folder
./Configure -- prefix =/usr/local/Apache -- enable-module = shared
Add the following parameters. Otherwise, PHP cannot be used.-enable-module = shared indicates that Apache can dynamically load modules.
5. Compile
Make
6. Installation
Make install
7. Start, restart, and stop. Switch to the directory/usr/local/apache2/bin after installation.
./Apachectl-K start
./Apachectl-K restart
./Apachectl-K stop
8. configuration file (for the most basic configuration)
Edit the/usr/local/apache2/CONF/httpd. conf file
Find:
Addtype application/X-compress. Z
Addtype application/X-gzip. GZ. tgz
Add:
Addtype application/X-httpd-PHP. php (enable apcche to support PHP)
Addtype application/X-httpd-PHP-source. PHPs
Find:
<Ifmodule dir_module>
Directoryindex index.html
</Ifmodule>
Add:
<Ifmodule dir_module>
Directoryindex index.html index. php
</Ifmodule>
Find:
# Servername www.example.com: 80
To:
Servername 127.0.0.1: 80 or servername localhost: 80
Remember to remove the previous "#"
9. Test
Enter http: // 127.0.0.1 in the browser
If it works appears! It indicates the operation is successful.

10. Modify the default web site directory

The default directory is "/usr/local/apache2/htdocs". Modify the Apache configuration file httpd. conf. For example, you can create a/home/gyw/website directory as the Apache site directory.

Find the DocumentRoot line and change it to DocumentRoot "/home/gyw/Website"

Find <directory> and change this line to <directory "/home/gyw/Website">

Ii. Install php5.3.16
1. Download
Http://www.php.net/downloads.php
2. Decompress
Tar-zxvf php-5.3.16.tar.gz
3. Create the target folder
Mkdir/usr/local/PHP
That is to say, wait for the PHP to be installed in this folder.
4. Configuration
Return to the decompressed folder.

./Configure -- prefix =/usr/local/PHP
-- With-apxs2 =/usr/local/Apache/bin/apxs

Note that there is a-with-apxs2 =/usr/local/Apache/bin/apxs option, where apxs is generated when Apache is installed,apxsIs a tool for compiling and installing extension modules for the Apache HTTP Server.mod_soProvidedLoadModuleThe command is loaded to the Apache server at runtime. In my understanding, this tool dynamically loads the PHP module into Apache.
5. Compile
Make
6. Test Compilation
Make Test
7. Installation
Make install
8. Configuration File

CP/usr/local/src/php-5.3.16/PHP. ini-development/usr/local/PHP/lib/PHP. ini
Copy the php. ini-development in the source code to/usr/local/PHP/lib/PHP. ini and rename it PHP. ini.
9. Restart Apache
10. Test
Create a PHP file test. php under Apache htdocs with the following content:
<? PHP
Phpinfo ();
?>
Enter http: // 127.0.0.1/test. php In the browser
If the PHP configuration is successful, if nothing is entered, it indicates that the configuration fails. Repeat the preceding steps or find the cause.

If you decide to change the configuration option after installation, repeat the last three steps configure, make, and make install, and then restart Apache to make the new module take effect. Apache does not need to be re-compiled.

Iii. Install MySQL

1. Download
Download mysql-5.1.65.tar.gz from the official website (note the source code package)
2. Decompress
Tar-zxvf mysql-5.1.65.tar.gz
3. Create the target folder
Mkdir/usr/local/MySQL
That is to say, wait for the MySQL to be installed in this folder.
4. Configuration
./Configure -- prefix =/usr/local/MySQL/-- With-extra-charsets = all
The 2nd parameters indicate that all character sets can be used in Ubuntu.
5. Compile
Make
6. Installation
Make install
7. Start
MySQL does not start automatically. You must initialize the MySQL database as follows:
CD/usr/local/MySQL/bin
Sudo./mysql_install_db -- user = root
Note: The final root here refers to the user who can operate the database. It can be the current user or a new user. It is different from the root user on Linux and can be named by yourself.
./Mysqld_safe -- user = root & this command is used to start the daemon process of the MySQL service. In addition, this command is required at the end of "&" because you want the daemon to run in the background.
Here, the root is the one
8. Create a password for the root user
./Mysqladmin-u Root Password '123'
If the root user has set a password, use the following method:
./Mysqladmin-u Root Password oldpass '000000'
9. Test
Mysql-u root-P
You will be prompted to enter the password.
123456
If mysql> is displayed, the connection is successful. Run the following command to create a database, create a table, and add a record to prepare for subsequent tests.

Mysql> Create Database gywtest;
Mysql> Use gywtest;

Mysql> Create Table student (ID int (4) not null primary key auto_increment, stuname char (20 ));

Mysql> insert into student (stuname) values ('Tom ');

Note that each command is followed by a semicolon. If the preceding command is successful, you can use this test later.

4. Combine PHP with MySQL

1. reconfigure PHP and change the configuration options. You only need to repeat the last three steps of configure, make, and make install during PHP installation, and then restart Apache to make the new module take effect, apache does not need to be re-compiled.

2. Configuration

. /Configure -- prefix =/usr/local/PHP -- with-apxs2 =/usr/local/apache2/bin/apxs -- With-mysqli =/usr/local/MySQL/bin/mysql_config note mysql_config path
3. Compile make

4. Install make install

5. Test and write a page named test. php, which is stored in the Apache web directory, and test the database created with the command above.

<? PHP
$ Mysqli = new mysqli ();
$ Mysqli-> connect ('localhost', 'root', '000000', 'gywtest ');
// Create a query
$ Sqlstr = 'select * from student ';
// Send the query to MySQL
$ Result = $ mysqli-> query ($ sqlstr );
While ($ ROW = $ result-> fetch_object ())
{
$ Name = $ row-> stuname;
Echo $ name;
}
?>

Output result: Tom. Verify that PHP and MySQL are configured correctly.

5. Install phpMyAdmin, a client management tool

1. Download phpmyadmin-3.5.2.2-all-languages.tar.gz to the official website.

2. Decompress

Tar-zxvf phpMyAdmin-3.5.2.2-all-languages.tar.gz

3. Rename the decompressed folder to phpMyAdmin and put it under the Apache site directory.

4. Enter http: // localhost/PHPmyAdmin/index. php In the browser to view the management interface.

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.