Nginx 1.6.2 + PHP 5.5.20 + MySQL 5.6.10 在 CentOS64 下的编译安装

星期二, 2015-01-06 | Author: Lee | linux | 4,193 views

实际安装可以最新Nginx1.10.11 和php5.5.38 mysq5.7
更新时间到 2017-03-01

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
1.系统预先配置
yum install wget
yum install pcre
yum install openssl*
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers make
yum -y install gd gd2 gd-devel gd2-devel
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
ulimit -SHn 65535
mkdir -p /ia/data/
cd /ia/data/
wget http://ftp.exim.llorien.org/pcre/pcre-8.32.tar.gz
tar -zxvf pcre-8.32.tar.gz 
mkdir tgz
mv pcre-8.32* tgz/
mkdir installsoft
cd installsoft/
wget http://nginx.org/download/nginx-1.6.2.tar.gz
tar xzvf nginx-1.6.2.tar.gz 
cd nginx-1.6.2
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/ia/data/tgz/pcre-8.32 --with-http_realip_module --with-http_image_filter_module
make
make install
/usr/local/webserver/nginx/sbin/nginx -V
 
 2、安装 MySQL:
wget http://downloads.mysql.com/archives/mysql-5.6/mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz
tar zxvf mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.10-linux-glibc2.5-x86_64 /usr/local/webserver/mysql
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
mkdir -p /Data/data/mysql/data
yum install libaio
 
 
/usr/local/webserver/mysql/scripts/mysql_install_db --basedir=/usr/local/webserver/mysql --datadir=/ia/data/mysql/data --user=mysql
 
##mysql 5.7更新了初始化方式会有默认密码生成 使用 --initialize-insecure 会不生成root密码否则注意看密码
/usr/local/webserver/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/webserver/mysql --datadir=/ia/data/mysql/data 
 
sed -i "s#/usr/local/mysql#/usr/local/webserver/mysql#g" /usr/local/webserver/mysql/bin/mysqld_safe
GRANT ALL PRIVILEGES ON *.* TO 'ia_admin'@'localhost' IDENTIFIED BY '12345678';
GRANT ALL PRIVILEGES ON *.* TO 'ia_admin'@'127.0.0.1' IDENTIFIED BY '12345678';
GRANT ALL PRIVILEGES ON *.* TO 'ia_admin'@'%' IDENTIFIED BY '12345678';
##忘记密码重置的配置 my.cnf 添加
#skip-grant-tables
#skip-networking
 
#后续mysql5.7登录mysql执行
ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678';
update user set authentication_string=PASSWORD("12345678") where User='root';
##修改成功后 可以启用GRANT去新增用户,会让强制改下root密码再执行
 
3、安装PHP依赖库
mkdir -p /usr/local/webserver/libs/
wget http://www.ijg.org/files/jpegsrc.v9.tar.gz     
tar zxvf jpegsrc.v9.tar.gz
cd jpeg-9/
./configure --prefix=/usr/local/webserver/libs --enable-shared --enable-static --prefix=/usr/local/webserver/libs
make
make install
cd ../
 
wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.2.tar.gz
tar zxvf libpng-1.6.2.tar.gz
cd libpng-1.6.2/
./configure --prefix=/usr/local/webserver/libs
make
make install
cd ../
 
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.12.tar.gz
tar zxvf freetype-2.4.12.tar.gz
cd freetype-2.4.12/
./configure --prefix=/usr/local/webserver/libs
make
make install
cd ../
 
 
wget "http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz"
wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz"
wget "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz"
 
 
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure --prefix=/usr/local/webserver/libs
make
make install
cd libltdl/
./configure --prefix=/usr/local/webserver/libs --enable-ltdl-install
make
make install
cd ../../
 
 
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure --prefix=/usr/local/webserver/libs
make
make install
cd ../
 
vi /etc/ld.so.conf
 
添加:
/usr/local/webserver/libs/lib
 
然后:
ldconfig
 
 
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
export LDFLAGS="-L/usr/local/webserver/libs/lib -L/usr/lib"
export CFLAGS="-I/usr/local/webserver/libs/include -I/usr/include"
touch malloc.h
./configure --prefix=/usr/local/webserver/libs --with-libmcrypt-prefix=/usr/local/webserver/libs
make
make install
cd ../
 
4、编译安装PHP 5.5
wget http://cl1.php.net/get/php-5.5.20.tar.gz/from/this/mirror
tar zxvf php-5.5.20.tar.gz
cd php-5.5.20/
export LIBS="-lm -ltermcap -lresolv"
export DYLD_LIBRARY_PATH="/usr/local/webserver/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
export LD_LIBRARY_PATH="/usr/local/webserver/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
 
ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so.20.3.4 /usr/local/webserver/mysql/lib/libmysqlclient_r.so
 
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir=/usr/local/webserver/libs --with-jpeg-dir=/usr/local/webserver/libs --with-png-dir=/usr/local/webserver/libs --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt=/usr/local/webserver/libs --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-pdo-mysql --enable-maintainer-zts
 
make
make install
cp php.ini-development /usr/local/webserver/php/etc/php.ini
 
##生产环境推荐
cp php.ini-production /usr/local/webserver/php/etc/php.ini
cd ../
ln -s /usr/local/webserver/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
如果是5.7的mysql做软链接
ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so.20 /usr/lib/libmysqlclient.so.20
 
mv /usr/local/webserver/php/etc/php-fpm.conf.default /usr/local/webserver/php/etc/php-fpm.conf
 
##一定记得修改 php-fpm.conf 的启动组为www(把对应的nobody修改下,否则php文件无法接收)
 
 5、编译安装PHP扩展
wget http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
tar zxvf autoconf-latest.tar.gz
cd autoconf-2.69/
./configure --prefix=/usr/local/webserver/libs
make
make install
cd ../
 
wget http://pecl.php.net/get/memcache-2.2.7.tgz
tar zxvf memcache-2.2.7.tgz
cd memcache-2.2.7/
export PHP_AUTOCONF="/usr/local/webserver/libs/bin/autoconf"
export PHP_AUTOHEADER="/usr/local/webserver/libs/bin/autoheader"
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../
 
 
  打开 /usr/local/webserver/php/etc/php.ini 查找 ; extension_dir = "ext"
  在其后增加一行:
extension = "memcache.so"

Tags: , , ,

文章作者: Lee

本文地址: https://www.pomelolee.com/1409.html

除非注明,Pomelo Lee文章均为原创,转载请以链接形式标明本文地址

No comments yet.

Leave a comment

Search

文章分类

Links

Meta