Server setup , Install libraries, Install Nginx or Apache, Setup cronjob
Install libraries:
sudo apt-get install pdftk
sudo apt-get install libreoffice
sudo apt install imagemagick
sudo apt install openjdk-9-jre
sudo apt install libreoffice --no-install-recommends
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt updatex
sudo apt install php php-cli php-fpm php-json php-pdo php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath
sudo apt install php7.4
sudo apt-get install php7.4-fpm php7.4-cli php7.4-mysql php7.4-gd
sudo apt install php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip php7.4-intl -y
Connect Mysql:
mysql -uroot -h 11.111.11.111 –p
->password
->use db_name; (xyz)
->show warnings;
Cronjob Setup:
#to check the cronlist
crontab -l
#to add/update/delete the cronjob
crontab -e
#Format of the cronjobs
* * * * * cd /var/www/user && php artisan schedule:run >> /dev/null 2>&1
35 2 * * 1 /bin/systemctl reload nginx
15 6 * * 5 /usr/local/bin/php /home/user/artisan update-users
1 10 * * 5 /usr/local/bin/php /home/user/artisan update-users --user=2
#to set the time properly please check with below site
Update the document root from public_html to public:
Sudo nano /var/cpanel/userdata/username/xyz.com
Change documentroot: public_html => public
Change scriptalias: public_html => public
And restart Apache: /scripts/rebuildhttpdconf; service httpd restart
Installing and configure Nginx:
Step 1: Install
sudo apt update
sudo apt install nginx
Step 2 – Adjusting the Firewall
sudo ufw app list
Available applications:
Nginx Full
Nginx HTTP
Nginx HTTPS
OpenSSH
sudo ufw allow 'Nginx HTTP'
sudo ufw status
Step 3 – Checking your Web Server
systemctl status nginx
Step 4 – Managing the Nginx Process
sudo systemctl stop nginx
sudo systemctl start nginx
sudo systemctl restart nginx
sudo systemctl reload nginx
sudo systemctl disable nginx
sudo systemctl enable nginx
sudo nano /etc/nginx/sites-available/example.com
server {
listen 80;
listen [::]:80;
root /var/www/example.com/html;
index index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ =404;
}
}
sudo nginx -t -c /etc/nginx/nginx.conf
sudo systemctl restart nginx
Installing and configure Apache:
Step 1 — Install
sudo apt update
sudo apt install apache2
Step 2 — Adjusting the Firewall
sudo ufw app list
Output
Available applications:
Apache
Apache Full
Apache Secure
OpenSSH
sudo ufw allow 'Apache'
sudo ufw status
Step 3 — Checking your Web Server
sudo systemctl status apache2
Step 4 — Setting Up Virtual Hosts (Recommended)
sudo mkdir /var/www/your_domain
sudo chown -R $USER:$USER /var/www/your_domain
sudo nano /etc/apache2/sites-available/your_domain.conf
ServerAdmin webmaster@localhost
ServerName your_domain
ServerAlias your_domain
DocumentRoot /var/www/your_domain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
sudo a2ensite your_domain.conf (file will create in "/etc/apache2/sites-enabled/your_domain.conf" which effects the domain)
sudo a2dissite 000-default.conf
sudo apache2ctl configtest (sudo apachectl configtest)
sudo systemctl restart apache2
sample of 000-default.conf_______
<VirtualHost *:80>
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot "/var/www/steps/public"
<Directory "/var/www/steps/public">
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>