start apache & mysql from desktop script in ubuntu - mysql

on lubuntu 14.04 (desktop) i have installed apache web server and mysql server and, because of low ram (only 1024mb), i decided to remove them from startup (with sudo update-rc.d -f apache2 remove and by editing the /etc/mysql/my.cnf file ).
now, every time i want to do some development i have to sudo service apache2 start and sudo service mysql start in a terminal. wich is fine.
my question is: could those commands be executed from a .sh file? a file that i can double-click it from my desktop?
so far i got
#!/bin/sh
sudo service apache2 start
sudo service mysql start

You can do it with scripts which you mentioned.
Apache:
#!/bin/sh
sudo service apache2 start
Mysql
#!/bin/sh
sudo service mysql start

Related

How to completely delete Bitnami WAMP server?

I installed Bitnami WAMP and I tried to uninstall it and use AMPPS instead of Bitnami WAMP.
I deleted Bitnami WAMP but it wasn't deleted completely.
I can still find WMAP files in 'Setting > Service' : 'wampstack Apache' and 'wampstack MySQL' files are still there.
And, When I run AMPPS, I can't run Apache and PHP 7.1.
An error message occurs and it says "Apache port:80 is being used by another application"
fyi, This is how I uninstall Bitnami WAMP :
1. Run Bitnami uninstall file
2. Remove Bitnami folder
- Even after running that file, Bitnami folder still remained, so I remove that folder by GitBash.
- rm -r -f Bitnami
How Can I remove Bitnami WAMP perfectly?
I searched google a lot but couldn't find how to do. ;(
I need your help.
You can find the PID of the Apache and Mysql processes using netstat:
sudo netstat -nlp | grep apache
and
sudo netstat -nlp | grep mysql
And then stop them:
sudo kill -9 PID
After stopping the processes it should be possible to remove the folder.

how to use my database on AWS

I'm using linux, and I've been trying to import my database mysql to my AWS instance, I downloaded all the tools.
php, mysql-server,apache2 and the AWS instance is running.
I'm using FileZilla to upload the files, and I'm connected to the server fine, but whenever I try to open myphpadmin it won't work, showing me weird things on the screen.
Adding a pic for reference
It's not about the AWS; you should prepare the LAMP env at first.
To install and start the LAMP web server with the Amazon Linux AMI
sudo yum update -y
sudo yum install -y httpd24 php70 mysql56-server php70-mysqlnd
sudo service httpd start
sudo chkconfig httpd on
For more info read the following article
Tutorial: Install a LAMP Web Server with the Amazon Linux AMI

How do I update phpMyAdmin in Ubuntu?

