Php extension and embedding-how to configure the LAMP environment in linux

Source: Internet
Author: User
Tags php development environment
In linux, install LAMP by compiling the source code package. you can have a deeper understanding of the internal compilation mechanism and php module loading. LAMP refers to Linux & amp; 43; Apache & amp; 43; Mysql & amp; 43; Php. after these software is installed

In linux, install LAMP by compiling the source code package. you can have a deeper understanding of the internal compilation mechanism and php module loading.

The so-called LAMP refers to Linux + Apache + Mysql + Php. after these software is installed, the php development environment is successfully established.

First, download the source code package:

Apache: wget requests. Php: wget requests
..Tar.bz2 is tar jxvf .tar.gz is tar zxvf
1. install mysql
First, install mysql. For mysql, the source code package is hard to find, and it is not necessary to install it by compiling. Therefore, the most convenient method is to directly use the apt-get installation method. Sudo apt-get install mysql-clientsudo apt-get install mysql-server after following the prompts, most of the installation is completed. In the prompt, set the user name and password. this is the main parameter required to connect to the database. Next we will use this command to perform a test: mysql-u Username-P PasswordReplace username and password with the set value and check whether mysql is successfully installed. Under normal circumstances, mysql should be registered as a linux service. Run the following command to check all registered services: chkconfig -- list.

2. install apache
When installing apache, first decompress and enter the source directory: tar jxvf apache-version.tar.bz2cd apache-version/
Then configure apache:./configure? Prefix =/usr/local/apache? Enable-module = so? Enable-module = rewrite? Enable-shared = max? Htdocsdir =/var/www &&
The prefix parameter provided here represents the installed directory. The htdocsdir parameter represents the location of the localhost file on the apache server. Enable-module parameters start two modules: so and rewrite. So is the core apache module used to provide DSO support. Rewrite is the module that implements address rewriting. Such modules cannot be dynamically loaded, and the source code must be re-compiled if necessary. Therefore, we recommend that you load them. The enable-shared = max parameter is used to compile all apache standard modules other than so into the DSO module, rather than the apache core. Then start: makemake install
Next we need to set apache as a linux service: first copy the startup file to the service directory: cp/usr/local/apache2/bin/apachectl/etc/init. d/httpd

Open the service file vim/etc/init. d/httpd.

In #! Add the following two lines to/bin/sh: # chkconfig: 345 85 15
# Description: Start and stops the Apache HTTP Server.
Chkconfig: the subsequent definition defines the running level of the startup service (in this example, enable 2345 to start and change the service), and the order of closing and starting the service (in the above example, the order of closing the service is 8, set the start sequence to 92)
Descriptions: description of the service to be modified

Next, change the file execution permission 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 packages during apache configuration. I used to encounter zlib. you can download the source code package of zlib and install it in the same way, you can specify the installation directory during configuration, for example,/usr/local/zlib. when you configure apahce again, add -- with-zlib =/usr/loca/zlib to add this dependency. The same applies to other packages.
3. php installation
Similarly, you need to extract 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 want to add another library, use the -- with-Library name = [Library installation directory] -- enable-debug parameter to output a lot of useful information when an error occurs, to quickly locate errors. The-enable-maintainer-zts enables PHP to think about the behavior in a multi-threaded environment, and allows you to capture common program errors that will not cause problems in a non-thread environment, however, in a multi-threaded environment, your extensions become unavailable. Next go to makemake install common errors can see the following link: http://lyp.cn/350_how-to-fix-php-compile-errors
If there is no yum package, find the corresponding apt-get package.
Configure vim/usr/local/apache/conf/httpd in apache. conf and add: AddType application/x-httpd-php in AddType. phpAddType application/x-httpd-php-source. phps

Add index. php in DirectoryIndex so that Apache can identify the index in PHP format.

DirectoryIndex index.html index. php


Restart the apache service to make the change take effect: sudo/etc/init. d/httpd restart
And then copy the php configuration file: cp ../php-5.2.10/php. ini. dist/usr/local/php/lib/php. ini

Then you can verify it. create info. php in the network folder: Open the browser and enter localhost/info. php. if the output is normal, the configuration is complete.

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.