首页 > 代码库 > LAMP部署流水

LAMP部署流水

1、安装完成linux系统后,关闭防火墙:

[root@localhost ~]# service iptables stop

iptables: Setting chains to policy ACCEPT: nat mangle filte[  OK  ]

iptables: Flushing firewall rules:                         [  OK  ]

iptables: Unloading modules:                               [  OK  ]

[root@localhost ~]# chkconfig iptables off

2、关闭selinux

[root@localhost ~]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

#     enforcing - SELinux security policy is enforced.

#     permissive - SELinux prints warnings instead of enforcing.

#     disabled - No SELinux policy is loaded.

SELINUX=disabled

# SELINUXTYPE= can take one of these two values:

#     targeted - Targeted processes are protected,

#     mls - Multi Level Security protection.

SELINUXTYPE=targeted

3、检查并卸载lamp默认安装环境

[root@dbking rpm]# rpm -qa|grep httpd

[root@dbking rpm]# rpm -qa|grep php

[root@dbking rpm]# rpm -qa|grep mysql

mysql-libs-5.1.71-1.el6.x86_64

[root@dbking rpm]# yum remove mysql-libs-5.1.71-1.el6.x86_64

[root@dbking rpm]# rpm -qa|grep mysql

[root@dbking rpm]#

4、检查编译工具

[root@dbking rpm]# gcc -v

Using built-in specs.

Target: x86_64-redhat-linux

Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux

Thread model: posix

gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)

#yum install libtool-ltdl-devel

#yum install zlib-devel pcre-devel

5、上传源码包并解压

6、安装lamp源码包

./configure 配置

make && make install 编译并安装cp

(1)安装libxml2

[root@dbking /]# cd /rpm/libxml2-2.9.4

[root@dbking libxml2-2.9.4]# ./configure --prefix=/usr/local/libxml2/

[root@dbking libxml2-2.9.4]# make

[root@dbking libxml2-2.9.4]# make install

(2)安装libmcrypt

[root@dbking libltdl]# cd libmcrypt-2.5.8

[root@dbking libltdl]# ./configure --prefix=/usr/local/libmcrypt

[root@dbking libltdl]# make && make install

[root@dbking libltdl]# cd libltdl/

[root@dbking libltdl]# ./configure --enable-ltdl-install

[root@dbking libltdl]# make

[root@dbking libltdl]# make install

(3)安装zlib

[root@dbking zlib-1.2.8]# ./configure

[root@dbking zlib-1.2.8]# make && make install

(4)安装libpng

[root@dbking libpng-1.5.27]# ./configure --prefix=/usr/local/libpng

[root@dbking libpng-1.5.27]# make && make install

(5)安装jpeg

[root@dbking jpeg-9b]# mkdir /usr/local/jpeg9

[root@dbking jpeg-9b]# mkdir /usr/local/jpeg9/bin

[root@dbking jpeg-9b]# mkdir /usr/local/jpeg9/lib

[root@dbking jpeg-9b]# mkdir /usr/local/jpeg9/include

[root@dbking jpeg-9b]# mkdir -p /usr/local/jpeg9/man/man1

[root@dbking jpeg-9b]# ./configure --prefix=/usr/local/jpeg9/ --enable-shared --enable-static

[root@dbking jpeg-9b]# make

[root@dbking jpeg-9b]# make install

(6)安装freetype

[root@dbking freetype-2.6.2]# yum install bzip2-devel libpng-devel

[root@dbking freetype-2.6.2]# ./configure --prefix=/usr/local/freetype --with-bzip2=yes --with-harfbuzz=no

[root@dbking freetype-2.6.2]# make

[root@dbking freetype-2.6.2]# make install

(7)安装autoconf

[root@dbking autoconf-2.10]# ./configure

[root@dbking autoconf-2.10]# make && make install

(8)安装gd

[root@dbking libgd-2.1.1]# ./configure --prefix=/usr/local/gd2/ --with-jpeg=/usr/local/jpeg9/ --with-freetype=/usr/local/freetype/ --with-png=/usr/local/libpng/

[root@dbking libgd-2.1.1]# make

[root@dbking libgd-2.1.1]# make install

(9)安装apache

[root@dbking httpd-2.2.31]# ./configure --prefix=/usr/local/apache2 --sysconfdir=/etc/httpd/ --with-included-apr --disable-userdir --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support

[root@dbking httpd-2.2.31]# make

[root@dbking httpd-2.2.31]# make install

启动apache服务器:[root@dbking httpd-2.2.31]# /usr/local/apache2/bin/apachectl start

配置apache自动启动:#echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.local

[root@dbking rpm]# vim /etc/httpd/httpd.conf

ServerName localhost:80

(10)安装ncurses

[root@dbking ncurses-5.9]# ./configure --with-shared --without-debug --without-ada --enable-overwrite

[root@dbking ncurses-5.9]# make

