Update 01-en.md

This commit is contained in:
Christoph 2023-04-11 09:35:11 +02:00 committed by GitHub
parent c4994b3593
commit c61a2481eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,66 +15,87 @@ available_languages: en
---
# Introduction
This tutorial describes how to Install Apache2 with php8.2-fpm on a Ubuntu Server.
The tutorial is only testet on Ubuntu 22.04, but should also work on Ubuntu 18.04 and 20.04.
This tutorial describes how to install Apache2 with php8.2-fpm on an Ubuntu Server.
The tutorial has only been tested on Ubuntu 22.04, but should also work on Ubuntu 18.04 and 20.04.
# Requirements
* Server (root or vps) with Ubuntu Server 22.04
* Server (Root or VPS) with Ubuntu Server 22.04.
# Step 1 - Check for system updates
Check your system for updates and install them by running this command:
# Step 1 - Check for System updates
Check your System for updates and install them before.
```
apt-get update && sudo apt-get -y upgrade
```
# Step 2 - Install Apache2
Install Apache2 by running the following command:
```
apt-get install apache2
```
# Step 3 - Install PHP8.2-FPM
Because PHP8.2 is not yet included in the Ubuntu repository, we need to add the PPA repository
Because PHP8.2 is not yet included in the Ubuntu repository, we need to add the respective PPA repository by running:
```
add-apt-repository ppa:ondrej/php
```
Then update package sources.
Next, update package sources:
```
apt-get update
```
Install PHP8.2 with commonly used modules (bz2,curl,mbstring,intl,bcmath,xml,mysql,zip,gd,mbstring,imagick). Here you can add modules or remove some.
Now, we will install PHP8.2 with some commonly used modules (bz2,curl,mbstring,intl,bcmath,xml,mysql,zip,gd,mbstring,imagick). You can add or remove modules if you already know your specific requirements:
```
apt-get install php8.2-{fpm,cli,bz2,curl,mbstring,intl,bcmath,xml,mysql,zip,gd,mbstring,imagick}
```
Enable the config of Apache2 php8.2-fpm.\
In the config the mods proxy_fcgi and setenvif are used, so enable them too.
Next, enable the Apache2 php8.2-fpm confic, as well as the mods proxy_fcgi and setenvif by running:
```
a2enmod proxy_fcgi setenvif
a2enconf php8.2-fpm
```
Restart apache
Restart Apache2:
```
systemctl reload apache2
```
Check the installation
Edit the following file by running:
```
nano /var/www/html/test.php
```
Add following:
And add:
```
<?php
phpinfo();
?>
```
Use a Browser and go to http://ip_of_your_server/test.php \
Server API Should be FPM/FastCGI.
Now, use a browser and head to http://ip_of_your_server/test.php \
Note that the server API should be FPM or FastCGI.
![Check PHP](images/check_php.png)
Now you have succesfully installed Apache2 with php8.2-fpm.
The Path of the php.ini is /etc/php/8.2/fpm/php.ini \
If you need, we can increase memory-limit and maximum of upload filesize. (Other values can changed too)
At this point, you have successfully installed Apache2 with php8.2-fpm. Note that the path of the php.ini is '/etc/php/8.2/fpm/php.ini'.
If you need, we can increase the memory limit and the maximum file size for uploads as well as other values by editing:
```
nano /etc/php/8.2/fpm/php.ini
```
```diff
- memory_limit = 128M
+ memory_limit = 256M
@ -83,19 +104,27 @@ nano /etc/php/8.2/fpm/php.ini
- post_max_size = 8M
+ post_max_size = 16M
```
Restart php-fpm.
To apply the changes, restart php8.2-fpm:
```
/etc/init.d/php8.2-fpm restart
```
Then verify the values with the test.php Script.
# Step 4 - (Optional) Add a new V-Host
The Server is only Listening by IP. If you have a Domain we can add a new V-Host.
Now, verify the values via the test.php script.
# Step 4 - (Optional) Add a new virtual host
The server is only listening on IP. If you have a domain, we can add it as a new virtual host.
To do this, run:
```
mkdir /var/www/vhostname
nano /etc/apache2/sites-available/vhostname.conf
```
Insert the following content and replace vhost and yourdomain.de with your names.
Insert the following content and replace vhost and yourdomain.de with your data:
```
<VirtualHost *:80>
ServerName www.yourdomain.de
@ -111,32 +140,38 @@ Insert the following content and replace vhost and yourdomain.de with your names
</Directory>
</VirtualHost>
```
Enable V-Host and restart Apache
You need to enable the virtual host and restart Apache2:
```
a2ensite vhostname
systemctl reload apache2
```
# Step 4.1 - (Optional) Install SSL Certificate from Let's Encrypt
Install Certbot
# Step 4.1 - (Optional) Install a TLS Certificate from Let's Encrypt
To secure your server via a TLS certificate, simply install Certbot:
```
apt-get install certbot python3-certbot-apache
```
Generate and install SSL-Certificate
Next, generate and install the TLS certificate by running the following command and following the steps provided. Please note that you will have to replace yourDomain.de,www.yourAlais.de with your specific data:
```
certbot --apache -d yourDomain.de,www.yourAlais.de
```
# Step 5 - (Optional) Enable Http/2 Protocol
Enable the apache http2 Module and restart apache
# Step 5 - (Optional) Enable HTTP/2 Protocol
If needed, you can easily enable the Apache2 HTTP2 Module by simply running:
```
a2enmod http2
systemctl restart apache2
```
# Conclusion
You have installed Apache2 with PHP8.2-FPM. Optional SSL installed with http/2 Protocol.\
If you have multiple Domains you can repeat step 4 to add more domains.
The server is not yet secured and should still be secured. This Tutorial are only basic steps for installation of Apache2 with php8.2-fpm.
You have now installed Apache2 with PHP8.2-FPM. Optionally, you have also installed a TLS certificate with HTTP/2 Protocol. If you have multiple domains you can repeat Step #4 to add these domains. Please keep in mind that the server is not yet secure and you should take additional steps to ensure its security. This tutorial is only focused on the installation of Apache2 with php8.2-fpm.
# Licence
@ -159,4 +194,4 @@ By making a contribution to this project, I certify that:
3) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.
4) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the licence(s) involved.
4) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the licence(s) involved.