Install apache2 + PhP5 + MySql in Debian source code

Source: Internet
Author: User
Tags install openssl

Install apache2 + PhP5 + MySql in Debian source code

Author: add lost objects:
Keyword: PhP5

Debian is really great, but some updates are very slow. For example, the update of lamp is actually very slow.
No way, install the source code.
(In fact, Apache and MySQL are safe to be installed using the Debian package.
Apt-Get install apache2-common apache2-mpm-perfork mysql-common mysql-server mysql-Client
I just compiled it. For MySQL, it is quite troublesome to install the database image using the Debian package.
).
1. Install MYSQL:
Compiling MySQL is the least expensive, because its document install-source has already been very detailed.
Download mysql-4.0.20.tar.gz first.
Shell> groupadd MySQL
Shell> useradd-G MySQL
Shell> tar zxvf mysql-4.0.20.tar.gz
Shell> Cd mysql-4.0.20
Shell>./configure -- prefix =/usr/local/MySQL (I installed the system to use/usr/local as an independent partition to install this type of source code compilation stuff)
Shell> make & make install
Shell> support-files/my-medium.cnf/etc/My. CNF
Shell> support-files/MySQL. Server/etc/init. d/MySQL
Shell> chmod + x/etc/init. d/MySQL # Then select MySql through rcconf to automatically start the service every time.
Shell> Cd/usr/local/MySQL
Shell>/bin/mysql_install_db -- user = MySQL
Shell> chown-r root.
Shell> chown-r MySQL VaR
Shell> chgrp-r MySQL.
Shell> bin/mysqld_safe -- user = MySQL & or shell>/etc/init. d/MySQL start
OK, complete!

2. Install apache2:
Download httpd-2.0.49.tar.gz.
Shell> tar zxvf httpd-2.0.49.tar.gz
Shell>./configure -- prefix =/usr/local/apache2 -- enable-so -- enable-Rewrite -- enable-mod-shared -- enable-SSL -- enable-track-vars
Shell> make & make install
Installation is complete.
The configuration file httpd. conf should be modified here, but it still needs to be modified after installing PHP.

3. Install PhP5:
Download php-5.0.0rc3.tar.gz.
Shell> tar zxvf php-5.0.0RC3.tar.gz
Because I want PHP to support MySQL, PostgreSQL, and gD2 (GIF, JPEG, and PNG) at the same time, many options are specified:
Shell>. /configure -- with-apxs2 =/usr/local/apache2/bin/apxs/-- With-mysql =/usr/local/MySQL -- With-Gd -- With-mm/-- enable-Gd -Native-TTF -- enable-FTP -- With-zlib/-- With-OpenSSL -- With-pgsql -- With-PNG-dir -- With-TTF/-- With-FreeType-dir -- -JPEG-dir -- With-zlib-Dir
For Debian, libmm-Dev (APT-Get install libmm-Dev) must be installed with the -- with-mm parameter)
Use the -- with-Gd parameter to install the GD2 library (APT-Get install libgd2-dev)
To use -- With-OpenSSL, you must install OpenSSL and libssl-Dev.
-- With-PNG and -- With-JPEG both require the corresponding libraries, libpng and libjpeg.
It is very convenient to compile the source code in Debian, because all a few software packages can be directly installed through apt-Get install. Very convenient.
Then compile:
Shell> make & make install
Shell> cp php. ini-Dist/usr/local/lib/PHP. ini

Next, modify/usr/local/apache2/CONF/httpd. conf.
Loadmodule php5_module modules/libphp5.so # This line of PhP5 installation should have been automatically added.
Add the following two rows:
Addtype application/X-httpd-PHP. php. phtml
Addtype application/X-httpd-PHP-source. PHPs
Modify servername and other parameters as needed.
Remember to modify the adddefacharcharset line. If you do not want to display Chinese characters, it is garbled.
Adddefacharcharset gb2312
Then restart apache2:
Shell>/usr/local/apache2/bin/apachectl restart
Add the index. php file to/usr/local/apache2/htdocs. (If DocumentRoot is modified, this path is not used ).
<? PHP
Phpinfo ();
?>
Enter the following in the browser:
Http: // localhost/index. php
The system configuration information should be displayed.

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.