一键安装脚本
https://oneinstack.com/
https://lnmp.org/
ssh
apt-get install sshpass
sshpass -p 'password' ssh -i '.pem' username@ip
Get Ready
useradd www
usermod -L www
apt-get update
apt-get upgrade
apt-get purge apache nginx mysql
apt-get install g++ make libpcre3 perl psmisc curl wget
mkdir -p /vhost/tmp/
mkdir -p /vhost/phpx/
mkdir -p /vhost/down
cd /vhost/down
nginx
install
curl -O http://zlib.net/zlib-1.2.11.tar.gz
curl -O https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz
curl -O https://www.openssl.org/source/openssl-1.1.0g.tar.gz
curl -O http://nginx.org/download/nginx-1.14.0.tar.gz
tar -zxf zlib-1.2.11.tar.gz
tar -zxf pcre-8.41.tar.gz
tar -zxf openssl-1.1.0g.tar.gz
tar -zxf nginx-1.14.0.tar.gz
cd nginx-1.14.0
./configure --prefix=/vhost/nginx --with-pcre=/vhost/down/pcre-8.41 --with-zlib=/vhost/down/zlib-1.2.11 --with-openssl=/vhost/down/openssl-1.1.0g --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module
make&&make install
rm -rf /usr/local/bin/nginx
ln -s /vhost/nginx/sbin/nginx /usr/local/bin/
php7.2
freetype
wget https://sourceforge.net/projects/freetype/files/freetype2/2.9/freetype-2.9.tar.gz/download -O freetype-2.9.tar.gz
tar zxf freetype-2.9.tar.gz
cd freetype-2.9
./configure --prefix=/usr/local/freetype2
make&&make install
install
apt-get install libxml2 libxml2-dev libcurl4-openssl-dev pkg-config libssl-dev libjpeg-dev libfreetype6-dev libmcrypt-dev libxslt1-dev libicu-dev
curl -O http://php.net/distributions/php-7.2.8.tar.xz
xz -dk php-7.2.8.tar.xz
tar xf php-7.2.8.tar
cd php-7.2.8
./configure --prefix=/vhost/phpx/php7.2.8 --with-config-file-path=/vhost/phpx/php7.2.8/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype2 --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --enable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --enable-ftp --with-gd --with-openssl --with-mhash --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-fileinfo --enable-opcache --enable-exif
make&&make install
rm /usr/local/bin/php
ln -s /vhost/phpx/php7.2.8/bin/php /usr/local/bin/
mkdir -p /vhost/phpx/opcachecache /vhost/phpx/session /vhost/phpx/uploadtmp
chmod 777 -R /vhost/phpx/opcachecache /vhost/phpx/session /vhost/phpx/uploadtmp
etc
php.ini
sed -i "s#^post_max_size = 8M#post_max_size = 128M#" php.ini-production
sed -i "s#^upload_max_filesize = 2M#upload_max_filesize = 128M#" php.ini-production
echo '
session.save_path = '/vhost/phpx/session'
opcache.file_cache = '/vhost/phpx/opcachecache'
upload_tmp_dir = '/vhost/phpx/uploadtmp'
' >> php.ini-production
cp php.ini-production /vhost/phpx/php7.2.8/etc/php.ini
php-fpm.conf
vi /vhost/phpx/php7.2.8/etc/php-fpm.conf
[www]
user = www
group = www
listen = /dev/shm/php72.sock
pm = dynamic
pm.max_children = 5
pm.start_servers = 3
pm.min_spare_servers = 3
pm.max_spare_servers = 5
plug
mongodb
apt-get install autoconf m4 automake libtool
curl -O https://pecl.php.net/get/mongodb-1.5.2.tgz
tar zxf mongodb-1.5.2.tgz
cd mongodb-1.5.2
/vhost/phpx/php7.2.8/bin/phpize
./configure --with-php-config=/vhost/phpx/php7.2.8/bin/php-config
make&&make install
sed -i 'extension=mongodb.so' /vhost/phpx/php7.2.8/etc/php.ini
composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
chmod 777 /usr/local/bin/composer
/etc/profile
vi /etc/profile
#composer
export PATH="$PATH:{user root}/.config/composer/vendor/bin/"
or
echo '
#composer
export PATH="$PATH:{user root}/.config/composer/vendor/bin/"
' >> /etc/profile
mariadb
install
mkdir /vhost/mysqlData
rm -rf /usr/local/mysql /etc/my.cnf /etc/init.d/mysql
apt-get install libaio-dev
wget http://ftp.cc.uoc.gr/mirrors/mariadb//mariadb-10.3.8/bintar-linux-x86_64/mariadb-10.3.8-linux-x86_64.tar.gz
tar -zxf mariadb-10.3.8-linux-x86_64.tar.gz
mv mariadb-10.2.13-linux-x86_64 /usr/local/mysql
my.cnf
memTotal=`free -m | grep Mem | awk '{print $2}'`
# 选取合适的配置文件
if [[ ${memTotal} -lt 64 ]]; then
# 小于64m
mysqlCnf='my-small'
elif [[ ${memTotal} -ge 64 && ${memTotal} -lt 128 ]]; then
# 64m 到 128m
mysqlCnf='my-medium'
elif [[ ${memTotal} -ge 128 && ${memTotal} -lt 512 ]]; then
# 128m 到 512m
mysqlCnf='my-large'
elif [[ ${memTotal} -ge 512 && ${memTotal} -lt 4096 ]]; then
# 512m 到 4096m
mysqlCnf='my-huge'
elif [[ ${memTotal} -ge 4096 ]]; then
# 大于 4096m
mysqlCnf='my-innodb-heavy-4G'
fi
cp /usr/local/mysql/support-files/${mysqlCnf}.cnf /etc/my.cnf
add user
groupadd mysql
useradd -g mysql mysql
chown root:mysql -Rf /usr/local/mysql
chmod +x -Rf /usr/local/mysql
chown mysql:mysql /etc/my.cnf
install data
/usr/local/mysql/scripts/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/vhost/mysqlData --force
chgrp -R mysql /vhost/mysqlData
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
sed -i "s#^datadir=.*#datadir='/vhost/mysqlData'#" /etc/init.d/mysql
chmod 777 /etc/init.d/mysql
up user
systemctl enable mysql.service
systemctl start mysql.service
/usr/local/mysql/bin/mysqladmin -u root password 'root'
/usr/local/mysql/bin/mysql -uroot -proot -e "drop database test;use mysql;delete from db;delete from user where user = '';delete from user where password = '';flush privileges;";
systemctl stop mysql.service
del more
mkdir /usr/local/mysqlSmail
mv /usr/local/mysql/bin /usr/local/mysqlSmail
mv /usr/local/mysql/share /usr/local/mysqlSmail
rm -rf /usr/local/mysql/
mv /usr/local/mysqlSmail /usr/local/mysql/
ln -s
rm -f /usr/bin/mysql /usr/bin/mysqldump
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
mongodb
install
rm -rf /usr/local/mongodb
mkdir -p /vhost/mongodb/data
chmod 777 /vhost/mongodb/data
#curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian92-4.0.0.tgz
curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.0.tgz
tar -zxf mongodb-linux-x86_64-4.0.0.tgz -C /usr/local/
mv /usr/local/mongodb-linux-x86_64-4.0.0 /usr/local/mongodb
rm -f /usr/local/bin/mongo /usr/local/bin/mongod
ln -s /usr/local/mongodb/bin/mongo /usr/local/bin/mongo
ln -s /usr/local/mongodb/bin/mongod /usr/local/bin/mongod
conf
vi /usr/local/mongodb/mongodb.conf
dbpath=/vhost/mongodb/data
logpath=/vhost/mongodb/mongodb.log
fork=true
logappend=true
auth=true
port=27017
node
install
rm -rf /usr/local/node
curl -O https://nodejs.org/dist/v8.11.3/node-v8.11.3-linux-x64.tar.xz
xz -dk node-v8.11.3-linux-x64.tar.xz
tar xf node-v8.11.3-linux-x64.tar
mv node-v8.11.3-linux-x64 /usr/local/node
chmod 777 -R /usr/local/node
/etc/profile
vi /etc/profile
#node
export PATH="$PATH:/usr/local/node/bin/"
or
echo '
#node
export PATH="$PATH:/usr/local/node/bin/"
' >> /etc/profile
python3
install
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
xz -dk Python-3.7.0.tar.xz
tar xf Python-3.7.0.tar.xz
cd Python-3.7.0
mkdir -p /usr/local/py3
./configure --prefix=/usr/local/py3
make&&make install
rm -rf /usr/bin/py3*
ln -s /usr/local/py3/bin/python3 /usr/bin/py3
ln -s /usr/local/py3/bin/pip3 /usr/bin/pip3
reids
install
rm -rf /usr/local/redis
wget http://download.redis.io/releases/redis-4.0.11.tar.gz
tar xzf redis-4.0.11.tar.gz
mv redis-4.0.11 redis
cd redis
make
rm -f /usr/local/bin/redis*
mkdir -p /usr/local/redis/bin/
mv src/redis-server /usr/local/redis/bin/
mv src/redis-cli /usr/local/redis/bin/
ln -s /usr/local/redis/bin/redis-server /usr/local/bin/
ln -s /usr/local/redis/bin/redis-cli /usr/local/bin/
conf
mkdir /vhost/redis
sed -i "s#^dir ./#dir /vhost/redis/#" /vhost/down/redis/redis.conf
sed -i "s#^daemonize no/#daemonize yes#" /vhost/down/redis/redis.conf
sed -i 'requirepass root' /vhost/down/redis/redis.conf
rm -rf /usr/local/redis/redis.conf
cp /vhost/down/redis/redis.conf /usr/local/redis/redis.conf
question
2018年08月06日12:21:07
echo ‘net.core.somaxconn = 511’ > /etc/sysctl.confecho ‘vm.overcommit_memory = 1’ > /etc/sysctl.conf
echo 'net.core.somaxconn = 511' >> /etc/sysctl.conf
echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
echo '
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
' >> /etc/rc.local
sysctl -p
git
install
apt-get install libpcre3 libpcre3-dev tk perl cpio gettext
curl -O https://www.kernel.org/pub/software/scm/git/git-2.18.0.tar.xz
xz -dk git-2.18.0.tar.xz
tar xf git-2.18.0.tar
cd git-2.18.0
./configure --prefix=/usr/local/git-2.18.0
make&&make install
rm /usr/local/bin/git
ln -s /usr/local/git-2.18.0/bin/git /usr/local/bin
end
vhost
vi /vhost/vhost.sh
1 | !/bin/bash |
chmod 777 /vhost/vhost.sh
ln -s /vhost/vhost.sh /usr/local/bin/vhost