Use these instructions to setup Apache, PHP,Composer, And Node JS in your Ubuntu Based System.
Here I am using an Ubuntu server. I have tested this instructions in Ubuntu 20+, Linux Mint 20+, Elementary OS, and works perfectly. Basically you can use these instructions in any ubuntu based system.
To install Apache
sudo apt-get install apache2After the installation complete, go to your preferred browser, type in the address bar
http://localhostand hit enter. You should see Ubuntu's default page on your screen.
Then go back to your terminal and type
sudo apt-get install php php-curl php-xml libapache2-mod-php php-mysql php-mbstring php-fpmAfter installing these packages,type
cd var/www/htmlIt brings you to your server folder.Then type
sudo nano test.phpIt will open a terminal-based text editor, then type
<?php echo "IT WORKS" ?>and then press ctrl+s and ctrl+x. After that go to your browser again and type on addressbar.
http://localhost/test.phpIt should say "IT WORKS"
If you want to remove php completely from the system, try this one
sudo apt-get purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`And now it's time to set up the MySQL database. Go back to terminal
sudo apt-get install mysql-server mysql-clientAfter install MySQL server , I am going to set up my MySQL root password, type
sudo mysqlIf it wants a password then type your system user password.After entering into MySQL terminal, type
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';Put your password in your_password field. Then type
FLUSH PRIVILEGESAgain type and hit enter
quit;MySQL setup is done.
To, export your MySQL tables, type this command on your terminal
mysqldump -u USERNAME -p DATABASE_NAME > YOUR_FILE_NAME.sqlIf you want to export some specific tables, use this command on your terminal
mysqldump -u USERNAME -p DATABASE_NAME TABLE1 TABLE2 TABLE3 > YOUR_FILE_NAME.sqlTo, import you MySQL tables, type this command on your terminal
Note: This way is working on my end.
mysqldump -u USERNAME -p DATABASE_NAME < YOUR_FILE_NAME.sqlThis is how I make my things done on my end First log into MySQL
mysql -u root -pAfter log into MySQL, type this commands on your terminal
use DATABASE_NAME;
source YOUR_FILE_NAME.sqlNow it's time to install Node JS
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install nodejsTo check Node version
node -vTo check npm version
npm -vYarn is a Node JS package manager like NPM. To install Yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install yarnTo check Yarn version
yarn -vLike Yarn, Composer is a package manager, But it's for PHP. To setup composer in your machine
sudo apt update
sudo apt-get install php-cli php-zip unzip
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
HASH="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php -r "unlink('composer-setup.php');"It will install Composer in your system. To access it easily, run this command
sudo mv composer.phar /usr/local/bin/composerAfter that, Simply type
composerAnd hit enter. You can see its nice function list and work doc in your terminal.
- To change the PHP version, use this command
sudo update-alternatives –config phpthen choose your PHP version and enter. Then type
sudo a2enmod 'your_php_version'