Centos 6.7 编译安装LAMP
时间:2015-10-28 06:26 来源:linux.it.net.cn 作者:IT
一、环境和软件包准备
[root@yy ~]
# cat/etc/redhat-release
CentOS release 6.7 (Final)
[root@yy ~]
# uname -rm
2.6.32-573.el6.x86_64 x86_64
cd
/etc/yum
.repos.d/
wget http:
//mirrors
.163.com/.help
/CentOS6-Base-163
.repo
setenforce 0
service iptables stop
二、安装依赖环境
yum -y groupinstall
"Development Libraries"
yum -y groupinstall
"Desktop Platform Development"
yum -y groupinstall
"X Software Development"
yum -y
install
wget gcc gcc-c++ ncurses ncurses-devel cmakemake perl bison openssl openssl-devel gcc* libxml2 libxml2-devel curl-devellibjpeg* libpng* freetype* pcre-devel
bzip2
-devel libmcrypt-devel
三、编译安装apr
1、编译安装apr
cd
/tools
tar
xjvfapr-1.5.2.
tar
.bz2 -C
/usr/src/
;
cd
/usr/src/apr-1
.5.2/
.
/configure--prefix
=
/usr/local/apr
make
&& makeinstall
2、编译安装apr-util
cd
/tools/
tar
xjvfapr-util-1.5.4.
tar
.bz2 -C
/usr/src/
;
cd
/usr/src/apr-util-1
.5.4
.
/configure--prefix
=
/usr/local/apr-util
--with-apr=
/usr/local/apr/
make
&&
make
install
四、编译安装apache
cd
/tools
tar
xjvf httpd-2.4.17.
tar
.bz2 -C
/usr/src/
;
cd
/usr/src/httpd-2
.4.17
.
/configure--prefix
=
/usr/local/apache2
--with-apr=
/usr/local/apr--with-apr-util
=
/usr/local/apr-util/
--with-mpm=event --
enable
-so--
enable
-mods-shared=all --
enable
-proxy=shared --
enable
-proxy-balancer=shared--
enable
-prosy-http=shared --
enable
-proxy-ajp --
enable
-deflate --
enable
-cache--
enable
-disk-cache --
enable
-mem-cachemake &&
make
install
五、编译安装mysql
1、安装mysql
cd
/tools
tar
xzvfmysql-5.6.26.
tar
.gz -C
/usr/src/
;
cd
/usr/src/mysql-5
.6.26
cmake-DENABLE_DOWNLOADS=1 -DCMAKE_INSTALL_PREFIX=
/opt/mysql
--with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd
make
&&
make
install
2、创建相关设置
mkdir
/data/mysql/
{mysql-data,mysql-logs} –pv
groupadd -r -g 306 mysql
useradd
-r -g 306 -u 306mysql
chown
-R mysql.mysql
/data/mysql/
[mysql]
prompt= (\u@\h)[\d]>
[client]
port = 3306
socket =
/tmp/mysql3306
.sock
default_character_set = utf8
[mysqld]
user= mysql
port = 3306
socket =
/tmp/mysql3306
.sock
datadir =
/data/mysql/mysql-data
pid_file =
/data/mysql/mysql-data/mysql
.pid
log-bin =
/data/mysql/mysql-logs/mysql-bin
log-error =
/data/mysql/mysql-logs/mysql
.err
basedir=
/opt/mysql
datadir=
/data/mysql/mysql-data
defaultconf=
/etc/my
.cnf
chmod
+x
/etc/rc
.d
/init
.d
/mysqld
3、初始化数据库并启动
/opt/mysql/scripts/mysql_install_db--user
=mysql --datadir=
/data/mysql/mysql-data/
--basedir=
/opt/mysql/
--defaults-
file
=
/etc/my
.cnf
[root@yuanyang tools]
#/etc/rc.d/init.d/mysqld start
Starting MySQL.........SUCCESS!
PATH=$PATH:
/opt/mysql/bin/
chkconfig --add mysqld
chkconfig mysqld on
[root@yy tools]
# chkconfig --list mysqld
mysqld 0:off1:off2:on3:on4:on5:on6:off
[root@yy tools]
# service mysqld stop
Shutting down MySQL.SUCCESS!
六、编译安装php
1、安装curl
cd
/tools
tar
xzvf curl-7.45.0.
tar
.gz-C
/usr/src/
;
cd
/usr/src/curl-7
.45.0
.
/configure--prefix
=
/usr/local/curl
&&
make
&&
make
install
2、安装libmcrypt
cd
/tools
tar
xzvflibmcrypt-2.5.8.
tar
.gz -C
/usr/src/
;
cd
/usr/src/libmcrypt-2
.5.8/
.
/configure
--prefix=
/usr/local/libmcrypt
&&
make
&&
make
install
3、安装mhash
cd
/tools
tar
xzvfmhash-0.9.9.9.
tar
.gz -C
/usr/src/
;
cd
/usr/src/mhash-0
.9.9.9
.
/configure--prefix
=
/usr/local/mhash
&&
make
&&
make
install
ln
-s
/usr/local/lib/libmhash
.a
/usr/lib/libmhash
.a
ln
-s
/usr/local/lib/libmhash
.la
/usr/lib/libmhash
.la
ln
-s
/usr/local/lib/libmhash
.so
/usr/lib/libmhash
.so
ln
-s
/usr/local/lib/libmhash
.so.2
/usr/lib/libmhash
.so.2
ln
-s
/usr/local/lib/libmhash
.so.2.0.1
/usr/lib/libmhash
.so.2.0.1
echo
“
/usr/local/lib
” >>
/etc/ld
.so.conf
ldconfig
4、安装mcrypt
cd
/tools
tar
xzvf mcrypt-2.6.8.
tar
.gz -C
/usr/src/
;
cd
/usr/src/mcrypt-2
.6.8
.
/configure
--prefix=
/usr/local/mcrypt
--with-libmcrypt=
/usr/local/libmcrypt/
&&
make
&&
make
install
5、安装gettext
cd
/tools
tar
xvf gettext-0.19.5.
tar
-C
/usr/src/
;
cd
/usr/src/gettext-0
.19.5
.
/configure--prefix
=
/usr/local/gettext
&&
make
&&
make
install
6、安装libxml2
cd
/tools
tar
xzvflibxml2-2.6.30.
tar
.gz -C
/usr/src/
;
cd
/usr/src/libxml2-2
.6.30/
.
/configure--prefix
=
/usr/local/libxml2
&&
make
&&
make
install
7、安装php
cd
/tools
tarxzvf php-5.5.30.
tar
.gz -C
/usr/src/
;
cd
/usr/src/php-5
.5.30
.
/configure--prefix
=
/opt/php
--with-apxs2=
/usr/local/apache2/bin/apxs--with-curl
=
/usr/local/curl/
--with-mcrypt=
/usr/local/mcrypt/--with-mysql
=
/opt/mysql/
--with-gettext=
/usr/local/gettext/
--with-mysqli --with-bz2 --with-mhash--
enable
-sockets --
enable
-mbstring --
enable
-zip --
enable
-bcmath--
enable
-calendar --
enable
-exif --
enable
-
ftp
--
enable
-fpm --with-openssl--with-libxml-
dir
=
/usr/local/libxml2/
make
&&
make
install
8、设置phpinfo和phpadmin
(1)、设置phpinfo页面
cd
/usr/local/apache2/htdocs/
cat
> index.php <<EOF
<?php
phpinfo();
?>
EOF
DirectoryIndexindex.php index.html
AddTypeapplication
/x-httpd-php
.php .phtml
AddType application
/x-httpd-php-source
.phps
(2)、设置phpadmin
cd
/tools
unzipphpMyAdmin-4.5.0.2-all-languages.zip
mvphpMyAdmin-4.5.0.2-all-languages
/usr/local/apache2/htdocs/phpadmin
cd
/usr/local/apache2/htdocs/phpadmin
cpconfig.sample.inc.php config.inc.php
vim config.inc.php
mysqladmin -u root password abc123
mysqladmin -u root -h 127.0.0.1 passwordabc123
mysql -u root -pabc123
(root@127.0.0.1)[(none)]>grant allprivileges on *.* to root@
'%'
identified by
'root'
;
Query OK, 0 rows affected (0.00 sec)
(3)、修改php.in
cd
/usr/src/php-5
.5.30/
cp
php.ini-production
/opt/php/lib/php
.ini
七、扩展PHP模块
1、安装freetype
cd
/tools
tar
xjvffreetype-2.4.0.
tar
.bz2 -C
/usr/src/
;
cd
/usr/src/freetype-2
.4.0/
.
/configure--prefix
=
/usr/local/freetype
&&
make
&&
make
install
2、安装jpeg
cd
/tools
tar
xzvf jpegsrc.v9.
tar
.gz-C
/usr/src/
;
cd
/usr/src/jpeg-9
CFLAGS=
"-O3-fPIC"
.
/configure
--prefix=
/usr/local/jpeg
&&
make
&&
make
install
mkdir
-p
/usr/local/jpeg/include
mkdir
-p
/usr/local/jpeg/lib
mkdir
-p
/usr/local/jpeg/bin
mkdir
-p
/usr/local/jpeg/man/man1
3、安装libpng
cd
/tools
tar
xzvflibpng-1.2.53.
tar
.gz -C
/usr/src/
;
cd
/usr/src/libpng-1
.2.53
CFLAGS=
"-O3-fPIC"
.
/configure
--prefix=
/usr/local/libpng
&&
make
&&
make
install
4、安装gd
cd
/usr/src/php-5
.5.30
/ext/gd/
[root@yuanyang gd]
#/opt/php/bin/phpize
Configuring
for
:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
.
/configure--with-php-config
=
/opt/php/bin/php-config
--with-jpeg-
dir
=
/usr/local/jpeg
--with-png-
dir
=
/usr/local/libpng
--with-freetype-
dir
=
/usr/local/freetype
&&
make
&& makeinstall
5、安装zlib
cd
/tools
tar
xzvf zlib-1.2.3.
tar
.gz -C
/usr/src/
;
cd
/usr/src/zlib-1
.2.3
.
/configure--prefix
=
/usr/local/zlib
&&
make
&&
make
install
cd
/usr/src/php-5
.5.30
/ext/zlib/
mv
config0.m4 config.m4
[root@yuanyang zlib]
#/opt/php/bin/phpize
Configuring
for
:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
.
/configure--with-php-config
=
/opt/php/bin/php-config
&&
make
&& makeinstall
[root@yuanyang zlib]
# ls/opt/php/lib/php/extensions/no-debug-zts-20121212/
gd.so opcache.so zlib.so
6、编辑php.ini文件
extension_dir =
/opt/php/lib/php/extensions/no-debug-zts-20121212/
extension=gd.so
extension=zlib.so
/opt/php/bin/php
–m
/usr/local/apache2/bin/apachectlrestart
7、验证是否安装成功
八、搭建网站服务
cd
/tools
unzip opencart-2.1.0.1.zip;
cd
opencart-2.1.0.1
mv
upload/
/usr/local/apache2/htdocs/opencart
九、设置防火墙
[root@yuanyang tools]
# iptables -tfilter -I INPUT -p tcp --dport 80 -j ACCEPT
[root@yuanyang tools]
# iptables -tfilter -I INPUT -p tcp --dport 443 -j ACCEPT
[root@yuanyang tools]
# iptables -tfilter -I INPUT -p tcp --dport 22 -j ACCEPT
[root@yuanyang tools]
# iptables -tfilter -I INPUT -p tcp --dport 3306 -j ACCEPT
[root@yuanyang tools]
# iptables -tfilter -P INPUT DROP
[root@yuanyang tools]
# iptables -tfilter -I INPUT -m state --stateRELATED,ESTABLISHED
(责任编辑:IT)
一、环境和软件包准备
二、安装依赖环境
三、编译安装apr1、编译安装apr
2、编译安装apr-util
四、编译安装apache
五、编译安装mysql1、安装mysql
2、创建相关设置
3、初始化数据库并启动
六、编译安装php1、安装curl
2、安装libmcrypt
3、安装mhash
4、安装mcrypt
5、安装gettext
6、安装libxml2
7、安装php
8、设置phpinfo和phpadmin(1)、设置phpinfo页面
(2)、设置phpadmin
(3)、修改php.in
七、扩展PHP模块1、安装freetype
2、安装jpeg
3、安装libpng
4、安装gd
5、安装zlib
6、编辑php.ini文件
7、验证是否安装成功八、搭建网站服务
九、设置防火墙
(责任编辑:IT) |