Ubuntu change sudo php path - php

I was struggling with apache2 already installed in ubuntu so I decided to return back to lampp..I have unistalled apache 2 mysql server and phpmyadmin.
The problem is that when I type sudo which php
I get nothing...
So I cannot request e.g. sudo composer create-project laravel/laravel.....
since php is missing for root user..
Although when I type which php I get /opt/lampp/bin/php..
Is it possible to make the root user use the same path..?

You can do this:
Switch to root user
sudo su -
Edit the .bashrc
vi ~/.bashrc
And add a new path to the current one:
export PATH=$PATH:/opt/lampp/bin

Related

phpmyadmin deprecation notice php 8

After upgrading phpmyadmin lots of warnings and notices is being shown while running any task. errors is shown below.
Deprecation Notice in .\vendor\twig\twig\src\Loader\FilesystemLoader.php#40
realpath(): Passing null to parameter #1 ($path) of type string is deprecated
Deprecation Notice in .\vendor\twig\twig\src\Markup.php#35
Return type of Twig\Markup::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Deprecation Notice in .\libraries\classes\Util.php#1936
Function strftime() is deprecated
For PHP 7.3+
Edit the following file : config.inc.php. It can be located in /etc/phpmyadmin/config.inc.php or in /usr/share/phpmyadmin/config.inc.php
$cfg['SendErrorReports'] = 'never';
I had the same issue after upgrading my PHP Version to 8.1 using MAMP's phpmyadmin 5. I could only find out a way to get rid of it thanks to this here:
Go to your phpmyadmin, even if it repeatedly logs deprecation warnings into your page
Select the Preferences Tab in your phpmyadmin interface (you have to be in your main phpmyadmin page for this tab to show up, and not have any table / db selected)
Select Functions and scroll down to Error Reports and select Never send and click on OK to save it. done!
I though that this should technically correspond to this:
$cfg['SendErrorReports'] = 'never';
But as it seems, there are additional steps involved. Anyway, working now!
I just used the standard update function from MAMP PRO itself. Menu MAMP PRO > Check for Updates… There i Run Install on the update phpMyAdmin5 5.1.0 -> 5.2.0. That worked for me.
From now you can turn off errors following these two steps:
Open /usr/share/phpmyadmin/themes/pmahomme/layout.inc.php
Add after <?php error_reporting(0);
Please note that this is not official information!
if you use a wamp server then you can put down the downloaded files from [https://www.phpmyadmin.net/downloads/] of PHPMyAdmin new version on apps folder. then go to alias folder and you have to change in
phpmyadmin.conf
Alias /phpmyadmin "d:/wamp64/apps/phpmyadmin5.2.0/" //change it here
<Directory "d:/wamp64/apps/phpmyadmin5.2.0/"> //change it here
then Save and Restart wamp services
I had the same error message on Debian 11 after switching from php7.4 to php8.1.
What solved the issue was upgrading phpMyAdmin to the latest version manually.
=======Steps to followed=====
Back up phpMyAdmin
You should back up your current phpMyAdmin folder by renaming it.
$ sudo mv /usr/share/phpmyadmin/ /usr/share/phpmyadmin.bak
Create a new phpMyAdmin folder
$ sudo mkdir /usr/share/phpmyadmin/
Change to the directory
$ cd /usr/share/phpmyadmin/
Download and Extract phpMyAdmin
$ sudo wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
Now extract
$ sudo tar xzf phpMyAdmin-*-all-languages.tar.gz
Once extracted, list folder
$ ls
You should see a new folder phpMyAdmin-*-all-languages
We want to move the contents of this folder to /usr/share/phpmyadmin
$ sudo mv phpMyAdmin-*-all-languages/* /usr/share/phpmyadmin
Make a copy of /usr/share/phpmyadmin/config.sample.inc.php
$ sudo cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
Now edit the config.inc.php
$ sudo nano config.inc.php
$cfg['blowfish_secret'] = 'Zbwen/BEAFv:HTbqOROrqakJ;KUMIpV:'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
$ Ctrl+x /* to save the file */
Go to your site/phpmyadmin check all error is cleared.
=================================================
YOU MAY ENCOUNTER THIS ERROR MESSAGE ON PHPMYADMIN /INDEX.PHP
IT MAY SAY SOMETHING LIKE:
The $cfg['TempDir'] (/usr/share/phpmyadmin/tmp) is not accessible.
phpMyAdmin is not able to cache templates and will be slow because of
this.
===SOLUTION==
$ sudo mkdir -p /var/tmp/phpMyAdmin
$ sudo chown www-data:www-data /var/tmp/phpMyAdmin
$ sudo chmod -R 700 /var/tmp/phpMyAdmin
Edit the config.inc.php again
$ sudo nano config.inc.php
add or replace this line
$cfg['TempDir'] = '/var/tmp/phpMyAdmin';
Cleanup --
You can now delete the tar.gz file and the empty folder.
$ sudo rm -rf /usr/share/phpmyadmin/phpMyAdmin-latest-all-languages.tar.gz
And if you’re certain your new phpMyAdmin install is working correctly you can delete the backup folder.
$ sudo rm -rf /usr/share/phpmyadmin.bak

"localhost" always shows "welcome to Nginx" Ubuntu?

I am running Ubuntu 16. I am fairly new to web design but I have set up a LAMP server on my Ubuntu machine and installed WordPress site. I wanted to try to mess around with PHP so I tried to install myphp.
I managed to do this and I realized that I had to install nginx also.
I did this, but my local host always diverts to a message "welcome to Nginx"
I tried to edit the configuration files but could not get it to work?
Is there a guide for installing Nginx and myphp to see phpMyAdmin, after you have already set up a WordPress site?
Like I said I am running Ubuntu 16.04.
You may need to delete the index.html file from the web root. The index.php file should remain.
On Ubuntu+nginx go to html directory using following command
cd /var/www/html/
then find out following index.nginx-debian.html and delete it or edit it as you want
To edit these file open into you editor or use Ubuntu default editor nano.
sudo nano /var/www/html/index.nginx-debian.html
To delete these file run following command.
sudo rm -rf /var/www/html/index.nginx-debian.html
these is the defautl nginx welcome page that why it appear after install, for more information check nginx default configuration file using following command.
sudo nano /etc/nginx/sites-available/default
Thanks

PHP code is rendered as text

I'm using Ubuntu 16.04 and I want to run php files.
I installed Php 7 on it using:
sudo mkdir -p /var/www/html
sudo chown -R $USER:$USER /var/www/html
sudo apt install php
sudo apt install apache2
I created a php file (e.g. test.php) in /var/www/html. I can access it in the browser (e.g. http://localhost/test.php). Instead of executing the <?php ... ?> code, it is displayed as plain text:
I tried to turn short_open_tag to On. So I edited the /etc/php/7.0/fpm/php.ini and enabled it.
Then I ran sudo service php7.0-fpm restart. This didn't make any change in the browser. The php code is still displayed as plain text.
How can I fix this?
You didn't install apache properly, doing an apt-get on apache2 does not install everything.
what #newman stated is correct you can follow that guide, or here is a digitalocean link that is usuable for production server (since you would do this on a droplet). Note this is full stack LAMP, which I would assume you would get to eventually when you want to dab with mysql
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-14-04

Run php file via command line on an ubuntu linux server

I am trying to run a php file on a ubuntu linux server but get a 'command not found' error when i run "php file_name.php"
Searching online, i found an article that suggested I run "sudo aptitude install php5-cli" which I did and restarted apache afterwards but I still get this error.
How do I fix this?
Try this once,
Go to terminal.
whereis php
It will show where is php installed.
Export that path to environment variable using following command
export PATH=$PATH;/path/to/php's/bin directory
Then execute required file..
As follows,
php file_to_execute.php
first make sure that you've installed following packs:
php5
php5-cli
php-pear
like this:
sudo apt-get install php5 php5-cli php-pear
then make sure to configure php safely befor using it.
also make your php file executable ( chmod 700 )
Try the following step :
Open your cmd/console or press ctr+alt+t.
php5 /your/path/to/php_file_name.

How to start with PHP on Ubuntu

I am newbie in PHP. I have successfully installed PHP on Ubuntu, now I want start my first program. I am using gPHPEdit as IDE.
Where should I save .php files that I create? And how to run/test them?
Make sure you have LAMP installed. Do a sudo tasksel and select lamp then hit enter, its gotta be the most simple *amp install ever made. Its a good idea to install phpmyadmin: sudo apt-get install phpmyadmin. After that just copy the files to /var/www/ and then they will show up on http://localhost. I recommended using Eclipse PDT or the Netbeans build for PHP.
You should pick up a book or start following some good tutorials on the web.
If you are just scripting using php, you can save them anywhere and run the php on the terminal using the php command line interpreter.
If you are trying write web scripts (and I think you are), you need to install and configure a web server (typically apache) and save your scripts in the server's document root (typically /var/www). Also, I highly recommend you to read up a little about servers and HTTP and figure out how all this works on the inside before learning to building websites in php.
If you cannot save or copy to var/www/html, to run your php scripts on your browser. If you are using Ubuntu 14.04.
I followed these steps and it worked for me.
Execute sudo su on the terminal.
Enter your password
Execute sudo subl /etc/apache2/sites-available/000-default.conf on your terminal to open this file. Note you can change the subl to any text editor to open the file e.g sudo nano /etc/apache2/sites-available/000-default.conf.
Change DocumentRoot /var/www/html to /home/user/yoursubdir
Save the file and close it.
Execute sudo subl /etc/apache2/apache2.conf on your terminal to open this file.
Add the following to end of the file
<Directory /home/user/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Save and Close the file.
Execute sudo service apache2 restart
Go to your browser, type the URL of your script e.g 127.0.1.1/directory/document.php.
I hope this helps.
remove the index.html file from /var/www/
$ sudo rm index.html
create a new php file there:
$ sudo gedit /var/www/index.php
write in it:
<?php
print_r(phpinfo());
?>
Restart your Apache2 Server :
$ sudo service apache2 restart
OR
$ sudo /etc/init.d/apace2 restart
and point to yout localhost and /index.php
if err arises visit : http://www.allaboutlinux.eu/how-to-run-php-on-ubuntu/
https://www.php.net/manual/en/features.commandline.webserver.php
this is an easy way to test your files in php.
$ cd ~/public_html
$ php -S localhost:8000
then you can go to your browser and enter localhost:8000/myfile.php.

Categories