I want to deploy my PHP website in Ubuntu Virtual Machine in Azure. I am downloading the website zip file from Azure blob storage and copying it to /var/www/html/ using below command.
wget tar -xzvf Online_Shopping.tar.gz sudo mkdir /var/www/html/Online_Shopping sudo cp -r ~/Online_Shopping/* /var/www/html/Online_Shopping Now I have to add "AddType application/x-httpd-php .html" line at the end of sudo nano /etc/apache2/apache2.conf file automatic through command line. I am putting all the command in one script file and that script file is used to deploy my website automatically. I have written the below script file for my website deployment.
#!/bin/bash apt-get -y update # set up a silent install of MySQL dbpass=$1 export DEBIAN_FRONTEND=noninteractive echo mysql-server-5.6 mysql-server/root_password password $dbpass | debconf-set-selections echo mysql-server-5.6 mysql-server/root_password_again password $dbpass | debconf-set-selections # install the LAMP stack apt-get -y install apache2 mysql-server php5 php5-mysql wget tar -xzvf Online_Shopping.tar.gz sudo mkdir /var/www/html/Online_Shopping sudo cp -r ~/Online_Shopping/* /var/www/html/Online_Shopping sudo nano /etc/apache2/apache2.conf ****AddType application/x-httpd-php .html*** sudo /etc/init.d/apache2 restart Please help me, how I will add the line in an automated process.
51 Answer
as i see from this script your passing the password with the script like if the script is script.sh your running the script as
sudo -i ./script.sh yourmysqlpassword #assuming the script is in current directory i edited it to your needs just appending the line will do the job
#!/bin/bash apt-get -y update # set up a silent install of MySQL dbpass=$1 export DEBIAN_FRONTEND=noninteractive echo mysql-server-5.6 mysql-server/root_password password $dbpass | debconf-set-selections echo mysql-server-5.6 mysql-server/root_password_again password $dbpass | debconf-set-selections # install the LAMP stack apt-get -y install apache2 mysql-server php5 php5-mysql wget tar -xzvf Online_Shopping.tar.gz sudo mkdir /var/www/html/Online_Shopping sudo cp -r ~/Online_Shopping/* /var/www/html/Online_Shopping sudo nano /etc/apache2/apache2.conf ###AddType application/x-httpd-php .html### echo "AddType application/x-httpd-php.html" >> /etc/apache2/apache2.conf sudo /etc/init.d/apache2 restart run the script as root so echo doesn't complain
4