Table of Contents
Apache Introduction
Demo environment
Install Apache
Common problems and solutions
The web address of Apache is at There?
How to restart Apache
如何查看Apache当前启用的mods
如何修改php版本
php提示缺少某些拓展怎么办
总结
Home Backend Development PHP8 Super fine! Ubuntu20.04 installs Apache+PHP8 environment

Super fine! Ubuntu20.04 installs Apache+PHP8 environment

Mar 21, 2023 pm 03:26 PM
php apache

This article brings you relevant knowledge about PHP, and mainly shares with you the whole process of installing Apache in the Ubuntu20.04 LTS environment. We will also provide solutions to some of the pitfalls that may arise. Friends who are interested can take a look below. I hope it will be helpful to everyone.

Apache Introduction

Apache is an open source web server software provided by the Apache Foundation. It is a multi-purpose, portable, and A modifiable HTTP server, one of the commonly used Web server software;

Apache server supports mainstream operating systems, including UNIX, Linux , Mac OS X, Windows, etc.

Normally, it can be used in conjunction with MySQL database, Perl and PHP script interpreter to form LAMPArchitecture, you can build a dynamic website system. Apache is the world's number one and most popular Web server-side software. It is the Web server-side software used by the vast majority of websites.

Demo environment

Web page environment: Apache (Others are also available)

PHP version: 8.0

Operating system: Ubuntu 20.04

Install Apache

After entering the ubuntu system, first update apt:

sudo apt update
Copy after login

process You will be prompted whether to continue. Enter y and press Enter to continue.

Super fine! Ubuntu20.04 installs Apache+PHP8 environment

If you are stuck in this step or have network problems, you can update the apt source to Tsinghua source. For details, see the reference material ( Pay attention to selecting the correct ubuntu version): https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/ Use the command lsb_release -a to view the system version information. After modifying /etc/apt/source.list, use the command source /etc/profile to refresh the configuration.

Then install Apache, its name in apt is apache2:

sudo apt-get install apache2
Copy after login

After the installation is complete, visit http://localhost/See if the following interface appears:

If you are using a virtual machine, you can query the internal network IP of the current virtual machine through the ip addr command, and then add it from your own Open the web page on your computer to view it. Of course, you can also directly enter localhost in the virtual machine.

At this time, the server only has Apache installed, but php is not installed, so php cannot be parsed temporarily.

We need to install php, just install it in apt source. Here we take php8.0 as an example:

sudo apt-get install php8.0
Copy after login
Copy after login

You may encounter errors when installing directly here:

E: Unable to locate package php8.0
E: Couldn't find any package by glob 'php8.0'
Copy after login

You need to install a third-party PPA source, execute the following commands line by line:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php8.0
Copy after login

The method to install php extension is: sudo apt-get install php8.0-<extension name></extension>, for example sudo apt-get install php8.0-mysqli.

After the installation is complete, you need to enable php8.0 in Apache. Use the following command to enable it:

a2enmod php8.0复制代码
Copy after login

Create a new one in the /var/www/html directory index.php file, write in it:

<?php phpinfo();	
?>
Copy after login

The way to create a new file is to first cd to the corresponding directory: cd /var/www/html, then enter the command: touch index.php.

Now revisit http://localhost/index.php, and you should be able to see php related information.

Super fine! Ubuntu20.04 installs Apache+PHP8 environment

At this point, you have successfully completed the setup of the Apache server, and the php program is ready to run. .

Common problems and solutions

The following are some common problems and solutions when installing and using Apache:

The web address of Apache is at There?

The default is in /var/www/html. Of course, you can specify different paths for different domain names.

How to restart Apache

Use the command systemctl restart apache2.

如何查看Apache当前启用的mods

可以使用httpd -M命令查看apache的已经启用的mods

也可以在Apache的安装目录conf/httpd.conf文件中的LoadModule指令中查看。

用指令sudo ls -la /etc/apache2/mods-available/可以查看所有启用的mods。

如何修改php版本

修改对应的mods即可,例如我要从php7.0变为php8.0。

首先安装php8.0:

sudo apt-get install php8.0
Copy after login
Copy after login

同时还要重新安装各种PHP拓展,如果需要的话。

用命令关闭当前的php7.0 mod。

a2dismod php7.0
Copy after login

在用命令开启新的php8.0 mod。

a2enmod php8.0
Copy after login

此时可以用php探针再查一下php版本。

php提示缺少某些拓展怎么办

比如php提示缺少mysqli拓展。

打开/etc/php/8.0/apache2/php.ini,找到extionsion=mysqli并将前面的;删除,重启Apache。

Super fine! Ubuntu20.04 installs Apache+PHP8 environment

如果还是提示缺少拓展,可能是你没有安装对应的拓展。安装完成后重启Apache即可。

总结

以上是对Apache安装过程的全部教程,感谢大家的阅读。

推荐学习:《PHP视频教程

The above is the detailed content of Super fine! Ubuntu20.04 installs Apache+PHP8 environment. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles