Localhost not working after basic installation on WSL - php

I am trying to install a LAMP working environnement but for some reason nothing happen. The lack of error messages makes me wonder what to look for.
I followed the Ubuntu installation process :
sudo apt install apache2 php libapache2-mod-php mysql-server php-mysql
At that stage, localhost should display the "It works!" message but it doesn't.
I have been restarting the apache service several times with no effect:
sudo service apache restart
it looks to be fine anyway.
I have checked the following files as advices on some online tutorial :
/etc/apache2/sites-available/000-default.conf
/etc/apache2/apache2.conf
I am atually clueless on what to troubleshoot at that point.
Any ideas ?

You have apache2 installed. Try running this instead:
sudo service apache2 restart
I tried installing LAMP on WSL too. But I was lucky. I followed these steps:
Step 1: Update and Upgrade the ubuntu subsystem
sudo apt-get update && sudo apt-get upgrade
Step 2: Start bash.exe type:
sudo apt-get install lamp-server^
remember the caret (^) at the end of the command.
add these 2 lines in /etc/apache2/apache2.conf :
Servername localhost
AcceptFilter http none
then you can start apache :
/etc/init.d/apache2 start
Step 3: Test Web Server, PHP and MySQL
Test Apache: Open Web Browser and type this URL:
http://127.0.0.1 or http://localhost
Test PHP: Create below file (info.php) and place it in /var/www/html
<?php
phpinfo();
?>
Open Web Browser and type this URL:
http://127.0.0.1/info.php or http://localhost/info.php
Test MySQL: Type below command in bash prompt
service mysql start
mysql -uroot -ppassword
Hope it works for you.

Related

Why does my website loads infinitely after I tried the sleep method?

So I was playing with the sleep method of php. I coded sleep(99999); Now my website won't load lol. Is it because of that? How can I fix it?
I think you can just restart apache, or php-fpm if you are using php-fpm. And why in the world would you try that!
You must restart your server if restarting your web server didn't work. Or, it will just be stuck in a delay until the sleep time ends.
I would advise you not to play with a production server. Use a test server for these tests. Because it is not as easy to reset these issues.
For example, when you are using shared hosting, you cannot restart apache yourself.
How do I setup a test server:
Install some software like XAMPP if you are using Windows in your home PC. Or, if you are using Linux, you can just install apache and php using the following commands on:
Ubuntu/Debian: sudo apt install apache2 php
CentOS/Fedora: sudo yum install epel-release, and sudo yum install httpd php or sudo dnf install httpd php
Arch Linux/Manjaro: sudo pacman -S apache php php-apache

lamp stack is not working properly in linux mint

I am a newbie to Linux. I was trying to install lamp stack in linux-mint. I used this command sudo apt-get install apache2, and looks like this is working. I enter the localhost in my browser and it shows the apache2 ubuntu default page. but the problem is when I create a info.php file in /var/www/html this directory with some basic PHP code <?php phpinfo(); ?>, instead of showing PHP details and versions, it is showing me the the raw PHP code in the browser <?php phpinfo(); ?>. I've tried some solution from StackOverflow
but nothing works. how can I fix this?
You did not have PHP installed or maybe your php is not enable.
you can do:
For install -> sudo apt-get install php php-mysql
For enable ->
sudo a2enmod php7
sudo service apache2 restart
this is important sudo service apache2 restart

phpmyadmin page shows source code, Ubuntu 16.04 installed with Vagrant and Puphpet

I installed virtualbox and vagrant, then went to https://puphpet.com and downloaded a package with Ubuntu 16.04. The relevant parts of that package are PHP, MySQL and Apache. It works now, I managed to connect to the server and PHP is running correctly (I installed magento on it).
Now I'm trying to install phpmyadmin, however after running the commands:
sudo apt-get install phpmyadmin
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin.conf
sudo service apache2 restart
When i go to http://{serverIP}/phpmyadmin/ I get the source code of the file that's supposed to be the phpmyadmin login page, like this:
Source
What could be causing this? It can't be that PHP isn't installed correclty, cause I managed to install Magento and it works fine, so what could be the problem?
Edit:
Also in the /etc/apache2/apache.conf file, I added this line at the end of the file:
Include "/etc/phpmyadmin/apache.conf"
Solved it, I needed to run:
sudo apt-get install libapache2-mod-php7.0
I was missing that extension. Also after I installed that extension I got an error saying:
AH00534: apache2: Configuration error: More than one MPM loaded.
I fixed that by runnning:
sudo a2dismod worker
Not sure why this happened.

Unable to install phpmyadmin in ubuntu 14.04

I'm following this link: click here!
I ran
sudo apt-get update && sudo apt-get install phpmyadmin
Then I restarted apache2 by using this command:
sudo service apache2 restart
Then I went to http://localhost/phpmyadmin in browser and I got this error:
Not Found
The requested URL /phpmyadmin was not found on this server.
Where did things go wrong?
P.S: This is the 3rd time that I'm trying to install phpmyadmin.
Look at this: http://tecadmin.net/install-phpmyadmin-in-ubuntu/
You have to edit your conf file
You must have a LAMP server in order to work with phpmyadmin.
In your case, I think you haven't installed MySQL.
You can install the entire LAMP by the following command.
sudo apt-get install lamp-server^
It’s important to remember the caret (^) at the end of the command.
During the installation, MySQL will ask you to set a root password.
Step by step installation of LAMP server is described in this link.
As you have already installed phpmyadmin, you now need to configure apache.
sudo nano /etc/apache2/apache2.conf
Add the following to the bottom of the file:
# phpMyAdmin Configuration
Include /etc/phpmyadmin/apache.conf
Restart apache with the following command.
sudo service apache2 restart
Now phpmysql will be working in http://localhost/phpmyadmin/.

How can I run things off Netbeans on Ubuntu? Localhost not working

When I try to run something on Netbeans using Ubuntu, a window opens but nothing actually works. I'm pretty sure it's because my http://localhost/ isn't working. So, how do I get that to work so I run files on Netbeans? Any specific step-by-step instructions would be great. I heard I had to install Apache, but I'm not sure.
If you want to run PHP stuff outside NetBeans, there are several steps you have to take:
Install apache web server - sudo apt-get install apache2
Install PHP and connect it with apache - sudo apt-get install php5 sudo apt-get install libapache2-mod-php5
Restart apache - sudo /etc/init.d/apache2 restart
Now, your Document Root (web root) should be at /var/www.
Place your files there and access them with http://localhost/desired_file.php with some web browser or just execute them with php compiler on the command line.
Depending on your distro/version, there might be some configurations to be done, but that's the basic stuff you need to run PHP outside NetBeans

Categories