Ubuntu is based on Debian so it should apply to Ubuntu as well. I have tested this on latest Debian Testing (on SparkyLinux). I usually use WordPress and CakePHP on my localhost so I included instructions at the end to make them work perfectly.
Warning: This config is not designed with security in mind, only for convenience of desktop users. If you are setting up for server, please refer to proper manuals.
Note: This config is experimental. There might be better way to do some aspects. But it does work for my specific needs so I made it available. Please use carefully.
Install Apache and Mysql/Mariadb:
sudo apt install apache2 mariadb-server
Install PHP and other required libraries:
sudo apt install php php-intl php-mysql
Install phpMyAdmin:
sudo apt install phpmyadmin
Note: Remember to press space to select "apache2" (not lighttpd) in the screen that comes, then press tab and enter. If asks for "Configure database for phpmyadmin with dbconfig-common?" I chose no.
Now, to start the local server:
sudo systemctl start apache2 mariadb
To test, open http://localhost
on a webbrowser and then test http://localhost/phpmyadmin
. They should open without problems.
If you can't access http://localhost/phpmyadmin
then run:
sudo nano /etc/apache2/apache2.conf
then add at the end:
Include /etc/phpmyadmin/apache.conf
then:
sudo systemctl restart apache2
Windows XAMPP has root user with no password. To keep it here same:
Run:
sudo nano /etc/phpmyadmin/config.inc.php
then add these in proper place:
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['AllowNoPasswordRoot'] = true;
$cfg['Servers'][$i]['AllowNoPassword'] = true;
Also, comment these lines:
//$cfg['Servers'][$i]['controluser'] = $dbuser;
//$cfg['Servers'][$i]['controlpass'] = $dbpass;
To clear mysql root password (to use blank password), run:
sudo mysql -u root
then a mysql shell will open. Enter these on the shell:
use mysql;
update user set plugin='' where User='root';
flush privileges;
\q
source: https://superuser.com/a/1027838
You can skip this if you did not set a password for phpMyAdmin. It may be that it is not possible to login to phpMyAdmin with root and with a password after install. This is normal since password is not set yet. To set a password, run:
sudo mysql_secure_installation
Go through the process and set the password. If it does not work then:
sudo systemctl stop mariadb
sudo mysqld --skip-grant-tables &
sudo mysql -u root mysql
Replace YOURNEWPASSWORD with your new password:
UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;
Now you should be able to login with the new password on root user.
source: https://askubuntu.com/a/893899
sudo groupadd www-data
# maybe not needed, it should be automatically created w/apache
sudo usermod -a -G www-data $USER
# to add your user to www-data group
Run:
sudo nano /etc/apache2/envvars
then add:
export APACHE_RUN_USER=your_username
sudo nano /etc/apache2/mods-available/rewrite.load
uncomment:
LoadModule rewrite_module modules/mod_rewrite.so
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
sudo nano /etc/apache2/apache2.conf
find:
<Directory /var/www/>
under the tag make the line:
AllowOverride None
to:
AllowOverride All
sudo systemctl start apache2 mariadb
sudo systemctl stop apache2 mariadb
sudo systemctl restart apache2 mariadb
php --ini | grep Loaded | awk '{ print $4 }'
Mine says /etc/php/7.2/cli/php.ini
so I used it on later instructions.
First, install composer: sudo apt install composer
sudo nano /etc/php/7.2/cli/php.ini
extension=intl ; uncomment
extension=pdo_mysql ; uncomment
; under [intl]
; add...
intl.default_locale = en_utf8
intl.error_level = E_WARNING
extension=sockets // for websockets ; uncomment
extension=mbstring // uncomment
sudo systemctl restart apache2
source: https://stackoverflow.com/a/29405081
ln -s /var/www/html ~/html
sudo chown -R $USER:www-data /var/www/html/
This will create a shortcut named html
on your home and allow you to modify files without root, like a normal directory.
As this is experimental config, please report any issues.