Centos7一键安装lnmp脚本
mkdir /root/software
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-boost-5.7.18.tar.gz
wget https://sourceforge.net/projects/pcre/files/pcre/8.40/pcre-8.40.tar.gz
wget wget http://nginx.org/download/nginx-1.12.0.tar.gz wget http://hk1.php.net/distributions/php-7.1.4.tar.gz
#!/bin/sh
# This script used by one click install lnmp
# write by 2018/03/14
mkdir /root/software
cd /root/software/
ll
systemctl stop firewalld.service
systemctl disable firewalld.service
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0
######start install nginx######
echo '######start install nginx######'
useradd www -s /sbin/nologin
yum -y install pcre pcre-devel zlib zlib-devel gcc-c++ gcc openssl*
tar zxvf nginx-1.12.0.tar.gz
cd nginx-1.12.0/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre
make && make install
sleep 2
ln -s /usr/local/nginx/sbin/nginx /sbin/nginx
if [ ! -f //usr/lib/systemd/system/nginx.service ];then
cat >> /usr/lib/systemd/system/nginx.service << EOF
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=//usr/sbin/nginx -s reload
ExecStop=/usr/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
else
continue
fi
systemctl daemon-reload
systemctl start nginx
systemctl enable nginx
systemctl status nginx
sleep 2
echo '######nginx is install completed done.######'
###### start install mysql ######
cd /root/software/
yum -y install ncurses ncurses-devel bison cmake gcc gcc-c++
groupadd mysql
useradd -s /sbin/nologin -g mysql mysql -M
id mysql
chown -R mysql.mysql /usr/local/mysql
tar zxvf mysql-boost-5.7.18.tar.gz
cd mysql-5.7.18/
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DSYSCONFDIR=/usr/local/mysql/etc -DSYSTEMD_PID_DIR=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DWITH_BOOST=boost -DWITH_SYSTEMD=1
sleep 1
make && make install
sleep 2
chown -R mysql.mysql /usr/local/mysql/
cd /usr/local/mysql/
echo '######create my.cnf######'
if [ ! -f my.cnf ];then
cat >> my.cnf << EOF
[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysql]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
default-character-set=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
EOF
else
continue
fi
chown mysql.mysql my.cnf
echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
echo 'export PATH' >> /etc/profile
source /etc/profile
bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
cp usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
systemctl daemon-reload
systemctl start mysqld
systemctl enable mysqld
ps -ef|grep mysql
systemctl status mysqld
echo '######mysql is install completed done.######'
###### start install php ######
cd /root/software
tar zxvf php-7.1.4.tar.gz
cd php-7.1.4/
./configure --help
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel curl curl-devel openssl openssl-devel
./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mysqli --with-zlib --with-curl --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-openssl --enable-mbstring --enable-xml --enable-session --enable-ftp --enable-pdo -enable-tokenizer --enable-zip
sleep 1
make && make install
sleep 2
cp php.ini-development /usr/local/php/lib/php.ini
grep mysqli.default_socket /usr/local/php/lib/php.ini
sed -i 's#mysqli.default_socket =#mysqli.default_socket = /usr/local/mysql/mysql.sock#' /usr/local/php/lib/php.ini
grep mysqli.default_socket /usr/local/php/lib/php.ini
grep date.timezone /usr/local/php/lib/php.ini
sed -i 's#;date.timezone =#date.timezone = Asia/Shanghai#' /usr/local/php/lib/php.ini
grep date.timezone /usr/local/php/lib/php.ini
/usr/local/php/bin/php -v
/usr/local/php/bin/php -m
cp /usr/local/php/etc/php-fpm.conf.default
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
grep -E 'user =|group =' /usr/local/php/etc/php-fpm.d/www.conf
sed -i 's#user = nginx#user = www#' /usr/local/php/etc/php-fpm.d/www.conf
sed -i 's#group = nginx#group = www#' /usr/local/php/etc/php-fpm.d/www.conf
grep -E 'user =|group =' /usr/local/php/etc/php-fpm.d/www.conf
cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/
grep -E 'PIDFile|ExecStart' /usr/lib/systemd/system/php-fpm.service
systemctl daemon-reload
systemctl enable php-fpm
systemctl start php-fpm
systemctl status php-fpm
echo '######php is install completed done.######'
####### create test.com file used by test lnmp config is correct or incorrect ######
mkdir -p /var/www/html
chown -R www.www /var/www
if [ ! -f /var/www/html/test.php ];then
cat >> /var/www/html/test.php << EOF
<?php
echo "this a php test!"
?>
<?php
phpinfo()?>;
EOF
cd /usr/local/nginx/conf
sed -i '$i\include /usr/local/nginx/conf/conf.d/*;' nginx.conf
mkdir conf.d
cd conf.d/
echo '######create test.com.conf site file######'
cat >> test.com.conf <<EOF
server {
listen 81;
server_name localhost;
root /var/www/html;
location / {
index index.php index.html index.htm;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param PHP_VALUE open_basedir=\$document_root:/tmp/:/proc/;
include fastcgi_params;
}
}
EOF
else
continue
fi
systemctl reload nginx
systemctl reload php-fpm
sleep 2
echo '######LNMP is install completed done.######'
echo '######please Open the similar "localhost:81/test.php" to Visit the test.######'
Centos7一键安装lnmp脚本的更多相关文章
- 一键安装lnmp脚本
前段时间一直在找一个快速部署lnmp环境的方法,也没找着,就自己写了一个,结合网上的大神们的.我的方法是脚本结合源码包,很多依赖裤都是yum安装的,这都在脚本里面,需要的源码包我都下载好了,打包成压缩 ...
- 一键安装LNMP(适合centos7)
1.准备工作,下载源码包 wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar ...
- Shell脚本一键安装LNMP环境
https://sourceforge.net/projects/opensourcefile/files/ Nginx是一款高性能的HTTP和反向代理服务器.Nginx在反向代理,Rewrite规则 ...
- linux一键安装vncserver脚本
title: linux一键安装vncserver脚本 date: 2016-04-11 14:32:04 tags: --- linux多数情况下是作为服务器使用的,管理员一般也喜欢使用命令行来管理 ...
- Centos6.5中 一键安装LNMP 安装Yii2.0 手工配置
1.一键安装LNMP cd /usr wget -c http://soft.vpser.net/lnmp/lnmp1.2-full.tar.gz tar zxf lnmp1.-full.tar.gz ...
- Rehat一键安装mysql脚本和备份数据库脚本
Rehat一键安装mysql脚本 ##说明:适用,Rehat 5 6 7 1.运行状态,运行成功输出mysql临时密码 2.代码如下 #!/bin/bash #获取系统信息 sudo cat /etc ...
- (转)CentOS一键安装Nginx脚本
原文:https://www.xiaoz.me/archives/10301 https://blog.slogra.com/post-676.html-----centos7一键安装nginx脚本
- centos7 yum 安装lnmp
centos7 yum 安装lnmp 安装7.2把7.1改成7.2就行 使用第三方扩展epel源安装php7.2 #移除旧版php [root@web02 ~]# yum remove php-m ...
- Linux一键安装LNMP环境
Linux一键安装LNMP环境 官方地址:https://lnmp.org/. 参考安装步骤:https://lnmp.org/install.html. 一键安装可以选择mysql版本.php版本, ...
随机推荐
- HDU 4405 Aeroplane chess(期望dp)
Aeroplane chess Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- git 设置别名 git alias
git config --global alias.st status git config --global alias.ck checkout git config --global alias. ...
- 局域网&广域网&Internet&计算机通信过程
1.局域网 覆盖范围小(100m以内),自己花钱购买,自己单位来维护,带宽固定的(10M,100M,1000M) 2.Internet ISP,有自己的机房,对网民提供访问Internet连接 3.广 ...
- TCP重组问题
今天问题: vqmon 测试一pcap抓包文件18.pcap.发现实际输出的视频分片信息和抓包不符合. ===>pts : 00:00:33 Too much data in TCP recei ...
- 掌握OpenStack部署的最佳实践 打破部署失败的魔咒
部署OpenStack环境并不是一项简单的任务:根据SUSE最近的调查显示“曾经部署过OpenStack的企业当中有一半都失败了”.然而,随着最佳实践的出现,企业可以使用其避免在部署OpenStack ...
- 【UVA10655】 Contemplation! Algebra
题目 给定 \(p = a + b\) 和 \(q = ab\) 和 \(n\),求 \(a ^ n + b ^ n\). $0\le n\lt 2^{63} $ 分析 大水题. 先考虑 \(n\) ...
- 程序员必备PC维修法(软件篇)
学会使用专业软件检测与修复电脑硬件故障问题也是程序员的一种软技能. windows篇 情景:如何获取电脑硬件的真实信息.(如何检验选购回来的硬件是否正品) 自检:使用AIDA64软件检查电脑硬件,能详 ...
- NSIS编译报错:您可能有有一个或两个(大)的旧临时文件
一.有时在编译NSIS时会出现如下错误: 注意: 您可能有有一个或两个(大)的旧临时文件 残留在临时目录文件夹中 (通常这种情况只会发生在 Windows 9x 系统中). 二.本人遇到的问题原因: ...
- linux socket c/s上传文件
这是上传文件的一个示例,可以参照自行修改成下载或者其它功能. 在上传时,需要先将文件名传到服务器端,这是采用一个结构体,包含文件名及文件名长度(可以用于校验),防止文件名乱码. client #inc ...
- HDU 4763 Theme Section ( KMP next函数应用 )
设串为str, 串长为len. 对整个串求一遍next函数,从串结尾开始顺着next函数往前找<=len/3的最长串,假设串长为ans,由于next的性质,所以找到的串肯定满足E……E这种形式, ...