在工作中经常会遇到许多的测试要求,测试环境一般都要求有lamp环境,或者单独要求mysql,apache;最近因为工作需要对extmail进行测试,测试环境需要lamp结构,因而抽空修改了下之前的脚本,将脚本整合成lamp.sh,可以单独来安装apache或者mysql,也可以集成lamp环境!注意:使用该脚本编译php前需要先编译好apache和mysql,脚本包含在附件中…
[root@orcl ~]# sh lamp.sh
Usage:lamp.sh {parpare|apache|php|mysql|lamp}
一:准备环境
- [root@orcl ~]# sh lamp.sh parpare
- parparing enviroment....
- setenforce: SELinux is disabled
- Loaded plugins: rhnplugin, security
- Package flex-2.5.4a-41.fc6.i386 already installed and latest version
- Package gcc-4.1.2-46.el5.i386 already installed and latest version
- ………………………………………………………………输出省略………………………………………………………………………………………………
- Package libusb-devel-0.1.12-5.1.i386 already installed and latest version
- Package newt-devel-0.52.2-12.el5.i386 already installed and latest version
- Package 1:libvorbis-devel-1.1.2-3.el5_3.3.i386 already installed and latest version
- No packages in any requested group available to install or update
- Loaded plugins: rhnplugin, security
- This system is not registered with RHN.
- RHN support will be disabled.
- Setting up Install Process
- Package 2:libpng-devel-1.2.10-7.1.el5_3.2.i386 already installed and latest version
- Package libjpeg-devel-6b-37.i386 already installed and latest version
- Package freetype-devel-2.2.1-21.el5_3.i386 already installed and latest version
- Nothing to do
- parparing enviroment successful...
为了节约脚本运行时间,每次可以在运行parpare之后,将软件源码包上传到/usr/local/src/tarbag目录,避免脚本自动下载源码包
二:测试编译php
- [root@orcl ~]# sh lamp.sh php
- Loaded plugins: rhnplugin, security
- This system is not registered with RHN.
- RHN support will be disabled.
- Setting up Remove Process
- No Match for argument: php
- Package(s) php available, but not installed.
- No Packages marked for removal
- Download and compile php...
- your must compile mysql-server first...
三:测试编译apache
- [root@orcl ~]# sh lamp.sh apache
- Loaded plugins: rhnplugin, security
- This system is not registered with RHN.
- RHN support will be disabled.
- Setting up Remove Process
- No Match for argument: httpd
- Package(s) httpd available, but not installed.
- No Packages marked for removal
- download and install apache_2.2.16.....
- Download httpd...
- --2011-09-05 09:34:23-- http://archive.apache.org/dist/httpd/httpd-2.2.16.tar.gz
- Resolving archive.apache.org... 140.211.11.131
- Connecting to archive.apache.org|140.211.11.131|:80... connected.
- HTTP request sent, awaiting response... 200 OK
- Length: 6369022 (6.1M) [application/x-gzip]
- Saving to: `/usr/local/src/tarbag/httpd-2.2.16.tar.gz'
- 100%[========================================================================>] 6,369,022 193K/s in 32s
- 2011-09-05 09:34:56 (193 KB/s) - `/usr/local/src/tarbag/httpd-2.2.16.tar.gz' saved [6369022/6369022]
- apache install complete done ...
- Configure apache...
- [root@orcl ~]# ls /usr/local/apache2.2.16/
- bin build cgi-bin conf error htdocs icons include lib logs man manual modules
四:编译mysql
- [root@orcl ~]# sh lamp.sh mysql
- Setting Environment variables...
- Creating data directory...
- Download and install mysql...
- ………………………输出省略…………………………………
- Mysql install complete done...
- Initialization mysql...
- Modify mysql-server main parameter file...
- Initialization mysql complete done...
- [root@orcl ~]# ls /usr/local/mysql/
- bin docs include lib libexec mysql-test share sql-bench
- [root@orcl ~]# ls /mydata/
- aclocal mysql mysql-bin.000001 mysql-bin.000002 mysql-bin.index test
- [root@orcl ~]# service mysqld restart
- MySQL manager or server PID file could not be found![FAILED]
- Starting MySQL.[ OK ]
- [root@orcl ~]# /usr/local/mysql/bin/mysql
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 1
- Server version: 5.1.36-log Source distribution
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- mysql>
五:正常编译php
- [root@orcl ~]# sh lamp.sh php
- Loaded plugins: rhnplugin, security
- This system is not registered with RHN.
- RHN support will be disabled.
- Setting up Remove Process
- No Match for argument: php
- Package(s) php available, but not installed.
- No Packages marked for removal
- Download and compile php...
- ………………………输出省略…………………………………
- php install complete done ...
- Start Apache with php support OK...
- [root@orcl ~]# /usr/local/apache2.2.16/bin/apachectl -t -D DUMP_MODULES |grep php
- Syntax OK
- php5_module (shared)
- [root@orcl ~]# ls /usr/local/php5.2.13/
- bin etc include lib man
- [root@orcl ~]# /usr/local/php5.2.13/bin/php -i |grep configure
- Configure Command => './configure' '--prefix=/usr/local/php5.2.13' '--with-config-file-path=/usr/local/php5.2.13/etc' '--with-apxs2=/usr/local/apache2.2.16/bin/apxs' '--with-bz2' '--with-curl' '--with-curlwrappers' '--enable-ftp' '--enable-sockets' '--disable-ipv6' '--with-gd' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-freetype-dir=/usr/local' '--enable-gd-native-ttf' '--with-iconv-dir=/usr/local' '--enable-mbstring' '--enable-calendar' '--with-gettext' '--with-libxml-dir=/usr/local' '--with-zlib' '--enable-zend-multibyte' '--with-pdo-mysql=/usr/local/mysql' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--with-mysql=/usr/local/mysql' '--enable-dom' '--with-ldap' '--enable-xml'
- [root@orcl ~]# netstat -ntpl |grep :80
- tcp 0 0 :::80 :::* LISTEN 20705/httpd
附件:http://down.51cto.com/data/2358861
本文转自斩月博客51CTO博客,原文链接http://blog.51cto.com/ylw6006/657907如需转载请自行联系原作者
ylw6006
本文介绍了一款用于快速部署LAMP环境的shell脚本。通过简单的命令即可完成Apache、PHP和MySQL的安装与配置,适用于快速搭建Web开发环境。
1923

被折叠的 条评论
为什么被折叠?



