-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
809 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Nick Tsai | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
*Linux Nignx MySQL PHP* | ||
======================= | ||
|
||
LNMP Environment Building | ||
|
||
INSTALLATION | ||
------------ | ||
|
||
Select your Linux distribution to download and execute the installer as below: | ||
|
||
> You can make installer executable by `$ chmod +x ./installer` then `$ ./installer`. | ||
### Ubuntu 16.04 LTS | ||
|
||
> Nginx: 1.10.3 | ||
> PHP: 7.0 | ||
> PHP: 5.6 (Optional) | ||
> MySQL: 5.7.25 (Optional) | ||
> | ||
> *PhpMyAdmin (Optional) is installed at `/var/www/html/phpmyadmin` and can be accessed via `http://yourhost/phpmyadmin`.* | ||
``` | ||
$ wget https://raw.githubusercontent.com/yidas/server-installers/master/LNMP/ubuntu16.04.sh -O installer | ||
$ bash installer | ||
``` | ||
|
||
### Ubuntu 18.04 LTS | ||
|
||
> Nginx: 1.14.0 | ||
> PHP: 7.2 | ||
> PHP: 7.3 (Optional) | ||
> PHP: 7.0 (Optional) | ||
> PHP: 5.6 (Optional) | ||
> MySQL: 5.7.25 (Optional) | ||
> | ||
> *PhpMyAdmin (Optional) is installed at `/var/www/html/phpmyadmin` and can be accessed via `http://yourhost/phpmyadmin`.* | ||
``` | ||
$ wget https://raw.githubusercontent.com/yidas/server-installers/master/LNMP/ubuntu18.04.sh -O installer | ||
$ bash installer | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Default server configuration | ||
# | ||
server { | ||
listen 80 default_server; | ||
listen [::]:80 default_server; | ||
|
||
# SSL configuration | ||
# | ||
# listen 443 ssl default_server; | ||
# listen [::]:443 ssl default_server; | ||
# | ||
# Note: You should disable gzip for SSL traffic. | ||
# See: https://bugs.debian.org/773332 | ||
# | ||
# Read up on ssl_ciphers to ensure a secure configuration. | ||
# See: https://bugs.debian.org/765782 | ||
# | ||
# Self signed certs generated by the ssl-cert package | ||
# Don't use them in a production server! | ||
# | ||
# include snippets/snakeoil.conf; | ||
|
||
root /var/www/html; | ||
|
||
# Add index.php to the list if you are using PHP | ||
index index.php index.html index.htm index.nginx-debian.html; | ||
|
||
server_name _; | ||
|
||
location / { | ||
# First attempt to serve request as file, then | ||
# as directory, then fall back to displaying a 404. | ||
try_files $uri $uri/ =404; | ||
} | ||
|
||
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | ||
# | ||
location ~ \.php$ { | ||
include snippets/fastcgi-php.conf; | ||
# fastcgi_param SCRIPT_FILENAME $request_filename; | ||
|
||
# With php-cgi alone: | ||
# fastcgi_pass 127.0.0.1:9000; | ||
|
||
# With php7.0-fpm: | ||
fastcgi_pass unix:/run/php/php7.0-fpm.sock; | ||
|
||
# With php5.6-fpm (Optional install): | ||
#fastcgi_pass unix:/run/php/php5.6-fpm.sock; | ||
} | ||
|
||
# deny access to .htaccess files, if Apache's document root | ||
# concurs with nginx's one | ||
# | ||
#location ~ /\.ht { | ||
# deny all; | ||
#} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Default server configuration | ||
# | ||
server { | ||
listen 80 default_server; | ||
listen [::]:80 default_server; | ||
|
||
# SSL configuration | ||
# | ||
# listen 443 ssl default_server; | ||
# listen [::]:443 ssl default_server; | ||
# | ||
# Note: You should disable gzip for SSL traffic. | ||
# See: https://bugs.debian.org/773332 | ||
# | ||
# Read up on ssl_ciphers to ensure a secure configuration. | ||
# See: https://bugs.debian.org/765782 | ||
# | ||
# Self signed certs generated by the ssl-cert package | ||
# Don't use them in a production server! | ||
# | ||
# include snippets/snakeoil.conf; | ||
|
||
root /var/www/html; | ||
|
||
# Add index.php to the list if you are using PHP | ||
index index.php index.html index.htm index.nginx-debian.html; | ||
|
||
server_name _; | ||
|
||
location / { | ||
# First attempt to serve request as file, then | ||
# as directory, then fall back to displaying a 404. | ||
try_files $uri $uri/ =404; | ||
} | ||
|
||
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | ||
# | ||
location ~ \.php$ { | ||
include snippets/fastcgi-php.conf; | ||
# fastcgi_param SCRIPT_FILENAME $request_filename; | ||
|
||
# With php-cgi alone: | ||
# fastcgi_pass 127.0.0.1:9000; | ||
|
||
# With php7.2-fpm: | ||
fastcgi_pass unix:/run/php/php7.2-fpm.sock; | ||
|
||
# With php7.3-fpm (Optional install): | ||
#fastcgi_pass unix:/run/php/php7.3-fpm.sock; | ||
|
||
# With php7.0-fpm (Optional install): | ||
#fastcgi_pass unix:/run/php/php7.0-fpm.sock; | ||
|
||
# With php5.6-fpm (Optional install): | ||
#fastcgi_pass unix:/run/php/php5.6-fpm.sock; | ||
} | ||
|
||
# deny access to .htaccess files, if Apache's document root | ||
# concurs with nginx's one | ||
# | ||
#location ~ /\.ht { | ||
# deny all; | ||
#} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
#!/bin/bash | ||
|
||
# LNMP Installer for Ubuntu 16.04 TLS | ||
# | ||
# @author Nick Tsai <[email protected]> | ||
# @version 1.0.0 | ||
# @link https://github.com/yidas/server-installers | ||
|
||
# Access Configuration | ||
sshPasswodAuthOn=false | ||
echo "SSH Login: Do you want turn on SSH PasswordAuthentication? [Y/n, empty as No]:" | ||
read sshPasswodAuthOn | ||
case $yn in | ||
[Yy]* ) sshPasswodAuthOn=true;; | ||
* ) | ||
esac | ||
|
||
echo "Sudoer User: Type the sudoer user name if you want to create, empty to skip, followed by [ENTER]:" | ||
read sudoerUsername | ||
|
||
sudoerPassword='' | ||
if [ $sudoerUsername ]; then | ||
echo "Sudoer User: Type the password for sudoer user \`{$sudoerUsername}\` if you want to create, or empty, followed by [ENTER]:" | ||
read sudoerPassword | ||
fi | ||
|
||
# PHP | ||
usePhp5=false; | ||
# PHP default | ||
echo "PHP: Do you want to additionally install PHP 5.6? [Y/n, empty as No]" | ||
read yn | ||
case $yn in | ||
[Yy]* ) usePhp5=true;; | ||
* ) | ||
esac | ||
# PHP force asking | ||
#while true; do | ||
# echo "PHP: Default version is PHP 7, install old version PHP 5.6? [Y/n]" | ||
# read yn | ||
# case $yn in | ||
# [Yy]* ) usePhp5=true; break;; | ||
# [Nn]* ) break;; | ||
# * ) echo "Please answer yes or no.";; | ||
# esac | ||
#done | ||
|
||
# MySQL question | ||
echo "MySQL: Do you want to install MySQL? [Y/n, empty as Yes]" | ||
read yn | ||
case $yn in | ||
[Nn]* ) installMySQL=false;; | ||
* ) | ||
installMySQL=true | ||
|
||
echo "MySQL: Type the password for MySQL root, default is \`password\` followed by [ENTER]:" | ||
read mysqlRootPassword | ||
if [ ! $mysqlRootPassword ]; then | ||
mysqlRootPassword='password' | ||
fi | ||
;; | ||
esac | ||
|
||
# PHPMyAdmin question | ||
echo "PHPMyAdmin: Do you want to install PHPMyAdmin? [Y/n, empty as Yes]" | ||
read yn | ||
case $yn in | ||
[Nn]* ) installPhpMyAdmin=false;; | ||
* ) installPhpMyAdmin=true;; | ||
esac | ||
# PHPMyAdmin with Metro theme | ||
if [ $installPhpMyAdmin = true ]; then | ||
echo "PHPMyAdmin: Do you want to install Metro theme? [Y/n, empty as Yes]" | ||
read yn | ||
case $yn in | ||
[Nn]* ) installPhpMyAdminTheme=false;; | ||
* ) installPhpMyAdminTheme=true;; | ||
esac | ||
fi | ||
|
||
# Access | ||
if [ $sshPasswodAuthOn ]; then | ||
# Root Login Disabled | ||
sudo sed -i 's/PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config | ||
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config | ||
sudo service ssh reload | ||
fi | ||
|
||
# Sudoer | ||
if [ $sudoerUsername ]; then | ||
sudo adduser ${sudoerUsername} --gecos "" --disabled-password | ||
echo "${sudoerUsername}:${sudoerPassword}" | sudo chpasswd | ||
sudo usermod -a -G sudo ${sudoerUsername} | ||
else | ||
echo "Skip creating user" | ||
fi | ||
|
||
# IPv6 Disabled | ||
if ! grep -q "net.ipv6.conf.all.disable_ipv6 = 1" /etc/sysctl.conf; then | ||
sudo printf "net.ipv6.conf.all.disable_ipv6 = 1\nnet.ipv6.conf.default.disable_ipv6 = 1\nnet.ipv6.conf.lo.disable_ipv6 = 1" >> /etc/sysctl.conf | ||
sysctl -p | ||
echo "IPv6 Disabled" | ||
fi | ||
|
||
# APT Source using IPv4 | ||
sudo apt-get update | ||
|
||
# Timezone | ||
sudo timedatectl set-timezone Asia/Taipei | ||
sudo apt-get install ntpdate -y | ||
sudo ntpdate time.stdtime.gov.tw | ||
|
||
# Nginx | ||
sudo apt-get install nginx -y | ||
|
||
|
||
# PHP | ||
sudo apt-get install php-fpm php-mysql php-cli php-mcrypt php-curl php-mbstring php-imagick php-gd php-xml php-zip -y | ||
sudo apt-get install php-memcached memcached -y | ||
sudo phpenmod mcrypt | ||
|
||
if [ $usePhp5 = true ]; then | ||
# PHP 5.6 | ||
sudo apt-get install software-properties-common -y | ||
sudo apt-get install python-software-properties -y | ||
sudo add-apt-repository ppa:ondrej/php -y | ||
sudo apt-get update | ||
sudo apt-get install php5.6-fpm php5.6-mysql php5.6-cli php5.6-mcrypt php5.6-curl php5.6-mbstring php5.6-imagick php5.6-gd php5.6-xml php5.6-zip -y | ||
fi | ||
|
||
# MySQL | ||
if [ $installMySQL = true ]; then | ||
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password ${mysqlRootPassword}" | ||
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password ${mysqlRootPassword}" | ||
sudo apt-get install mysql-server -y | ||
fi | ||
|
||
# PHPMyAdmin | ||
if [ $installPhpMyAdmin = true ]; then | ||
# Configuration | ||
version="4.8.2" | ||
webPath="/var/www/html/" | ||
#filename="phpMyAdmin-${version}-english" | ||
filename="phpMyAdmin-${version}-all-languages" | ||
fileUrl="https://files.phpmyadmin.net/phpMyAdmin/${version}/${filename}.tar.gz" | ||
# Commands | ||
sudo wget "${fileUrl}" | ||
sudo tar -zxvf "${filename}.tar.gz" -C "${webPath}" | ||
sudo rm -f "${filename}.tar.gz" | ||
sudo mv "${webPath}${filename}" "${webPath}phpmyadmin" | ||
# Nginx Default Site | ||
configUrl='https://raw.githubusercontent.com/yidas/server-installers/master/LNMP/nginx-sites/default-php7.0-all' | ||
|
||
sudo wget "${configUrl}" -O /etc/nginx/sites-available/default | ||
|
||
# PHPMyAdmin theme | ||
if [ $installPhpMyAdminTheme = true ]; then | ||
# Configuration | ||
file="metro-2.8.zip" | ||
fileUrl="https://files.phpmyadmin.net/themes/metro/2.8/${file}" | ||
# Commnads | ||
pathTheme="${webPath}phpmyadmin/themes" | ||
sudo wget "${fileUrl}" -P "${pathTheme}" | ||
sudo apt install unzip -y | ||
sudo unzip "${pathTheme}/${file}" -d "${pathTheme}/" | ||
sudo rm "${pathTheme}/${file}" | ||
fi | ||
fi | ||
|
||
sudo service nginx reload |
Oops, something went wrong.