Under Linux, using source code package compilation to install LAMP can give you 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 are installed, the environment for PHP development has been successfully established.
First you need to download the source code package:
apache: wget http://apache.dataguru.cn//httpd/httpd-2.4.7.tar.bz2mysql: Installed directly with apt-get. The new version of this source code is difficult to find. php: wget http://cn2.php.net/distributions/php-5.5.7.tar.bz2
After downloading the source code package, you need to decompress it. 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 it is tar zxvf
1 Install mysql
First let's install mysql. Because for mysql, the source code package is difficult to find, and there is actually no need to install it through compilation. So the most convenient way is to directly use the apt-get installation method.
sudo apt-get install mysql-client
sudo apt-get install mysql-server
After following the prompts, most of the installation is completed. The prompt requires you to set a username and password, which are the main parameters required to connect to the database.
Next, use this command to check:
mysql -u
username -p
password
Replace username and password with the originally set values, and then check whether mysql is installed successfully.
Under normal circumstances, mysql should be registered as a Linux service. You can check it with the following command:
chkconfig --list
View all registered services.
2 Install apache
When installing apache, first unzip it and enter the source directory:
tar jxvf apache-version.tar.bz2
cd 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 given here represents the installation directory. The htdocsdir parameter represents the localhost file location of the apache server. The enable-module parameter starts the two modules so and rewrite. so is the apache core module used to provide DSO support. rewrite is a module that implements address rewriting. Modules like these cannot be loaded dynamically, and the source code must be recompiled if needed in the future, so it is recommended to load them all.
The enable-shared=max parameter specifies that all apache standard modules except so should be compiled into DSO modules, not within the apache core.
Then it starts:
make
make install
Next, you 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
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 defined later to start the service (in the example, 2345 is used to start the service), and the order in which to shut down and start the service, (in the above example, the order to shut down the service is 8, and the order to start is 92)
descriptions: Description of the service
Next, change the execution permissions of the file and add services:
chmod +x /etc/rc.d/init.d/httpd
chkconfig –add httpd
This completes the configuration of apache.
Note: There may be missing packages when configuring apache. I encountered zlib before. You can download the source code package of zlib and configure the installation in the same way. You can specify the installation directory during configuration, such as is/usr/local/zlib
Then when configuring apahce again, you need to add
--with-zlib=/usr/loca/zlib
Let’s add this dependency.
The same goes for other bags.
3 php installation
Also perform the operations of decompressing and entering 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 other libraries, use --with-library name=[library installation directory]
The --enable-debug parameter will output a lot of useful information when an error occurs, allowing you to quickly locate the error.
-enable-maintainer-zts will make PHP think about its behavior in a multi-threaded environment and allow you to catch common program errors that do not cause problems in a non-threaded environment, but do in a multi-threaded environment. Your extension becomes unavailable.
Next enter
make
make install
Common mistakes can be found at this link:
http://lyp.cn/350_how-to-fix-php-compile-errors
If there is no yum package, it is OK to find the corresponding apt-get package.
Next configure in apache:
vim /usr/local/apache/conf/httpd.conf
Then add in AddType:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Add index.php to DirectoryIndex so that Apache can recognize the index in PHP format
DirectoryIndex index.html index.php
Restart the apache service for the changes to take effect:
sudo /etc/init.d/httpd restart
After that, copy the php configuration file:
cp ../php-5.2.10/php.ini.dist /usr/local/php/lib/php.ini
Then you can verify it and create info.php in the network folder:
Then open the browser and enter localhost/info.php
If the output is normal, the configuration is complete.
http://www.bkjia.com/PHPjc/621618.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/621618.htmlTechArticleUnder Linux, use the source code package compilation method to install LAMP, which can load the internal compilation mechanism and PHP modules. Have a more in-depth understanding of other aspects. The so-called LAMP refers to LinuxApacheMy...