A quick Guide to fixing errors encountered by beginners setting up the Database and Server in PHP with Linux OS

As a Beginner to backend web development with PHP, I had to install a Web Server like Apache and a database server like MySQL. There are various web servers for running PHP programs like WAMP and XAMPP but I chose to use XAMPP because it is supported in both Windows and Linux.

I used Ubuntu, a Linux Operating System, to install XAMPP and MySQL. After the installation, I encountered some errors while starting Apache and MySQL.

LIST OF SOME OF THE ERRORS WITH SOLUTIONS

  • To start XAMPP, I ran this command in the terminal and got the following output:

    sudo /opt/lampp/lampp start

Screenshot from 2020-10-31 09.38.26.png Apache failed to start and it said another web server is already running. To fix this, simply run this command:

sudo netstat -nap | grep :80

You’ll see apache2 and there is 3–4 digit numbers before it, mine is 985

sudo kill [number]

Then restart the server with

sudo /opt/lampp/lampp start

Screenshot from 2020-10-31 10.13.38.png You'll see that your Apache server is now running.

  • The control panel starts right after installation of XAMPP in Ubuntu but I was unable to start the panel after I closed it. I also tried to search for XAMPP in my system but I could not find it. After a series of googling I found a command that starts the control panel for Ubuntu OS. I followed these steps:

  • In your terminal type,

    cd /opt/lampp/

  • Then list the files in that directory by running this in your terminal:

    ls Screenshot from 2020-10-31 10.32.49.png

  • You'll see a file in the list of files with a name, "manager-linux-x64.run", run this command:

    sudo chmod 755 manager-linux-x64.run

You won't see any output on the screen.

  • The control panel will be opened immediately after running this last command:

    sudo ./manager-linux-x64.run Screenshot from 2020-10-31 10.39.59.png

  • Another issue I had while setting up a project in php was the permission set on files by default in Ubuntu. In the path where xampp is located in Ubuntu

/opt/lampp/

There you would find the 'htdocs' folder which will house all your php projects. You will not be granted access to create a folder in this directory

/opt/lampp/htdocs/

To fix this, run this command in your terminal

sudo chmod 777 -R /opt/lampp/htdocs

  • I also encountered this error with MySQL Screenshot from 2020-11-01 11.26.10.png To fix this, run this command in your terminal:

sudo service mysql stop

Then restart the server and run this command:

sudo /opt/lampp/lampp status

Refresh localhost/phpmyadmin Screenshot from 2020-11-01 11.33.16.png

No Comments Yet