Home>Article>Backend Development> Detailed explanation of ubuntu php environment settings
ubuntu php setting method: first update the source list; then open the "terminal window" and enter the command "sudo apt-get install php5" to install php; then install and configure the apache environment, and install the php5-gd module ;Finally create the "info.php" file.
Ubuntu PHP environment configuration
1. Update source list
Open" Terminal window", enter "sudo apt-get update"-->Enter-->"Enter the password of the root user"-->Enter, and that's it.
If you install PHP directly without running this command, you will see "Several software packages cannot be downloaded, causing PHP to fail to install normally. Some package contents may fail to download, ignore it and just go to the next step.
2. Install php
Open the "terminal window" and enter "sudo apt-get install php5"-->Enter-->Enter "y"-->Enter -->The installation is complete.
To determine whether PHP is installed, you can enter the command "php -v" to check the PHP version
##3 .Let Apache support php. I have installed apache by default. If it is not installed, please install and configure the apache environment first.Open the "terminal window" and enter "sudo apt-get install libapache2-mod-php5" -->Enter-->The installation is complete.
4. Install the php5-gd moduleOpen the "terminal window" and enter "sudo apt-get install php5-gd"- ->Enter-->The installation is complete.
5. Use gedit to create the info.php file under "/var/www"Open the "Terminal Window", Enter "sudo gedit /var/www/info.php"-->Enter-->In the editor, enter "e2d0e752df2c971bca1fcef6e50119b4"-->Save, the file is created successfully .
6. Test whether Apache can parse the php web pageEnter "127.0.0.1\info. php"-->The PHP version information page appears, indicating that the PHP installation and configuration is successful and the program has run perfectly.
Commonly used commands in configuration to restart apachesudo /etc/init.d/apache2 restart
chgrp -R www-data /var/www chmod -R 775 /var/www //有效 chmod -R 777 /var/www //有效For more related knowledge, please visit
PHP Chinese website!
The above is the detailed content of Detailed explanation of ubuntu php environment settings. For more information, please follow other related articles on the PHP Chinese website!