Home  >  Article  >  Backend Development  >  How to install php under linux

How to install php under linux

王林
王林Original
2023-05-06 20:03:061125browse

The open source nature of Linux brings great freedom to users, and also makes some developers like to use it for server-side application development. In Linux systems, installing PHP is a very common requirement. This article will introduce how to install PHP in Linux systems.

As an open source server-side scripting language, PHP itself also runs on many operating systems, including Linux. Installing PHP under Linux requires a combination of Apache and MySQL. First you need to install Apache.

Use apt-get command to install Apache in Linux system. First, open a terminal window and enter the following command:

sudo apt-get update

Note: Administrator privileges are required to complete this operation. If you do not have administrator rights, please contact the system administrator, or use another account that already has administrator rights.

After executing the above command, enter the following command to install Apache:

sudo apt-get install apache2

The user will get a prompt message asking whether to continue the installation. After confirmation, the system will automatically download and install Apache.

When the Apache installation is complete, enter the terminal window and enter the following command to update the system installer:

sudo apt-get update

Next, run the following command to install PHP and MySQL:

sudo apt-get install php5 mysql-server-5.5

This command will download and install PHP, MySQL and other related programs from the server.

The installation program will prompt the user to enter a MySQL root user password. Users need to set a password and confirm the password. During this process, the installer also prompts the user to confirm basic settings and permissions for MySQL.

After the installation is complete, users can verify whether PHP has been successfully installed by running the following command:

php -v

If everything is normal, this command will display the version number of PHP and other related system information.

If you need to install phpmyadmin, you can use the following command:

sudo apt-get install phpmyadmin

This command will download and install phpmyadmin. Then, users can access phpmyadmin through the browser and manage the MySQL database.

You need to pay attention to the following points when installing PHP on a Linux system:

  1. When installing PHP, MySQL will be installed at the same time. If you need to use other databases, users need to download and install them separately.
  2. Users may need to set the root user password when installing MySQL.
  3. PHP’s configuration files in Linux systems are usually located in /etc/php5/apache2/php.ini or /etc/php5/cli/php.ini. Users need to operate these files with caution to avoid configuration errors. error causing the system to crash.

Through the above method, installing PHP in the Linux system allows users to develop applications on the server side. In addition, in the open source environment of the Linux system, users can also freely choose to use other open source software to meet their own needs.

The above is the detailed content of How to install php under linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:why to install phpNext article:why to install php