sh Ubuntu 16.04的跛行堆栈(PHP7,Nginx,MySql,MongoDB,PhpMyAdmin,Git,Node.js,Bower,Gulp,Docker,Composer(带资产插

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Ubuntu 16.04的跛行堆栈(PHP7,Nginx,MySql,MongoDB,PhpMyAdmin,Git,Node.js,Bower,Gulp,Docker,Composer(带资产插相关的知识,希望对你有一定的参考价值。

#!/bin/bash

echo "Please, enter your username, it will be added to 'sudo' and 'docker' groups during the process."
read USERNAME

if [ -z "$USERNAME" ] ; then
	echo "Exiting... Done."
	exit
else
	echo "Adding user to 'sudo' group..."
	sudo usermod -aG sudo $USERNAME
	
	echo "Adding needed repos"
	sudo add-apt-repository ppa:ondrej/php

	echo "Initializing script..."
	sudo apt-get update
	sudo apt-get -y upgrade

	echo "Installing Nginx..."
	sudo apt-get install -y nginx

	echo "Adding rule to 'ufw' firewall"
	sudo ufw allow 'Nginx HTTP'

	echo "Installing MySQL..."
	sudo apt-get install -y mysql-server
	# sudo mysql_secure_installation

	echo "Installing PHP 7 and its components: [cli,common,fpm,curl,gd, intl,zip,xsl,mbstring,mysql]..."
	
	sudo apt-get install -y php7.0-cli
	sudo apt-get install -y php7.0-common
	sudo apt-get install -y php7.0
	sudo apt-get install -y php7.0-fpm
	sudo apt-get install -y php7.0-curl
	sudo apt-get install -y php7.0-gd
	sudo apt-get install -y php7.0-intl
	sudo apt-get install -y php7.0-zip
	sudo apt-get install -y php7.0-xsl
	sudo apt-get install -y php7.0-mbstring
	sudo apt-get install -y php7.0-mysql
	# required by phpmyadmin
	sudo apt-get install -y php-gettext
	# required for installing xdebug
	sudo apt-get install -y php7.0-dev

	# PhpMyAdmin
	echo "Installing PhpMyAdmin..."
	sudo apt-get install phpmyadmin
	mkdir -p /var/www/localhost
	sudo ln -s /usr/share/phpmyadmin/ /var/www/localhost/pma

	echo "Configuring PHP..."
	sudo sed -i s/\;cgi\.fix_pathinfo\s*\=\s*1/cgi.fix_pathinfo\=0/ /etc/php/7.0/fpm/php.ini

	# Composer
	echo "Installing Composer..."
	curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

	echo "Installing Composer Asset plugin..."
	sudo composer global require "fxp/composer-asset-plugin:~1.1"

	echo "Installing Dnsmasq..."
	sudo apt-get install dnsmasq
	echo "Pointing all *.dev domains to 127.0.0.1"
	echo "address=/.dev/127.0.0.1" >> /etc/dnsmasq.conf
	sudo /etc/init.d/dnsmasq restart

	echo "Restarting PHP, Nginx and MySQL services..."
	sudo /etc/init.d/php7.0-fpm restart
	sudo /etc/init.d/nginx restart
	sudo /etc/init.d/mysql restart
	
	echo "Installing MongoDB..."
	sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
	sudo echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
	sudo apt-get update
	sudo apt-get install -y --allow-unauthenticated mongodb-org
	sudo echo '[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target' > /etc/systemd/system/mongodb.service
	sudo systemctl start mongodb
	sudo systemctl status mongodb
	sudo systemctl enable mongodb

	echo "Installing GIT..."
	sudo apt-get install -y git

	echo "Installing Node.js"
	sudo apt-get install -y nodejs
	sudo ln -s /usr/bin/nodejs /usr/bin/node
	sudo apt-get install -y build-essential
	sudo apt-get install -y npm
	sudo ln -s /usr/bin/nodejs /usr/bin/node

	echo "Installing Bower..."
	sudo npm install -g bower

	echo "Installing Gulp..."
	sudo npm install -g gulp

	echo "Installing Grunt..."	
	sudo npm install -g grunt-cli

	echo "Installing DOCKER..."
	sudo apt-get update
	sudo apt-get install -y apt-transport-https ca-certificates
	sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
	sudo echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" >> /etc/apt/sources.list.d/docker.list
	sudo apt-get update
	sudo apt-get purge -y lxc-docker
	sudo apt-cache policy docker-engine
	sudo apt-get update
	sudo apt-get install -y linux-image-extra-$(uname -r)
	sudo apt-get install -y docker-engine

	echo "Adding user to 'docker' group..."
	sudo usermod -aG docker $USERNAME

	echo "Starting docker service..."
	sudo /etc/init.d/docker start

	echo "Testing docker..."
	sudo docker run hello-world

	echo "Removing unneeded dependencies"
	sudo apt-get autoremove
fi

以上是关于sh Ubuntu 16.04的跛行堆栈(PHP7,Nginx,MySql,MongoDB,PhpMyAdmin,Git,Node.js,Bower,Gulp,Docker,Composer(带资产插的主要内容,如果未能解决你的问题,请参考以下文章

sh 安装php7.1 ubuntu 16.04 EC2

sh 安装php7.1 ubuntu 16.04 EC2

sh 在Ubuntu 16.04上安装PHP7.2 NGINX和PHP7.2-FPM

sh 在Ubuntu 16.04上安装PHP7.2 NGINX和PHP7.2-FPM

sh 在Ubuntu 16.04上安装PHP7.2 NGINX和PHP7.2-FPM

sh Ubuntu Xenial 16.04的多个版本的php从php7下降到php5.6