[root@dbking ncurses-5.9]# make install

[root@dbking ncurses-5.9]# yum install ncurses-devel

(11)安装mysql

参考:http://www.z-dig.com/binary-packages-to-install-mysql-5-5.html

建组、建用户:

[root@dbking mysql]# groupadd mysql

[root@dbking mysql]# useradd -g mysql mysql

解压安装程序:

[root@dbking mysql]# tar -zxvf mysql.tar.gz

[root@dbking mysql]# mv /rpm/mysql /usr/local/mysql

初始化:

[root@dbking mysql]# ./scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql

配置文件:

[root@dbking mysql]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

basedir = /usr/local/mysql

datadir = /usr/local/mysql/data

port = 3306

log_error=mysql.err

修改目录权限:

[root@dbking mysql]# chown -R mysql:mysql /usr/local/mysql/

修改环境变量:

export PATH=/usr/local/mysql/bin:$PATH

启动数据库:

[mysql@dbking ~]$ /usr/local/mysql/bin/mysqld --defaults_file=/etc/my.cnf --user=mysql &

设置mysql开机自动启动:

[root@dbking mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld

[root@dbking mysql]# chown -R root:root /etc/rc.d/init.d/mysqld

[root@dbking mysql]# chmod 755 /etc/rc.d/init.d/mysqld

[root@dbking mysql]# chkconfig --add mysqld

[root@dbking mysql]# chkconfig --list mysqld

mysqld          0:off 1:off 2:on 3:on 4:on 5:on 6:off

[root@dbking mysql]# service mysqld status

ERROR! MySQL is not running

mysql的root用户授权:

mysql> grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘oracle‘;

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> set password for ‘root‘@‘%‘=password(‘oracle‘);

Query OK, 0 rows affected (0.00 sec)

(12)安装php

[root@dbking php-5.6.22]# ./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg9/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/ --with-gd --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets  --enable-bcmath --with-gettext

[root@dbking php-5.6.22]# make

[root@dbking php-5.6.22]# make install

生成php.ini文件:

[root@dbking php-5.6.22]# cp /rpm/php-5.6.22/php.ini-production /usr/local/php/etc/php.ini

编辑/etc/httpd/httpd.conf

[root@dbking php-5.6.22]# vim /etc/httpd/httpd.conf

添加: AddType application/x-httpd-php .php .phtml

以及如下红色部分

<IfModule dir_module>

    DirectoryIndex index.html index.php

</IfModule>

重启apache服务:

[root@dbking php-5.6.22]# /usr/local/apache2/bin/apachectl stop

[root@dbking php-5.6.22]# /usr/local/apache2/bin/apachectl start

测试php是否安装成功:

[root@dbking htdocs]# cat test.php

<?php

echo phpinfo();

?>

13、安装ZendOptimizer

[root@dbking ZendOptimizer-3.3.0a-linux-glibc21-i386]# pwd

/rpm/tempdir/ZendOptimizer-3.3.0a-linux-glibc21-i386

[root@dbking ZendOptimizer-3.3.0a-linux-glibc21-i386]# ./install.sh

./install.sh: ./php: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

错误原因是64位系统安装了32位程序,可以通过如下命令修正:

[root@dbking ZendOptimizer-3.3.0a-linux-glibc21-i386]# yum install glibc.i686

[root@dbking ZendOptimizer-3.3.0a-linux-glibc21-i386]# ./install.sh

按照提示执行。

发现此种情况:

[root@dbking ZendOptimizer-3.3.0a-linux-glibc21-i386]# ./install.sh

Please, wait ...

Zend Optimizer installation was NOT completed successfully.

Error while executing the dialog utility.

Probable reason - wrong terminal settings.

Please use install-tty instead.

For further assistance, please contact Zend Support at

https://www.zend.com/support/

[To continue, press Enter]

[root@dbking ZendOptimizer-3.3.0a-linux-glibc21-i386]#

执行:

[root@dbking ZendOptimizer-3.3.0a-linux-glibc21-i386]# ./install-tty

14、安装phpmyadmin

[root@dbking rpm]# unzip phpMyAdmin-4.6.2-all-languages.zip

[root@dbking rpm]# mv phpMyAdmin-4.6.2-all-languages /usr/local/apache2/htdocs/phpmyadmin

[root@dbking rpm]# cd /usr/local/apache2/htdocs/phpmyadmin/

cp配置文件:

[root@dbking phpmyadmin]# cp config.sample.inc.php config.inc.php

编辑配置文件,将cookie改为http即可:

修改host为IP地址或主机名(主机名需要配置好才可以)。

15、安装wordpress

[root@dbking rpm]# mv wordpress /usr/local/apache2/htdocs/

[root@dbking wordpress]# cp wp-config-sample.php wp-config.php

[root@dbking wordpress]# vim wp-config.php

输入主机名、用户、密码,然后进行图形界面安装。

LAMP部署流水