Detailed explanation of ubuntu php environment settings

藏色散人
Release: 2023-03-02 09:32:01
Original
3460 people have browsed it

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.

Detailed explanation of ubuntu php environment settings

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 ""-->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.


Additional knowledge points:

a: If php cannot run, restart the apache server first.

Restart papche

Commonly used commands in configuration to restart apachesudo /etc/init.d/apache2 restart

b: If the info file cannot be saved or modified, or the file cannot be written inside www

At the same time, execute the following command to grant read and write permissions to the www folder.


chgrp -R www-data /var/www
chmod -R 775 /var/www //有效
chmod -R 777 /var/www //有效
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template