博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
lnmp一键安装脚本
阅读量:7199 次
发布时间:2019-06-29

本文共 4538 字,大约阅读时间需要 15 分钟。

 入职新公司的第一天,带我的哥们就分配给我一个任务,让我装一个lnmp,并且写成脚本,这不是so easy 吗,于是我马上就开搞了,现在把我的脚本分享一下给大家。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#lnmp安装脚本
#Email:1445675350@qq.com
#autor:fujinzhou
#create time:  2016-11-29
 
yum -y 
install 
vim-enhanced ncurses-devel elinks gcc gcc-c++ flex bison autoconf automake 
gzip 
net-snmp-devel net-snmp ncurses-devel pcre pcre-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel  pam-devel libtool libtool-ltdl openssl openssl-devel fontconfig-devel libxml2-devel curl-devel  libicu libicu-devel libmcrypt libmcrypt-devel libmhash libmhash-devel
 
#添加nginx用户
user=
'nginx'
group=
'nginx'
user_exists=$(
id 
-nu $user)
if 
[ ! $user_exists ]; 
then
 
/usr/sbin/groupadd 
-f $group
 
/usr/sbin/useradd 
-g $group $user -s 
/sbin/nologin 
-M
fi
 
#安装nginx
wget http:
//nginx
.org
/download/nginx-1
.8.1.
tar
.gz 
tar 
-zxf nginx-1.8.1.
tar
.gz && 
cd 
nginx-1.8.1
.
/configure    
--prefix=
/usr/local/nginx     
--pid-path=
/usr/local/nginx/nginx
.pid   --user=nginx   --group=nginx  \
--with-http_ssl_module   --with-http_flv_module   --with-http_stub_status_module  --with-http_gzip_static_module  --http-client-body-temp-path=
/usr/local/nginx/client  
\
--http-proxy-temp-path=
/usr/local/nginx/proxy 
--http-fastcgi-temp-path=
/usr/local/nginx/fcgi  
--http-uwsgi-temp-path=
/usr/local/nginx/uwsgi  
--http-scgi-temp-path=
/usr/local/nginx/scgi  
--with-pcre
 
make 
&& 
make 
install
 
#启动nginx
/usr/local/nginx/sbin/nginx
 
#配置nginx
sed 
-i 
'56a\location ~ \.php$ {\n\    root          html;\n\    fastcgi_pass  127.0.0.1:9000;\n\    fastcgi_index  index.php;\n\    fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;\n\    include        fastcgi_params;\n\}\n' 
/usr/local/nginx/conf/nginx
.conf
/usr/local/nginx/sbin/nginx  
-s reload
echo 
-e 
'<?php\n echo "nginx and PHP is OK";\n?>\n' 
>
/usr/local/nginx/html/index
.php
 
#添加mysql用户
user=
'mysql'
group=
'mysql'
user_exists=$(
id 
-nu $user)
if 
[ ! $user_exists ]; 
then
 
/usr/sbin/groupadd 
-f $group
 
/usr/sbin/useradd 
-g $group $user -s 
/sbin/nologin 
-M
fi
 
#安装Mysql
wget http:
//mirrors
.sohu.com
/mysql/MySQL-5
.6
/mysql-5
.6.33-linux-glibc2.5-x86_64.
tar
.gz
tar 
-xf mysql-5.6.33-linux-glibc2.5-x86_64.
tar
.gz  && 
mv 
mysql-5.6.33-linux-glibc2.5-x86_64 
/usr/local/mysql
 
#配置mysql
mkdir 
-p 
/data/mysql
chown 
-R mysql:mysql 
/data/mysql/
chown 
-R mysql:mysql 
/usr/local/mysql/
/usr/local/mysql/scripts/mysql_install_db  
--basedir=
/usr/local/mysql/ 
--datadir=
/data/mysql/ 
--user=mysql  >>
/dev/null
cp 
/usr/local/mysql/support-files/my-default
.cnf  
/etc/my
.cnf
cp 
/usr/local/mysql/support-files/mysql
.server  
/etc/init
.d
/mysqld
sed 
-i 
's#^datadir=#datadir=/data/mysql#' 
/etc/init
.d
/mysqld
sed 
-i 
's#^basedir=#basedir=/usr/local/mysql#' 
/etc/init
.d
/mysqld
 