I have an old phpMyAdmin installation (contains my training and jobs data). I want to update it to the latest version and I want to keep my data safe while updating it. Is there any way to do it by running some commands on the terminal? Is my data erased if I uninstall phpMyAdmin?
Here is how to upgrade/downgrade on Ubuntu.
Note: The following instruction only works if you previously (and correctly) installed phpMyAdmin with the command line and use APACHE as a web server.
I suppose that you already have a working phpMyAdmin, but the version isn't the one you want. For instance, Ubuntu is shipping the 4.6.x version which doesn't work properly with PHP 7.2.
Check the version you want on:
https://www.phpmyadmin.net/files/
On your server
cd /usr/share/
rm -rf phpmyadmin
then adapt this line with the correct version number
wget https://files.phpmyadmin.net/phpMyAdmin/4.8.0/phpMyAdmin-4.8.0-all-languages.zip
unzip phpMyAdmin-4.8.0-all-languages.zip
rm phpMyAdmin-4.8.0-all-languages.zip
mv phpMyAdmin-4.8.0-all-languages phpmyadmin
Note: If unzip don't work, install it with: sudo apt-get install unzip
Check permissions
Now you should be good.
The owner of /usr/share/phpmyadmin should be root:root on a default installation. This should be fine but if you face some permissions issues, you can try to let Apache be the owner:
# only if you have permissions issues
chown -R www-data:www-data /usr/share/phpmyadmin
chmod -R 755 /usr/share/phpmyadmin
You can also restart Apache
sudo service apache2 reload
Troubleshooting
Note: Depending on your PHP version, you may need to install additional libraries.
For example, to resolve the error about missing mysqli and mysql extensions (update the command to reflect your PHP version):
sudo apt-get install php5.6-mysql
phpmyadmin is mysql client, so it will not affect your database if you uninstall phpmyadmin.
I update phpmyadmin by using terminal commands:
First you have to add repository to get phpmyadmin :
sudo add-apt-repository ppa:nijel/phpmyadmin;
and then update it to get the latest version of software in repositories :
sudo apt-get update;
after that, you can get it (install, you need to uninstall the older version first if you have) :
sudo apt-get install phpmyadmin;
Oh, make sure you are connected to the internet
Using ubuntu? i think it will be better if you ask it in ubuntu forum.
may it helps
------ UPDATE -------
If you find the phpmyadmin version you get from ppa is not the latest one, you can find the latest version here and install it manually (not from repo).
Downloaded phpmyadmin can be installed in /var/www/html/ or in your working directory (public_html or something you've defined). Just extract the zip and move extracted folder to /var/www/html/. And don't forget to change the permission of the phpmyadmin folder to 777(it may not safe, but works fine).
Here is the how:
extract downloaded file
unzip phpMyAdmin-4.6.6-all-languages.zip
move to /var/www/html/, you might need sudo.
if you're not sudoer, move it into your working directory (e.g. public_html), and rename the folder to 'phpmyadmin'
sudo mv phpMyAdmin-4.6.6-all-languages /var/www/html/phpmyadmin
change the permission
sudo chmod 777 -R /var/www/html/phpmyadmin
and then you can access phpmyadmin via http://localhost/phpmyadmin.
If you put the phpmyadmin in public_html, you might want to create a symlink into it from /var/www/html, so you can access phpmyadmin as usual.
phpMyAdmin is only client for MySQL database, it doesn't contain your data. It's all saved in database, so nothing will be deleted even if you delete phpMyAdmin.
To update phpMyAdmin from repository you can follow steps from this thread.
1- check your phpmyadmin version from GUI.
2- Download Latest version of phpMyAdmin HERE
Use the below command to download the latest version of phpMyAdmin into /opt or /usr/src directory
# wget https://files.phpmyadmin.net/phpMyAdmin/4.8.3/phpMyAdmin-4.8.3-all-languages.zip
Notes to install unzip package: apt-get install unzip
# unzip phpMyAdmin-4.8.3-all-languages.zip
3- Find phpMyAdmin Installation Directory
Use the below command to search the phpMyAdmin Installation Directory on your system
# /usr/share/phpMyAdmin
4- Remove/Delete phpMyAdmin content
/usr/share/phpmyadmin is correct phpMyAdmin installation directory, Just Delete/Remove everything from that directory
# cd /usr/share/phpMyAdmin/
# rm -Rf *
5- Move/Copy New phpMyAdmin content
Use the below command to copy all the new phpMyAdmin content to /usr/share/phpmyadmin.
# cd /opt/phpMyAdmin-4.8.3-all-languages
# mv * /usr/share/phpMyAdmin/
6- Restart Apache, MySQL or MariaDB service.
Start/Restart the service in SysVinit Systeme
# service restart httpd
# service restart mysql
Start/Restart the service in Systemd Systeme
# systemctl restart httpd.service
# systemctl restart mariadb.service
7- Now Check New version of phpMyAdmin
Navigate your browser to http://localhost/phpmyadmin, Now you are using latest version 4.8.3 of phpMyAdmin.
Reference
sudo su
cd /usr/share/
rm -rf phpmyadmin
wget https://files.phpmyadmin.net/phpMyAdmin/4.8.4/phpMyAdmin-4.8.4-all-languages.zip
unzip phpMyAdmin-4.8.4-all-languages.zip
mv phpMyAdmin-4.8.4-all-languages phpmyadmin
chown -R www-data:www-data /usr/share/phpmyadmin
chmod -R 755 /usr/share/phpmyadmin
sudo service apache2 reload

Start mysql and apache from cmd

I installed xampp and now I want start apache and mysql from command line and also I won't install services.
I use some command and it's worked but after start mysql (for example) cmd is open, I want close but after close cmd mysql stopped.
You can't. Either you run it from the command line, having to keep the shell open, or you run it as a service after which you can close cmd (if you used cmd at all).
I would choose the latter, and I can't understand why you won't install it as a service.
If you are using XAMPP, you can start your servers by doing:
sudo /opt/lampp/lampp start
Otherwise, you can start your servers with this one:
sudo service apache2 start && sudo service mysql start

How make mysql start automatically ? (linux-cli only)

How can i make mysql start every time the system boot ? I need that in a dedicated server(ubuntu distro) in which i have my blog, but every time the server goes down, on booting mysql is stopped.
Btw i can use only command line.
update-rc.d allows setting init script links on Ubuntu and Debian Linux systems to control what services are run by init when entering various runlevels. It should be able to add mysql to the list of services to run at boot:
sudo update-rc.d mysql defaults
If you later want to disable running mysql on bootup:
sudo update-rc.d mysql remove
You can do it by using sysv-rc-conf, on debian based you can install it with sudo apt-get install sysv-rc-conf
then you can choose what start at boot with a simple X on the name of the deamon, all via command line
Run the following command to see your mysql current status:
/sbin/chkconfig mysqld --list
it will return a line such as below:
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
to make mysql start every time the system boots, type the following:
sudo /sbin/chkconfig mysqld on
Result now from '--list' is:
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
No answer helped. Finally chkconfig and update-rc.d did not work with MySQL on my machine.
Solution, I had a file /etc/init/mysql.override which contained
manual
i just deleted that file
$ sudo rm /etc/init/mysql.override
Deleting
/etc/init/mysql.override
did the job in my case (HostEurope VPS with Ubuntu 12.04)
I had the same problem, so I checked how I disabled it in the first place:
https://askubuntu.com/questions/138487/how-to-keep-apache-and-mysql-from-starting-automatically
Check your /etc/init/mysql.conf to make sure you don't have start on commented out (like I did).
# MySQL Service
description "MySQL Server"
author "Mario Limonciello <superm1#ubuntu.com>"
start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]
...
Rebooted the machine and it works.
$ sudo service mysql status
mysql start/running, process 972
Use the chkconfig command as per the manpage http://manpages.ubuntu.com/manpages/maverick/man8/chkconfig.8.html
Another place to look for clues as to what is and isn't starting at boot time...
/etc/init.d/.depend.start (and its buddy at shutdown time, .depend.stop)
Here's a little more info http://www.pyenet.co.nz/2-202-1-customising-system-startup-and-boot-processes/
I had 2 servers - after booting, 1 would have mysql running, the other not so much.
On the box where mysql was starting at boot time:
chkconfig wasn't even installed
there were zero links from any scripts in /etc/rc?.d/* back to /etc/init.d/mysql
BUT... /etc/init.d/.depend.start contained:
TARGETS = halt apache2 umountfs umountnfs.sh sendsigs networking umountroot reboot killprocs unattended-upgrades urandom mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo postfix single grub-common ondemand rc.local
INTERACTIVE = apache2
postfix: mysql
single: killprocs dns-clean pppd-dns
grub-common: apache2 unattended-upgrades postfix mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo
ondemand: apache2 unattended-upgrades postfix mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo
rc.local: apache2 unattended-upgrades postfix mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo
When I simply copied this file over to the problem server, and rebooted, mysql was up & running.
With Debian 9, I installed MySQL today and typed "reboot" and mysqld restarted automatically. Also rebooted from my VPS dashboard, mysqld restarted automatically. In short, if you have Debian 9, there's nothing extra to do, it just works.