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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
mysql安装:
 
1、下载mysql的repo源
 
 
wget http: //repo .mysql.com /mysql-community-release-el7-5 .noarch.rpm
 
2、安装mysql-community-release-el7-5.noarch.rpm包
 
  
 
rpm -ivh mysql-community-release-el7-5.noarch.rpm
  
 
备注:安装这个包后,会获得两个mysql的yum repo源: /etc/yum .repos.d /mysql-community .repo, /etc/yum .repos.d /mysql-community-source .repo
 
3、安装mysql:
 
  
 
yum  install  mysql-server
  
 
4、启动服务
 
  
 
systemctl start mysqld
  
 
php安装:
 
官网下载: http: //php .net /downloads .php
 
1、版本下载
 
http: //cn2 .php.net /get/php-7 .1.0. tar .gz /from/this/mirror
2、解压
 
tar  -zxvf php-7.1.0. tar .gz
3、进入目录  
 
 
cd  php-7.1.0
4、下载扩展库
 
yum  install  -y libxml2-devel php-mcrypt libmcrypt libmcrypt-devel openssl openssl-devel libcurl libcurl-devel zlib zlib-devel libjpeg libjpeg-devel freetype freetype-devel libpng libpng-devel
5、编译安装
 
 
. /configure  --prefix= /usr/local/php7  \
--with-config- file -path= /usr/local/php7/etc  \
--with-mcrypt= /usr/include  \
--with-mysql \
--with-gd \
--with-iconv \
--with-zlib \
-- enable -xml \
-- enable -bcmath \
-- enable -shmop \
-- enable -sysvsem \
-- enable -inline-optimization \
-- enable -mbregex \
-- enable -fpm \
-- enable -mbstring \
-- enable - ftp  \
-- enable -gd-native-ttf \
--with-openssl \
-- enable -pcntl \
-- enable -sockets \
--with-xmlrpc \
-- enable -zip \
-- enable -soap \
--without-pear \
--with-gettext \
-- enable -session \
--with-curl \
--with-jpeg- dir  \
--with-freetype- dir  \
-- enable -opcache
 
make
make  install
 
6、配置:
 
 
cp  php.ini-development  /usr/local/php7/lib/php .ini
cp  /usr/local/php7/etc/php-fpm .conf.default  /usr/local/php7/etc/php-fpm .conf
cp  /usr/local/php7/etc/php-fpm .d /www .conf.default  /usr/local/php7/etc/php-fpm .d /www .conf
7、添加服务
 
 
vim  /etc/systemd/system/php-fpm .service
 
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
  
[Service]
Type=simple
PIDFile= /run/php-fpm .pid
ExecStart= /usr/local/php7/sbin/php-fpm  --nodaemonize --fpm-config  /usr/local/php7/etc/php-fpm .conf
ExecReload= /bin/kill  -USR2 $MAINPID
ExecStop= /bin/kill  -SIGINT $MAINPID
  
[Install]
WantedBy=multi-user.target
8、启动php-fpm
 
 
systemctl start php-fpm.service
9、添加到开机启动
 
 
systemctl  enable  php-fpm.service
备注: systemctl指令
 
 
systemctl  enable  *.service  #开机运行服务
systemctl disable *.service  #取消开机运行
systemctl start *.service  #启动服务
systemctl stop *.service  #停止服务
systemctl restart *.service  #重启服务
systemctl reload *.service  #重新加载服务配置文件
systemctl status *.service  #查询服务运行状态
systemctl --failed  #显示启动失败的服务
  
 
nginx安装配置:
 
1、下载安装包
 
 
wget http: //nginx .org /download/nginx-1 .10.1. tar .gz
2、解压
 
 
tar  -zvxf nginx-1.10.1. tar .gz
3、进入目录  
 
 
cd  nginx-1.10.1
4、编译安装
 
 
. /configure  --prefix= /usr/local/nginx-1 .10.1 \
--with-http_ssl_module \
--with-http_stub_status_module
 
make
make  install
  
 
 
ln  -s  /usr/local/nginx-1 .10.1/  /usr/local/nginx
  
 
5、添加启动脚本
 
 
vim  /etc/init .d /nginx
 
复制代码
#! /bin/bash
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig:   - 85 15
# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
#
# processname: nginx
# config:      /etc/nginx/nginx.conf
# pidfile:     /var/run/nginx/nginx.pid
  
# Source function library.
/etc/rc .d /init .d /functions
  
# Source networking configuration.
/etc/sysconfig/network
  
# Check that networking is up.
"$NETWORKING"  "no"  ] &&  exit  0
  
nginx= "/usr/local/nginx/sbin/nginx"
prog=$( basename  $nginx)
  
NGINX_CONF_FILE= "/usr/local/nginx/conf/nginx.conf"
  
[ -f  /etc/sysconfig/nginx  ] && .  /etc/sysconfig/nginx
  
lockfile= /var/lock/nginx .lock
  
start() {
     [ -x $nginx ] ||  exit  5
     [ -f $NGINX_CONF_FILE ] ||  exit  6
     echo  -n $ "Starting $prog: "
     daemon $nginx -c $NGINX_CONF_FILE
     retval=$?
     echo
     [ $retval - eq  0 ] &&  touch  $lockfile
     return  $retval
}
  
stop() {
     echo  -n $ "Stopping $prog: "
     killproc $prog -QUIT
     retval=$?
     echo
     [ $retval - eq  0 ] &&  rm  -f $lockfile
     return  $retval
}
  
restart() {
     configtest ||  return  $?
     stop
     sleep  1
     start
}
  
reload() {
     configtest ||  return  $?
     echo  -n $ "Reloading $prog: "
     killproc $nginx -HUP
     RETVAL=$?
     echo
}
  
force_reload() {
     restart
}
  
configtest() {
   $nginx -t -c $NGINX_CONF_FILE
}
  
rh_status() {
     status $prog
}
  
rh_status_q() {
     rh_status > /dev/null  2>&1
}
  
case  "$1"  in
     start)
         rh_status_q &&  exit  0
         $1
         ;;
     stop)
         rh_status_q ||  exit  0
         $1
         ;;
     restart|configtest)
         $1
         ;;
     reload)
         rh_status_q ||  exit  7
         $1
         ;;
     force-reload)
         force_reload
         ;;
     status)
         rh_status
         ;;
     condrestart|try-restart)
         rh_status_q ||  exit  0
             ;;
     *)
         echo  $ "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
         exit  2
esac