#启动mysql
service mysqld start
chkconfig mysqld on
 
#添加php用户
#添加mysql用户
user=
'www'
group=
'www'
user_exists=$(
id 
-nu $user)
if 
[ ! $user_exists ]; 
then
 
/usr/sbin/groupadd 
-f $group
 
/usr/sbin/useradd 
-g $group $user -s 
/sbin/nologin 
-M
fi
 
#安装php
yum 
install 
-y libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel
wget http:
//mirrors
.sohu.com
/php/php-5
.6.12.
tar
.gz
tar 
-xf php-5.6.12.
tar
.gz && 
cd 
php-5.6.12
.
/configure 
--prefix=
/usr/local/php 
--with-config-
file
-path=
/usr/local/php/etc
\
 
--with-mysql=
/usr/local/mysql  
--with-mysqli=
/usr/local/mysql/bin/mysql_config
\
 
--
enable
-fpm\
 
--
enable
-mbstring=all\
 
--
enable
-soap\
 
--
enable
-zip\
 
--
enable
-calendar\
 
--
enable
-bcmath\
 
--
enable
-exif\
 
--
enable
-
ftp
\
 
--
enable
-intl\
 
--with-openssl\
 
--with-zlib\
 
--with-curl\
 
--with-gd\
 
--with-zlib-
dir
=
/usr/lib
\
 
--with-png-
dir
=
/usr/lib
\
 
--with-jpeg-
dir
=
/usr/lib
\
 
--with-gettext\
 
--with-mhash\
 
--with-fpm-user=www\
 
--with-fpm-group=www
  
make  
&& 
make 
install
 
#配置php
cp 
php.ini-development  
/usr/local/php/etc/php
.ini
sed 
-i 
's#^;date.timezone =#date.timezone=Asia/Shanghai#' 
/usr/local/php/etc/php
.ini
cp  
/usr/local/php/etc/php-fpm
.conf.default  
/usr/local/php/etc/php-fpm
.conf
cp 
sapi
/fpm/init
.d.php-fpm 
/etc/init
.d
/php-fpm
chmod 
+x 
/etc/init
.d
/php-fpm
 
#启动php-fpm
service php-fpm start
chkconfig php-fpm on
 
#删除解压目录
rm 
/root/lnmp/php-5
.6.12 -rf
rm 
/root/lnmp/nginx-1
.8.1 -rf

测试访问一下

本文转自 shouhou2581314 51CTO博客,原文链接:http://blog.51cto.com/thedream/1877631,如需转载请自行联系原作者

你可能感兴趣的文章
Powershell + Nagios 监控 VEEAM 备份状态
查看>>
布雷(扫雷游戏)
查看>>
收集整理了一些免费的区块链、以太坊技术开发相关的文件,有需要的拿去
查看>>
SKYPE原理分析
查看>>
Add Digits(leetcode258)
查看>>
6.3-全栈Java笔记:异常处理方法(上)
查看>>
Spark 性能相关参数配置详解-Storage篇
查看>>
十四,泛型(Generics)
查看>>
C3P0详细配置及其说明
查看>>
RedHat linux系统加固
查看>>
Linux下 RabbitMQ的安装与配置
查看>>
shell编程——$数字的含义
查看>>
Tomcat 安全配置与性能优化
查看>>
PHP教程:我们什么时候应该使用异常?
查看>>
我的友情链接
查看>>
搭建 vsftpd FTP服务器
查看>>
安全技术积累-搜索目标漏洞20163月
查看>>
python_day11_IO模型
查看>>
RAID1创建
查看>>
再谈可重入和线程安全
查看>>