环境搭建ubuntu 12.04 + nginx + Percona5.6.12
1
###搭建测试环境###
001
#设置root密码
002
sudo passwd root
003
#切换root
004
su root
005
#不知道为什么,换了源之后竟然连不上,无奈使用默认,谁告诉我原因?
006
gedit /etc/apt/sources.list
007
apt-get update
008
apt-get remove -y apache2 apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-common mysql-client mysql-server php5 php5-fpm pure-ftpd pure-ftpd-common pure-ftpd-mysql
009
apt-get -y autoremove
010
011
apt-get install -y gcc g++ make autoconf libltdl-dev libgd2-xpm-dev libfreetype6 libfreetype6-dev libxml2-dev libjpeg-dev libpng12-dev libcurl4-openssl-dev libssl-dev patch libmcrypt-dev libmhash-dev libncurses5-dev libreadline-dev bzip2 libcap-dev ntpdate chkconfig diffutils sendmail iptables unzip
012
013
#####64位
014
ln -s /usr/lib/x86_64-linux-gnu/libpng* /usr/lib/
015
ln -s /usr/lib/x86_64-linux-gnu/libjpeg* /usr/lib/
016
#####32位
017
ln -s /usr/lib/i386-linux-gnu/libpng* /usr/lib/
018
ln -s /usr/lib/i386-linux-gnu/libjpeg* /usr/lib/
019
020
#########同步时间
021
ntpdate tiger.sina.com.cn
022
hwclock -w
023
024
mkdir -p /data0/www/ php程序路径
025
mkdir -p /data0/soft/ 下载安装包路径
026
mkdir -p /data0/service/etc/ 配置文件夹
027
mkdir -p /data0/service/ 环境安装路径
028
mkdir -p /data0/service/init.d/ 启动程序路径
029
mkdir -p /data0/datas/mysql_data/ 数据存放目录
030
031
############
032
/etc/init.d/apparmor stop
033
update-rc.d -f apparmor remove
034
apt-get remove -y apparmor apparmor-utils
035
###简单添加下用户
036
groupadd mysql
037
useradd -g mysql mysql
038
039
groupadd www
040
useradd -g www www
041
042
####################安装Percona-Server
043
#下载cmake
044
tar zxvf cmake...tar.gz
045
./bootstrap
046
make
047
make install
048
apt-get install bison //缺少两个包,下面cmake会执行错误
049
050
tar zxvf Percona-Server-5.6.12.rc.tar.gz
051
cd Percona....
052
053
#cmake . -LH 查看有那写可以选择的编译参数
054
####换行的时候需不需要 -?? 忘了,
055
cmake ./
056
-DCMAKE_BUILD_TYPE:STRING:STRING=Release /
057
-DSYSCONFDIR:PATH=/data0/service/Percona-Server-5.6.12 /
058
-DCMAKE_INSTALL_PREFIX:PATH=/data0/service/Percona-Server-5.6.12 /
059
-DENABLED_PROFILING:BOOL=ON /
060
-DENABLE_DEBUG_SYNC:BOOL=OFF /
061
-DMYSQL_DATADIR:PATH=/data0/datas/mysql_data /
062
-DMYSQL_MAINTAINER_MODE:BOOL=OFF /
063
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk,gb2312 /
064
-DWITH_SSL:STRING=bundled /
065
-DWITH_UNIT_TESTS:BOOL=OFF /
066
-DWITH_ZLIB:STRING=bundled /
067
-DWITH_PARTITION_STORAGE_ENGINE:BOOL=ON /
068
-DINSTALL_LAYOUT:STRING=STANDALONE /
069
-DCOMMUNITY_BUILD:BOOL=ON /
070
-LH
071
072
make
073
074
make install
075
076
ln -sf /data0/service/Percona-Server-5.6.12 /data0/service/mysql
077
078
cp support-files/my-default.cnf /data0/service/etc/my.cnf
079
ln -sf /data0/service/etc/my.cnf /etc/my.cnf
080
081
cp support-files/mysql.server /data0/service/init.d/mysqld
082
chmod 755 /data0/service/init.d/mysqld
083
ln -sf /data0/service/init.d/mysqld /etc/init.d/mysqld
084
085
echo "/data0/service/mysql/lib/" >> /etc/ld.so.conf
086
ldconfig
087
088
089
chown -R mysql.mysql /data0/datas/mysql_data/
090
091
chmod 700 /data0/soft/Percona-Server-5.6.12-rc60.4/scripts/mysql_install_db
092
/data0/soft/Percona-Server-5.6.12-rc60.4/scripts/mysql_install_db --user=mysql --basedir=/data0/service/Percona-Server-5.6.12 --datadir=/data0/datas/mysql_data/
093
094
095
/data0/service/mysql/bin/mysqladmin -u root password "123456"
096
097
/data0/service/mysql/bin/mysql -uroot -p"123456" -e"use mysql;update user set password=password('123456') where user='root';delete from user where user='';drop user ''@'%';flush privileges;"
098
##启动下
099
service mysqld start
100
101
################################安装nginx
102
#先装pcre
103
tar zxvf pcre-8.10.tar.gz
104
cd pcre-8.10
105
./configure --prefix=/usr
106
make
107
make install
108
109
###自行替换*号
110
tar zxvf nginx-****.tar.gz
111
cd nginx***
112
make clean
113
./configure --user=www --group=www --prefix=/data0/service/nginx-**** --with-http_stub_status_module --with-http_ssl_module
114
115
make && make install
116
117
ln -sf /data0/service/nginx-***** /data0/service/nginx
118
mkdir /data0/service/nginx/conf/vhost
119
mkdir /data0/service/nginx/conf/rewrite
120
mkdir -p /data0/www/default
121
###网站的log就放在这了,记得自己改配置
122
mkdir -p /data0/www_logs
123
124
chown -R www.www /data0/www/
125
126
###下面几个配置文件,我就不发了,有需要的话再贴上来
127
cp ****/fcgi.conf /data0/service/nginx/conf/fcgi.conf
128
cp ****/nginx.conf /data0/service/nginx/conf/nginx.conf
129
cp ****/default.conf /data0/service/nginx/conf/vhost/000.default.conf
130
cp ****/init.nginxd /data0/service/init.d/nginxd
131
132
chmod 755 /data0/service/init.d/nginxd
133
rm -f /etc/init.d/nginxd
134
ln -sf /data0/service/init.d/nginxd /etc/init.d/nginxd
135
136
#记得要写好nginxd nginx.conf default.conf 的配置
137
#启动下
138
service nginxd start
139
#########################################安装php5.5
140
####libiconv
141
tar zxvf libiconv-1.14.tar.gz
142
cd libiconv-1.14
143
./configure --prefix=/usr
144
make
145
make install
146
ldconfig
147
148
tar zxvf php-5.5.1.tar.gz
149
150
###忘了这里操作了没有...
151
#64
152
#ln -s /usr/lib/x86_64-linux-gnu/libssl.* /usr/lib/
153
#32
154
ln -s /usr/lib/i386-linux-gnu/libssl.* /usr/lib/
155
####忘了....
156
157
cd php-5.5.1
158
#####编译的时候发现少了很多包,郁闷,这块用了很长时间,此奥!
159
apt-get install postgresql
160
apt-get install install postgresql-9.1 postgresql-client-9.1 postgresql-client-common postgresql-common postgresql-server-dev-9.1
161
apt-get install libxslt-dev
162
163
##去掉了--with-tidy=选项 因为没搞定这个tidy.... 刚开始忘记fpm了...
164
./configure --enable-opcache --prefix=/data0/service/php-5.5.1 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pgsql=/usr --with-curl --with-openssl-dir --with-zlib-dir=/usr --with-xpm-dir=/usr --with-pdo-pgsql=/usr --with-pdo-mysql=mysqlnd --with-xsl=/usr --with-ldap --with-xmlrpc --with-iconv-dir=/usr --with-snmp=/usr --enable-exif --enable-calendar --with-bz2=/usr --with-mcrypt=/usr --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-freetype-dir=/usr --enable-mbstring --enable-zip --with-pear --with-libdir=/lib/i386-linux-gnu --with-config-file-path=/data0/service/etc --enable-fpm
165
166
make ZEND_EXTRA_LIBS='-liconv'
167
168
make install
169
170
ln -sf /data0/service/php-5.5.1 /data0/service/php
171
###选好用那个 php.ini文件
172
cp php.ini-development /data0/service/php/etc/php.ini
173
ln -sf /data0/service/etc /data0/service/php/etc/php.ini
174
175
cd /data0/service/php/etc/
176
cp php-fpm.conf.default php-fpm.conf
177
vim php-fpm.conf
178
// 找到如下几行,确保如下几行前没有";"
179
pid = run/php-fpm.pid
180
error_log = log/php-fpm.log
181
listen = 127.0.0.1:9000
182
pm.max_children = 50
183
pm.start_servers = 20
184
pm.min_spare_servers = 5
185
pm.max_spare_servers = 35
186
pm.max_requests = 500
187
#记得修改下这两个值
188
user = www
189
group = www
190
191
192
cp /data0/soft/php-5.5.1/sapi/fpm/init.d.php-fpm /data0/service/init.d/php-fpm
193
chmod 755 /data0/service/init.d/php-fpm
194
ln -sf /data0/service/init.d/php-fpm /etc/init.d/php-fpm
195
196
vim php.ini
197
修改:extension="/data0/service/php-5.5.1/lib/php/extensions/no-debug-non-zts-20121212/"
198
199
######搞定,收工
200
service mysqld restart
201
service php-fpm start
202
service nginxd restart
203
204
205
##############################################
206
# 反正我是成功了~ 舒坦~ #
207
##############################################