To test a website on my PC before uploading it to the webhoster, I can simply open the html files with a browser. But if the site contains PHP code, a local web server is needed. So I installed apache2 and php8. But what do I need to do further? The browser cannot find 'localhost' yet, and /var/www does not exist yet.
Le 09/08/2022 à 12:28, Siard a écrit :
To test a website on my PC before uploading it to the webhoster, I can simply open the html files with a browser. But if the site contains PHP code, a local web server is needed. So I installed apache2 and php8. But what do I need to do further? The browser cannot find 'localhost' yet, and /var/www does not exist yet.
look in /srv? jdd -- http://dodin.org http://valeriedodin.com
On Tue, 9 Aug 2022 12:53 +0200, jdd@dodin.org wrote:
Le 09/08/2022 à 12:28, Siard a écrit :
To test a website on my PC before uploading it to the webhoster, I can simply open the html files with a browser. But if the site contains PHP code, a local web server is needed. So I installed apache2 and php8. But what do I need to do further? The browser cannot find 'localhost' yet, and /var/www does not exist yet.
look in /srv?
In /srv there are 4 directories: tftpboot, www, www/cgi-bin and www/htdocs. They are all empty. If I move the website to /srv/var/www, the browser still does not know what to do with the php files.
On 09/08/2022 13:17, Siard wrote:
On Tue, 9 Aug 2022 12:53 +0200, jdd@dodin.org wrote:
Le 09/08/2022 à 12:28, Siard a écrit :
To test a website on my PC before uploading it to the webhoster, I can simply open the html files with a browser. But if the site contains PHP code, a local web server is needed. So I installed apache2 and php8. But what do I need to do further? The browser cannot find 'localhost' yet, and /var/www does not exist yet.
look in /srv?
In /srv there are 4 directories: tftpboot, www, www/cgi-bin and www/htdocs. They are all empty. If I move the website to /srv/var/www, the browser still does not know what to do with the php files. Have you added "php8" to the list of modules defined by the variable APACHE_MODULES in /etc/sysconfig/apache2? This is not done automatically when you install the PHP packages.
If you modify that file, you then need to restart the Apache server (systemctl restart apache2.service). HTH Ph. A. -- *Philippe Andersson* Unix System Administrator IBA Particle Therapy | Tel: +32-10-475.983 Fax: +32-10-487.707 eMail: pan@iba-group.com <http://www.iba-worldwide.com> Disclaimer | Use of IBA e-communication<https://iba-worldwide.com/disclaimer> The contents of this e-mail message and any attachments are intended solely for the recipient (s) named above. This communication is intended to be and to remain confidential and may be protected by intellectual property rights. Any use of the information contained herein (including but not limited to, total or partial reproduction, communication or distribution of any form) by persons other than the designated recipient(s) is prohibited. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free. Ion Beam Applications does not accept liability for any such errors. Thank you for your cooperation.
Philippe Andersson wrote:
Have you added "php8" to the list of modules defined by the variable APACHE_MODULES in /etc/sysconfig/apache2? This is not done automatically when you install the PHP packages.
If you modify that file, you then need to restart the Apache server (systemctl restart apache2.service).
At least I made a big step forward with this; the site in /srv/www/htdocs could be viewed at http://localhost. However, the browser still could not open php files, but after following Georg Pfuetzenreuter's instructions it worked. Anyway, thank you very much.
Zitat von Siard <shiems+opensuse@mailbox.org>:
To test a website on my PC before uploading it to the webhoster, I can simply open the html files with a browser. But if the site contains PHP code, a local web server is needed. So I installed apache2 and php8. But what do I need to do further? The browser cannot find 'localhost' yet, and /var/www does not exist yet.
Easier way: Use a docker or a VM to seperate the content to to be sure thatb the test environment is not changes. Ralf
The default webroot on openSUSE is /srv/www/htdocs. In addition to installing the PHP cli and the Apache httpd you may need to: - `zypper in apache2-mod_php8` # install Apache PHP module - `a2enmod php` # enable the module - `rchttpd restart` # restart httpd An alternative to mod_php is php-fpm, but it's a bit more complicated and not needed for your use case. Best, Georg On 8/9/22 12:28, Siard wrote:
To test a website on my PC before uploading it to the webhoster, I can simply open the html files with a browser. But if the site contains PHP code, a local web server is needed. So I installed apache2 and php8. But what do I need to do further? The browser cannot find 'localhost' yet, and /var/www does not exist yet.
You can use the builtin test http server for this cd ~/your_html_files php -S localhost:8000 https://www.php.net/manual/en/features.commandline.webserver.php On 09.08.22 13:29, Georg Pfuetzenreuter <georg@syscid.com> wrote:
The default webroot on openSUSE is /srv/www/htdocs. In addition to installing the PHP cli and the Apache httpd you may need to:
- `zypper in apache2-mod_php8` # install Apache PHP module - `a2enmod php` # enable the module - `rchttpd restart` # restart httpd
An alternative to mod_php is php-fpm, but it's a bit more complicated and not needed for your use case.
Best, Georg
On 8/9/22 12:28, Siard wrote:
To test a website on my PC before uploading it to the webhoster, I can simply open the html files with a browser. But if the site contains PHP code, a local web server is needed. So I installed apache2 and php8. But what do I need to do further? The browser cannot find 'localhost' yet, and /var/www does not exist yet.
Op Tue, 9 Aug 2022 15:06 +0200, sven.marquardt@mail.smarquardt.space wrote:
You can use the builtin test http server for this cd ~/your_html_files php -S localhost:8000
https://www.php.net/manual/en/features.commandline.webserver.php
Yes, that works. It does have to be started every time before opening the site though. I just wonder if there aren't other ways to change the webroot, such as editing DocumentRoot in /etc/apache2/default-server.conf. I just haven't got that to work yet.
Georg Pfuetzenreuter wrote:
The default webroot on openSUSE is /srv/www/htdocs.
That's interesting to know. I just came from the Debian world, it's /var/www/html there.
In addition to installing the PHP cli and the Apache httpd you may need to:
- `zypper in apache2-mod_php8` # install Apache PHP module - `a2enmod php` # enable the module - `rchttpd restart` # restart httpd
The rchttpd command does not appear to exist in TW. Is it a typo? I've done a reboot now. I also noted that, following these instructions, 'php' was added to APACHE_MODULES in /etc/sysconfig/apache2, after I had already added 'php8' as suggested by Philippe Andersson's post, and the browser still could not open php files. But after removing 'php' and leaving 'php8' there, it finally worked. Thanks to you both!
On 2022-08-09 15:28, Siard wrote:
Georg Pfuetzenreuter wrote:
The default webroot on openSUSE is /srv/www/htdocs.
That's interesting to know. I just came from the Debian world, it's /var/www/html there.
In addition to installing the PHP cli and the Apache httpd you may need to:
- `zypper in apache2-mod_php8` # install Apache PHP module - `a2enmod php` # enable the module - `rchttpd restart` # restart httpd
The rchttpd command does not appear to exist in TW. Is it a typo? I've done a reboot now.
rcapache2 restart or systemctl restart apache2 -- Cheers / Saludos, Carlos E. R. (from 15.3 x86_64 at Telcontar)
Yes, apologies, it's `rcapache2 restart`, or, more commonly found, `systemctl restart apache2`. Glad your setup is working now! :-) On 8/9/22 15:28, Siard wrote:
Georg Pfuetzenreuter wrote:
The default webroot on openSUSE is /srv/www/htdocs.
That's interesting to know. I just came from the Debian world, it's /var/www/html there.
In addition to installing the PHP cli and the Apache httpd you may need to:
- `zypper in apache2-mod_php8` # install Apache PHP module - `a2enmod php` # enable the module - `rchttpd restart` # restart httpd
The rchttpd command does not appear to exist in TW. Is it a typo? I've done a reboot now. I also noted that, following these instructions, 'php' was added to APACHE_MODULES in /etc/sysconfig/apache2, after I had already added 'php8' as suggested by Philippe Andersson's post, and the browser still could not open php files. But after removing 'php' and leaving 'php8' there, it finally worked. Thanks to you both!
participants (7)
-
Carlos E. R.
-
Georg Pfuetzenreuter
-
jdd@dodin.org
-
Philippe Andersson
-
Ralf Prengel
-
Siard
-
sven.marquardt@mail.smarquardt.space