This article mainly shares with you an example tutorial on setting up a PHP development environment on Ubuntu. Following this article, I hope it can help you complete the process of setting up a PHP development environment on Ubuntu.
Apache installation
First install the apache server, and use apt-get to download and install the software under ubuntu.
After entering the password, the download and installation will begin. After installation, open the browser and enter localhost to check whether the installation is successful
If it is displayed as above, it means the installation is successful.
PHP installation
Here I am going to install the PHP7.0 version. Enter at the command line: sudo apt-get install php7.0
After the installation is complete, enter: php -v to check whether PHP is installed successfully
After PHP and Apache are installed, you need to enable Apache to recognize and parse PHP files. We first search Check if there are any plug-ins suitable for PHP7. Enter the command: apt-cache search libapache2-mod-php
You can see that one of the search results is PHP7.0 version Yes, we will install this: sudo apt-get install libapache2-mod-php7.0
Next we can just write a php file to see if it can be parsed and accessed. Enter the command: cd /var/www/html Switch to the apache project directory and create a new file: sudo vim test.php
After saving, visit the browser: localhost/test. php
If everything is normal, you will see some information about php.
Mysql installation
The next step is to install the database Mysql. The database needs to install both the server and the client. Enter the command: sudo apt-get install mysql-server mysql-client
During the installation process, you will be prompted to set the login password for the root account. After entering it, select OK to continue the installation
After the installation is completed, enter mysql -V View the installed version information
Similarly, we also need to enable mysql to interact with php and install the mysql plug-in for php: sudo apt-get install php7.0 -mysql
Finally we can also install some commonly used php extensions
At this point, the software about lamp is installed Completed, finally you can install composer: sudo apt-get install composer
After installation, enter the command: composer Check whether it is successful
As shown in the figure, the installation process is complete.
Related recommendations:
How to build a PHP development environment with Docker
Detailed installation of the PHP development environment under Windows
The above is the detailed content of An example tutorial on setting up a PHP development environment on Ubuntu. For more information, please follow other related articles on the PHP Chinese website!