利用脚本安装httpd:
[root@localhost ~]# vim 1.sh
#!/bin/bash
cd /media/dvd/Packages/
rpm -ivh ncurses-devel-5.9-13.20130511.el7.x86_64.rpm
yum -y install gcc gcc-c++
cd /home/~
tar zxf httpd-2.2.17.tar.gz -C /usr/src
cd /usr/src/httpd-2.2.17/
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrit --enable-charset-list --enable-cgi
make && make install
ln -s /usr/local/httpd/bin/* /usr/local/bin/
ls -l /usr/local/bin/httpd /usr/local/bin//apachectl
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
echo "#chkconfig:35 25 25" >> /etc/init.d/httpd
echo "#description:haha" >> /etc/init.d/httpd
chkconfig --add httpd
chkconfig --list httpd
/usr/local/httpd/bin//apachectl -t
/etc/init.d/httpd start
netstat -pant | grep httpd
[root@localhost ~]# chmod +x 1.sh
[root@localhost ~]# . 1.sh
利用脚本安装MySQL:
[root@localhost ~]# vim 2.sh
#!/bin/bash
cd /media/dvd/Packages/
rpm -ivh ncurses-devel-5.9-13.20130511.el7.x86_64.rpm
yum -y install gcc gcc-c++
cd /home/~/
tar zxvf cmake-2.8.6.tar.gz -C /usr/
cd /usr/cmake-2.8.6/
./configure
gmake && gmake install -j 4
groupadd mysql
useradd -M -s /sbin/nologin mysql -g mysql
cd /home/~/
tar zxvf mysql-5.5.22.tar.gz -C /usr/src/
cd /usr/src/mysql-5.5.22/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSET=all
make -j 4 && make install -j 4
chown -R mysql:mysql /usr/local/mysql
rm -fr /etc/my.cnf
cd /usr/src/mysql-5.5.22/
cp support-files/my-medium.cnf /etc/my.cnf
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
echo "PATH"=$PATH:/usr/local/mysql/bin/ >> /etc/profile
. /etc/profile
cp -fr support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
systemctl restart mysqld
netstat -pant | grep mysqld
[root@localhost ~]# chmod +x 2.sh
[root@localhost ~]# . 2.sh
安装PHP:
[root@localhost ~]# cd /media/dvd/Packages/
[root@localhost Packages]# rpm -ivh zlib-devel-1.2.7-17.el7.x86_64.rpm
warning: zlib-devel-1.2.7-17.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:zlib-devel-1.2.7-17.el7 ################################# [100%]
[root@localhost Packages]# rpm -ivh xz-devel-5.2.2-1.el7.x86_64.rpm
warning: xz-devel-5.2.2-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:xz-devel-5.2.2-1.el7 ################################# [100%]
[root@localhost Packages]# rpm -ivh libxml2-devel-2.9.1-6.el7_2.3.x86_64.rpm
warning: libxml2-devel-2.9.1-6.el7_2.3.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:libxml2-devel-2.9.1-6.el7_2.3 ################################# [100%]
安装libmcrypt:
[root@localhost ~]# tar zxf libmcrypt-2.5.8.tar.gz -C /usr/src/ 解压源码包
[root@localhost ~]# cd /usr/src/libmcrypt-2.5.8/
[root@localhost libmcrypt-2.5.8]# ./configure 配置
[root@localhost libmcrypt-2.5.8]# make && make install 编译安装
[root@localhost libmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt.* /usr/src/ 建立软连接
安装mhash:
[root@localhost ~]# tar zxf mhash-0.9.9.9.tar.gz -C /usr/src/ 解压源码包
[root@localhost ~]# cd /usr/src/mhash-0.9.9.9/
[root@localhost mhash-0.9.9.9]# ./configure 配置
[root@localhost mhash-0.9.9.9]# make && make install 编译安装
[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.* /usr/lib 建立软连接
安装mcrypt:
[root@localhost ~]# tar zxf mcrypt-2.6.8.tar.gz -C /usr/src/ 解压源码包
[root@localhost ~]# cd /usr/src/mcrypt-2.6.8/
添加环境变量,以解决configure报错:
[root@localhost mcrypt-2.6.8]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
[root@localhost mcrypt-2.6.8]# ./configure 配置
[root@localhost mcrypt-2.6.8]# make && make install 编译安装
安装PHP:
[root@localhost ~]# tar zxf php-5.3.28.tar.gz -C /usr/src/ 解压源码包
[root@localhost ~]# cd /usr/src/php-5.3.28/
[root@localhost php-5.3.28]# ./configure --prefix=/usr/local/php5 --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql/ --with-config-file-path=/usr/local/php5 --enable-mbstring 配置
以上参数详细解释
--prefix: 指定将PHP程序安装到哪个目录下,如/usr/local/php5.
--with-mcrypt: 加载数据加密等扩展工具支持
--with-apxs2: 设置apache http server提供的apxs模块支持程序的文件位置
--with-mysql: 设置MySQL数据库服务程序的安装位置。
--with-config-file-path: 设置php的配置文件php.ini将要存放的位置。
--enable-mbstring: 启用多字节字符串功能,以便支持中文等代码。
[root@localhost php-5.3.28]# make && make install 编译安装
[root@localhost php-5.3.28]# cp php.ini-development /usr/local/php5/php.ini 复制配置文件
[root@localhost php-5.3.28]# vim /usr/local/php5/php.ini 配置
226 short_open_tag = On 允许识别PHP短语法标记
784 default_charset = "utf-8"; 设置默认字符集为utf-8,配置文件内的784行
882 file_uploads = On 允许通过PHP网页上传文件
891 upload_max_filesize = 2M 允许上传的文件大小限制
740 post_max_size = 8M 每次通过表单post提交的数据量限制
添加ZendGuardLoader优化模块:
[root@localhost ~]# tar zxf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/
[root@localhost php-5.3.x]# cp ZendGuardLoader.so /usr/local/php5/lib/php/ 复制文件
[root@localhost php-5.3.x]# vim /usr/local/php5/php.ini 配置PHP
227 zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
228 zend_loader.enable=1
[root@localhost php-5.3.x]# vim /usr/local/httpd/conf/httpd.conf 配置httpd
53 LoadModule php5_module modules/libphp5.so
54 AddType application/x-httpd-php .php
167
168 DirectoryIndex index.html index.php
169
[root@localhost php-5.3.x]# vim /usr/local/httpd/htdocs/index.php 编写php测试网页
phpinfo();
?>
[root@localhost php-5.3.x]# systemctl restart httpd 重启httpd
[root@localhost php-5.3.x]# systemctl restart mysqld 重启MySQL
[root@localhost php-5.3.x]# netstat -anpt | grep httpd 查看httpd启动情况
tcp6 0 0 :::80 :::* LISTEN 91936/httpd
[root@localhost php-5.3.x]# netstat -anpt | grep mysqld 查看MySQL启动情况
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 101096/mysqld
[root@localhost php-5.3.x]# firefox 192.168.0.10/index.php 访问测试网页