Compiling and installing LAMP (Linux Apache MySQL PHP) is a common method of building a web application development environment. The following are general steps:
Install the Apache HTTP server:
a. Use the package management tool to install Apache on the Linux system. For example, on an Ubuntu system, you can install it using the following command:
sudo apt updatesudo apt install apache2
b. Start the Apache service:
sudo systemctl start apache2
Install the MySQL database server:
a. Use the package management tool to install the MySQL server. For example, on an Ubuntu system, you can install it using the following command:
sudo apt update sudo apt install mysql-server
b. During the installation process, you will be prompted to set the MySQL root password. Please set a secure password.
c. Start the MySQL service:
sudo systemctl start mysql
Install the PHP interpreter:
a. Use the package management tool to install PHP. For example, on an Ubuntu system, you can install it using the following command:
sudo apt update sudo apt install php
b. Install commonly used PHP extensions and libraries, such as MySQL extension, gd extension, etc.:
sudo apt install php-mysql php-gd
Configure the Apache server to support PHP:
a. Open the Apache configuration file /etc/apache2/apache2.conf
.
b. Add the following lines at the end of the file to enable the PHP module:
<FilesMatch \.php$> SetHandler application/x-httpd-php</FilesMatch>
c. Save the configuration file and close.
d. Restart the Apache service:
sudo systemctl restart apache2
Test the LAMP environment:
a. Create a PHP file, such as info.php
, and add the following content to the file:
<?phpphpinfo();?>
b. Move the file to Apache's web root directory:
sudo mv info.php /var/www/html/
c. Visit in the browser. If you can see the PHP information page, it means that the LAMP environment has been successfully established.
By following the above steps, you can compile and install the LAMP environment and start developing and deploying applications on your web server. Please note that the specific installation steps may vary depending on the Linux distribution you are using, so please refer to the appropriate documentation and guides for installation.
The above is the detailed content of Baidu search: Lan Yiyun [Compile and install LAMP]. For more information, please follow other related articles on the PHP Chinese website!