Skip to content

Use these instructions to setup Apache, PHP,Composer, And Node JS in your Ubuntu System

Notifications You must be signed in to change notification settings

hrrarya/server-setup-instructions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

Server Setup Instructions

Use these instructions to setup Apache, PHP,Composer, And Node JS in your Ubuntu Based System.

Requirments

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.

Installation

To install Apache

sudo apt-get install apache2

After the installation complete, go to your preferred browser, type in the address bar

http://localhost

and 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-fpm

After installing these packages,type

cd var/www/html

It brings you to your server folder.Then type

sudo nano test.php

It 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.php

It 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-client

After install MySQL server , I am going to set up my MySQL root password, type

sudo mysql

If 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 PRIVILEGES

Again type and hit enter

quit;

MySQL setup is done.

Import & Export MySQL Database using Terminal

To, export your MySQL tables, type this command on your terminal

mysqldump -u USERNAME -p DATABASE_NAME > YOUR_FILE_NAME.sql

If 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.sql

To, 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.sql

This is how I make my things done on my end First log into MySQL

mysql -u root -p

After log into MySQL, type this commands on your terminal

use DATABASE_NAME;
source YOUR_FILE_NAME.sql

Now 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 nodejs

To check Node version

node -v

To check npm version

npm -v

Yarn

Yarn 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 yarn

To check Yarn version

yarn -v

Composer

Like 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/composer

After that, Simply type

composer

And hit enter. You can see its nice function list and work doc in your terminal.

Special Commands

  1. To change the PHP version, use this command
sudo update-alternatives –config php

then choose your PHP version and enter. Then type

sudo a2enmod 'your_php_version'

About

Use these instructions to setup Apache, PHP,Composer, And Node JS in your Ubuntu System

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published