


PHP extension and embedding--how to configure the LAMP environment under Linux_PHP tutorial
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.htmlFor .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 -uusername -ppassword 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.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











From start to finish: How to use php extension cURL for HTTP requests Introduction: In web development, it is often necessary to communicate with third-party APIs or other remote servers. Using cURL to make HTTP requests is a common and powerful way. This article will introduce how to use PHP to extend cURL to perform HTTP requests, and provide some practical code examples. 1. Preparation First, make sure that php has the cURL extension installed. You can execute php-m|grepcurl on the command line to check

The SNMP extension for PHP is an extension that enables PHP to communicate with network devices through the SNMP protocol. Using this extension, you can easily obtain and modify the configuration information of network devices, such as CPU, memory, network interface and other information of routers, switches, etc. You can also perform control operations such as switching device ports. This article will introduce the basic knowledge of the SNMP protocol, how to install the SNMP extension of PHP, and how to use the SNMP extension in PHP to monitor and control network devices. 1. SN

To extend PHP function functionality, you can use extensions and third-party modules. Extensions provide additional functions and classes that can be installed and enabled through the pecl package manager. Third-party modules provide specific functionality and can be installed through the Composer package manager. Practical examples include using extensions to parse complex JSON data and using modules to validate data.

The combination of PHP and HTML is a common technology in web development. PHP can embed dynamic content in HTML files and implement auxiliary functions, which greatly improves the interactivity and customizability of the website. This article will introduce three techniques for embedding code and provide specific code examples for reference. 1. Use PHP tags to embed code. The most common way is to use PHP tags () to embed PHP code into HTML files to display dynamic content. For example, you can use PHP

1.UncaughtError:Calltoundefinedfunctionmb_strlen(); When the above error occurs, it means that we have not installed the mbstring extension; 2. Enter the PHP installation directory cd/temp001/php-7.1.0/ext/mbstring 3. Start phpize(/usr/local/bin /phpize or /usr/local/php7-abel001/bin/phpize) command to install php extension 4../configure--with-php-config=/usr/local/php7-abel

The POSIX extensions for PHP are a set of functions and constants that allow PHP to interact with POSIX-compliant operating systems. POSIX (PortableOperatingSystemInterface) is a set of operating system interface standards designed to allow software developers to write applications that can run on various UNIX or UNIX-like operating systems. This article will introduce how to use POSIX extensions for PHP, including installation and use. 1. Install the POSIX extension of PHP in

PHP is a popular server-side language that can be used to develop web applications and process files. The ZipArchive extension for PHP is a powerful tool for manipulating zip files in PHP. In this article, we’ll cover how to use PHP’s ZipArchive extension to create, read, and modify zip files. 1. Install the ZipArchive extension. Before using the ZipArchive extension, you need to ensure that the extension has been installed. The installation method is as follows: 1. Install

PHP and WebDriver extensions: How to simulate user clicks and input operations In recent years, with the rapid development of web applications, automated testing has become more and more important. In automated testing, simulating user operations is a key link, which allows us to test and verify our applications more accurately. In PHP development, we usually use SeleniumWebDriver to implement automated testing. SeleniumWebDriver is a powerful tool which can simulate
