PHP extensions and embedding--How to configure the lamp environment under Linux _php Tutorial

Source: Internet
Author: User
Tags php development environment zts
Under Linux, the use of the source package to compile the way to install lamp, the internal compilation mechanism and PHP module loading and other aspects of a more in-depth understanding.

The so-called lamp refers to the linux+apache+mysql+php, after the installation of these software, even if the successful construction of PHP development environment.

The first is to download the source package:

Apache:wget Http://apache.dataguru.cn//httpd/httpd-2.4.7.tar.bz2mysql: Directly with the apt-get installed, this new version of the source code is difficult to find. Php:wget http://cn2.php.net/distributions/php-5.5.7.tar.bz2 After downloading the source package, to be decompressed, the basic Decompression command is as follows: http://www.cnblogs.com/ Eoiioe/archive/2008/09/20/1294681.html
For. TAR.BZ2 is tar jxvf for. tar.gz is tar zxvf
1 Installing MySQL
First say install MySQL. Because for MySQL, the source package is difficult to find, in fact, there is no need to compile the way to install. So the most convenient way is to directly use the Apt-get installation method. sudo apt-get install mysql-clientsudo apt-get Install Mysql-server Follow the prompts to complete most of the installation. In the prompt to set the user name and password, this is the main parameters to connect the database. Next, use this command for testing: mysql-u username-P PasswordReplace the username and password with the value you set, and then see if MySQL is installed successfully. Under normal circumstances, MySQL should be a service registered as Linux. You can take a look at the following command: Chkconfig--list View all registered services.

2 Installing Apache
When installing Apache, first unzip and enter the source directory: Tar jxvf apache-version.tar.bz2cd apache-version/
Then configure Apache to:./configure–prefix=/usr/local/apache–enable-module=so–enable-module=rewrite–enable-shared=max– Htdocsdir=/var/www &&
The prefix parameter given here represents the installed directory. The Htdocsdir parameter represents the localhost file location of the Apache server. The Enable-module parameter launches and so and rewrite two modules. So is the Apache core module used to provide DSO support. Rewrite is the module that implements address rewriting. Like these modules are not dynamically loaded into, and later need to recompile the source code, so the recommendation is loaded in. The Enable-shared=max parameter specifies that all Apache standard modules other than so are compiled into the DSO module, not within the Apache core. Then start: Makemake Install
Next, you need to set Apache as a Linux service: first copy the boot file to the service directory: CP/USR/LOCAL/APACHE2/BIN/APACHECTL/ETC/INIT.D/HTTPD

Then open the service file: vim/etc/init.d/httpd

Add the following two lines after #!/bin/sh: #chkconfig: 345 85 15
#description: Start and stops the Apache HTTP Server.
Chkconfig: The run level that is defined later to enable the start service (for example, to enable 2345 to start the service), and the order in which services are closed and started (the order in which the services are turned off in the example above 8, the order in which the boot is 92)
Descriptions: Description of the change service

Next, change the file execution permissions and add the service: chmod +x/etc/rc.d/init.d/httpd
Chkconfig–add httpd
This completes the configuration of Apache.
Note: There may be a lack of packets in the Apache configuration, I have encountered the zlib, you can download the zlib source package, and the same configuration installation form, in the configuration can specify the installation directory, such as the/usr/local/ Zlib then configure APAHCE again with--with-zlib=/usr/loca/zlib to add this dependency. The same is true of other packages.
3 PHP Installation
Also perform operations to decompress and enter the directory. Next is the configuration process:./configure--prefix=[php installation directory]--with-config-file-path=[php installation directory--with-apxs2=[apache installation directory]/bin/apxs-- With-mysql=[mysql installation directory]--enable-debug--enable-maintainer-zts
If you also want to add another library, use the--with-library name =[Library to install the directory]--enable-debug parameter will be in error when the output of a lot of useful information, so as to quickly locate the error. While-enable-maintainer-zts will let PHP think about the behavior in a multithreaded environment and allow you to catch common program errors that do not cause problems in a non-threaded environment, but make your extension unusable in a multithreaded environment. Next go to makemake install common errors can be seen below this link: http://lyp.cn/350_how-to-fix-php-compile-errors
If there is no Yum package, find the corresponding Apt-get package is OK.
Next configure in Apache: vim/usr/local/apache/conf/httpd.conf then add in AddType: AddType application/x-httpd-php. Phpaddtype Application/x-httpd-php-source. Phps

Add index.php to DirectoryIndex in order for Apache to recognize the index in PHP format

DirectoryIndex index.html index.php


Restart the Apache service for changes to take effect: sudo/etc/init.d/httpd restart
After that, to copy the PHP configuration file: CP. /php-5.2.10/php.ini.dist/usr/local/php/lib/php.ini

You can then verify that the info.php is established under the network folder: Then open the browser, enter localhost/info.php if the output is normal, then the configuration is complete.

http://www.bkjia.com/PHPjc/621618.html www.bkjia.com true http://www.bkjia.com/PHPjc/621618.html techarticle Under Linux, the use of the source package to compile the way to install lamp, the internal compilation mechanism and PHP module loading and other aspects of a more in-depth understanding. The so-called lamp refers to the Linuxapachemy ...

  • 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.