mofdan 发表于 2018-11-23 08:20:37

CentOS+Apache+Mysql+PHP+phpMyadmin源码安装

系统版本
CentOS-6.4-x86_64-minimal
系统调整
  

vi /etc/sysconfig/network-scripts/ifcfg-eth0
ONBOOT=yes
service network restart
vi /etc/selinux/config
SELINUX=disabled
vi /etc/init/start-ttys.conf
env ACTIVE_CONSOLES=/dev/tty
vi /etc/sysconfig/init
ACTIVE_CONSOLES=/dev/tty
vi /etc/sysctl.conf
#net.bridge.bridge-nf-call-ip6tables = 0
#net.bridge.bridge-nf-call-iptables = 0
service iptables stop&&chkconfig iptables off
service ip6tables stop&&chkconfig ip6tables off
service postfix stop&&chkconfig postfix off
yum update
yum install -y vim-common vim-enhanced man gcc-c++ fontconfig cmake openssl-devel

软件获取



mysql-5.6.14         http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.14.tar.gz
apache-2.2.26      http://mirrors.sohu.com/apache/httpd-2.2.26.tar.gz
php-5.5.9            http://mirrors.sohu.com/php/php-5.5.9.tar.gz
libxml2-2.9.0      ftp://xmlsoft.org/libxml2/libxml2-2.9.0.tar.gz
curl-7.36.0          http://curl.haxx.se/download/curl-7.36.0.tar.gz
jpegsrc.v9a          http://www.ijg.org/files/jpegsrc.v9a.tar.gz
libpng-1.5.18      ftp://ftp.simplesystems.org/pub/png/src/libpng15/libpng-1.5.18.tar.gz
freetype-2.5.3       http://ftp.twaren.net/Unix/NonGNU/freetype/freetype-2.5.3.tar.gz
libmcrypt-2.5.7      ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
autoconf-2.69      http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
phpMyAdmin-4.1.8-all-languages    http://jaist.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.1.8/phpMyAdmin-4.1.8-all-languages.tar.gz
  
软件安装
安装mysql

# yum install -y ncurses-devel
# tar zxvf /var/ftp/pub/mysql-5.6.14.tar.gz -C /usr/src/
# cmake .
# make && make install
# groupadd -r mysql
# useradd -r mysql -g mysql -s /sbin/nologin
# chown -R mysql:mysql /usr/local/mysql/
# ls -ld /usr/local/mysql/
drwxr-xr-x 13 mysql mysql 4096 12月5 12:38 /usr/local/mysql/
# cd /usr/local/mysql/scripts/
# ./mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/ --basedir=/usr/local/mysql/
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
# chkconfig --add mysql
# chkconfig mysql on
# chkconfig mysql --list
mysql          0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭
# cp /usr/local/mysql/support-files/my-default.cnf /usr/local/mysql/my.cnf
cp:是否覆盖"/usr/local/mysql/my.cnf"? y
# vim /usr/local/mysql/my.cnf
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3678(默认端口3306)
sock = /tmp/mysql.sock
# service mysql start
# mysql -uroot
mysql> update mysql.user set password=password('neowave') where User="root";
Query OK, 4 rows affected (0.13 sec)
Rows matched: 4Changed: 4Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)安装apache


# tar zxvf /var/ftp/pub/httpd-2.2.26.tar.gz -C /usr/src/
# cd /usr/src/httpd-2.2.26/
# yum install zlib-devel
# ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd \
--enable-so --enable-rewrite --enable-charset-lite --enable-cgi \
--enable-mods-shared=all --enable-cache --enable-disk-cache --enable-mem-cache \
--enable-static-support
# make && make install
# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
# vim /etc/init.d/httpd
#chkconfig:35 10 90
#description:Activates/Deactivates Apache Web Server
# chkconfig httpd --add
# chkconfig httpd on
# chkconfig httpd --list
httpd          0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭
# service httpd start
# yum install -y lynx   #(centos-indexhtml)安装PHP

在安装PHP之前,应先安装PHP5需要的最新版本库文件,例如libxml2、libmcrypt以及GD2库等文件。
安装GD2库是为了让PHP5支持GIF、PNG和JPEG图片格式,所以在安装GD2库之前还要先安装最新的zlib、libpng、freetype和jpegsrc等库文件,而且中间还会穿插安装一些软件


批处理解包脚本代码:tar.sh
  
#!/bin/bash
sdir="/root"                  #tar包所在路径
ddir="/usr/local/src"         #解压目标路径
cd $sdir
#######将find的结果传递给while循环#################
find . -maxdepth 1 -type f -name "*.tar.*" -print |sed 's/\.\///g' | while read line
do
tar zxvf $line -C $ddir >> /dev/null#解压tar包
echo $line >> tar.txt               #解压过的tar包记录到tar.txt
done
exit 0将libxml2、curl、jpeg、libpng、freetype、libmcrypt的tar包复制到root目录,运行tar.sh批量解包,然后切换到/usr/local/src,逐个编译安装


####安装libxml2####
# cd libxml2-2.9.0/
# ./configure --prefix=/usr/local/libxml2&& make&&make install
####安装curl####
# cd ../curl-7.36.0/
# ./configure --prefix=/usr/local/curl&&make&&make install
####安装jpeg####
# cd ../jpeg-9a/
# ./configure --prefix=/usr/local/jpeg&&make&&make install
####安装libpng####
# cd ../libpng-1.5.18/
# ./configure --prefix=/usr/local/libpng&& make && make install
####安装freetype####
# cd ../freetype-2.5.3/
# ./configure --prefix=/usr/local/freetype&&make&&make install
####安装libmcrypt####
# cd ../libmcrypt-2.5.7/
# ./configure --prefix=/usr/local/libmcrypt&&make&&make install
####安装PHP####
# ./configure --prefix=/usr/local/php --with-config-file-path=/etc \
--with-apxs2=/usr/local/httpd/bin/apxs \
--with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config
--with-mysql-sock=/tmp/mysql.sock \
--with-iconv --with-openssl --with-gd --with-gettext --with-xmlrpc --with-curl=/usr/local/curl \
--with-zlib --with-mcrypt=/usr/local/libmcrypt/ --with-libxml-dir=/usr/local/libxml2/ \
--with-jpeg-dir=/usr/local/jpeg/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/ \
--without-pear --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex \
--enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --enable-zip \
--enable-soap --enable-session --enable-zend-signals --enable-fpm
# make&&make install
# cp php.ini-production /etc/php.ini编辑apache主配置文件(httpd.conf)添加php支持

# vim /etc/httpd/httpd.conf
Addtype application/x-httpd-php .php .phtml
重启httpd
# /usr/local/httpd/bin/apachectl restart
  
安装phpMyadmin
# tar zxvf phpMyAdmin-4.1.12-all-languages.tar.gz -C /usr/local/src
# mv /usr/local/src/phpMyAdmin-4.1.12-all-languages/usr/local/httpd/htdocs/phpMyAdmin
# cd /usr/local/httpd/htdocs/phpMyAdmin/
# cp config.sample.inc.php config.inc.php
# vim config.inc.php
$cfg['Servers'][$i]['auth_type'] = 'http';将auth_type 由'cookie'改为'http'
  
测试PHP
# vim /usr/local/httpd/htdocs/phpinfo.php

访问http://192.168.120.109/phpinfo.php
访问http://192.168.120.109/phpmyadmin/index.php
输入mysql.user中的用户和密码(要有localhost登陆权限)
  




页: [1]
查看完整版本: CentOS+Apache+Mysql+PHP+phpMyadmin源码安装