zzl001 发表于 2018-11-19 11:46:09

Apache运维架构之Apache+PHP

  

  当前互联网主流web服务器说明

  1、IIS微软的web服务器
  2、apache   中小web服务器主流,web服务器中的老大哥
  3、nginx   新兴的web服务器主流
  4、tomcat中小企业动态服务器,互联网java容器主流
  5、resin    大型企业动态服务器,互联网java容器主流
  

  apache的特点及应用场合
  特点:功能强大,配置简单,速度快,应用广泛,性能稳定可靠,并可做代理服务器和负载均衡
  

  应用场合:
  1、使用apache来运行静态html网页,图片,处理静态小文件能力不及nginx
  2、使用apache结合php引擎来运行php程序,lamp由此成为经典组合
  3、使用apache结合tomcat及resin运行jsp java等程序,成为中小企业的首选
  4、使用apache做代理及负载均衡
  

  本次环境所用到的软件版本如下(操作系统centos6.7)

1、基础环境准备
# tar xf apr-1.4.5.tar.gz
# cd apr-1.4.5
# ./configure --prefix=/usr/local/apr
# make && make install
# tar xf apr-util-1.3.12.tar.gz
# cd apr-util-1.3.12
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
# make && make install
# unzip pcre-8.10.zip
# cd pcre-8.10
# ./configure --prefix=/usr/local/pcre
# make && make install
# tar xf libxml2-2.7.6.tar.gz
# cd libxml2-2.7.6
# vim configure    将下面那行注释掉                     
#    $RM "$cfgfile"
# ./configure --prefix=/usr/local/libxml2 --without-zlib
# make && make install  

# tar xf libmcrypt-2.5.8.tar.gz
# cd libmcrypt-2.5.8
# ./configure --prefix=/usr/local/libmcrypt
# make && make install
# tar xf zlib-1.2.5.tar.gz
# cd zlib-1.2.5
# ./configure
# make && make install
# tar xf libpng-1.4.1.tar.gz
# cd libpng-1.4.1
# ./configure --prefix=/usr/local/libpng
# make && make install
# mkdir /usr/local/jpeg6
# mkdir /usr/local/jpeg6/bin
# mkdir /usr/local/jpeg6/lib
# mkdir /usr/local/jpeg6/include
# mkdir -p /usr/local/jpeg6/man/man1
# tar xf jpegsrc.v6b.tar.gz
# cd jpeg-6b/
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make && make报错
./libtool --mode=compile gcc -O2-I. -c ./jcapimin.c
make: ./libtool: Command not found
make: *** Error 127
解决方法
# tar xf libtool-2.2.6a.tar.gz
# cd libtool-2.2.6
# ./configure
# make && make install
# cd ../jpeg-6b/
# cp /usr/share/libtool/config/config.sub .
# cp /usr/share/libtool/config/config.guess .
#./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make && make
# tar xf freetype-2.3.12.tar.gz
# cd freetype-2.3.12
# ./configure --prefix=/usr/local/freetype
# make && make install
# tar xf autoconf-2.61.tar.gz
# cd autoconf-2.61
# ./configure
# make && make install
# tar xf libgd-2.1.1.tar.
libgd-2.1.1.tar.gzlibgd-2.1.1.tar.xz
# tar xf libgd-2.1.1.tar.gz
# cd libgd-2.1.1
#./configure \
> --prefix=/usr/local/gd2/ \
> --enable-m4_pattern_allow \
> --with-zlib=/usr/local/zlib/ \
> --with-jpeg=/usr/local/jpeg6/ \
> --with-png=/usr/local/libpng/ \
> --with-freetype=/usr/local/freetype/
#make && make install2、安装编译apache
# useradd -s /sbin/nologin -M www
# tar xf httpd-2.4.18.tar.bz2
# cd httpd-2.4.18
# ./configure --prefix=/usr/local/apache2--enable-mods-shared=all --enable-so --enable-proxy-ajp --enable-rewrite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
# make && make install3、安装编译mysql
# useradd -s /sbin/nologin -M mysql
# yum install cmake -y
# tar xf mysql-5.6.17.tar.gz
# cd mysql-5.6.17
# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
# make && make install
# chown -R mysql.mysql /usr/local/mysql/
# pwd
/tools/mysql-5.6.17/scripts
# chmod +x mysql_install_db
# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

Installing MySQL system tables...2016-08-19 13:13:18 0 TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-08-19 13:13:18 64062 InnoDB: Using atomics to ref count buffer pool pages
2016-08-19 13:13:18 64062 InnoDB: The InnoDB memory heap is disabled
2016-08-19 13:13:18 64062 InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-08-19 13:13:18 64062 InnoDB: Compressed tables use zlib 1.2.3
2016-08-19 13:13:18 64062 InnoDB: Not using CPU crc32 instructions
2016-08-19 13:13:18 64062 InnoDB: Initializing buffer pool, size = 128.0M
2016-08-19 13:13:18 64062 InnoDB: Completed initialization of buffer pool
2016-08-19 13:13:18 64062 InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-08-19 13:13:18 64062 InnoDB: Setting file ./ibdata1 size to 12 MB
2016-08-19 13:13:18 64062 InnoDB: Database physically writes the file full: wait...
2016-08-19 13:13:19 64062 InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-08-19 13:13:21 64062 InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-08-19 13:13:23 64062 InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-08-19 13:13:23 64062 InnoDB: New log files created, LSN=45781
2016-08-19 13:13:23 64062 InnoDB: Doublewrite buffer not found: creating new
2016-08-19 13:13:23 64062 InnoDB: Doublewrite buffer created
2016-08-19 13:13:23 64062 InnoDB: 128 rollback segment(s) are active.
2016-08-19 13:13:23 64062 InnoDB: Creating foreign key constraint system tables.
2016-08-19 13:13:23 64062 InnoDB: Foreign key constraint system tables created
2016-08-19 13:13:23 64062 InnoDB: Creating tablespace and datafile system tables.
2016-08-19 13:13:23 64062 InnoDB: Tablespace and datafile system tables created.
2016-08-19 13:13:23 64062 InnoDB: Waiting for purge to start
2016-08-19 13:13:23 64062 InnoDB: 5.6.17 started; log sequence number 0
2016-08-19 13:13:24 64062 Binlog end
2016-08-19 13:13:24 64062 InnoDB: FTS optimize thread exiting.
2016-08-19 13:13:24 64062 InnoDB: Starting shutdown...
2016-08-19 13:13:24 64062 InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2016-08-19 13:13:24 0 TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-08-19 13:13:24 64085 InnoDB: Using atomics to ref count buffer pool pages
2016-08-19 13:13:24 64085 InnoDB: The InnoDB memory heap is disabled
2016-08-19 13:13:24 64085 InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-08-19 13:13:24 64085 InnoDB: Compressed tables use zlib 1.2.3
2016-08-19 13:13:24 64085 InnoDB: Not using CPU crc32 instructions
2016-08-19 13:13:24 64085 InnoDB: Initializing buffer pool, size = 128.0M
2016-08-19 13:13:24 64085 InnoDB: Completed initialization of buffer pool
2016-08-19 13:13:24 64085 InnoDB: Highest supported file format is Barracuda.
2016-08-19 13:13:24 64085 InnoDB: 128 rollback segment(s) are active.
2016-08-19 13:13:25 64085 InnoDB: Waiting for purge to start
2016-08-19 13:13:25 64085 InnoDB: 5.6.17 started; log sequence number 1625977
2016-08-19 13:13:25 64085 Binlog end
2016-08-19 13:13:25 64085 InnoDB: FTS optimize thread exiting.
2016-08-19 13:13:25 64085 InnoDB: Starting shutdown...
2016-08-19 13:13:26 64085 InnoDB: Shutdown completed; log sequence number 1625987
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h ansible password 'new-password'
Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/local/mysql/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

注:在启动MySQL服务时,会按照一定次序搜索my.cnf,先在/etc目录下找,找不到则会搜索"$basedir/my.cnf",
在本例中就是 /usr/local/mysql/my.cnf,这是新版MySQL的配置文件的默认位置!
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# chmod +x /etc/init.d/mysqld
# /etc/init.d/mysqld start
Starting MySQL....... SUCCESS!4、编译安装php
# yum install libXpm-devel -y
# tar xf php-5.6.18.tar.gz
# cd php-5.6.18
# ./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-png-dir=/usr/local/libpng/ \
--with-jpeg-dir=/usr/local/jpeg6/ \
--with-freetype-dir=/usr/local/freetype/ \
--with-gd=/usr/local/gd2/ \
--with-zlib-dir=/usr/local/zlib/ \
--with-mcrypt=/usr/local/libmcrypt/ \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-xpm-dir=/usr/lib64/ \
--enable-soap\
--enable-mbstring=all \
--enable-sockets
# make && make install5、apache配置
# vim /usr/local/apache2/conf/httpd.conf   
ServerName localhost
DirectoryIndex index.php index.html
AddType
application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
Include conf/extra/httpd-vhosts.conf
LoadModule php5_module      modules/libphp5.so
User www
Group www# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
# Virtual Hosts

    ServerAdmin   1335120568@qq.com
    DocumentRoot "/usr/local/apache2/htdocs/www"
    ServerNamewww.martin1.com
    ServerAlias martin1.com
    ErrorLog "logs/www-error_log"
    CustomLog "logs/www-access_log" common


    ServerAdmin   1335120568@qq.com
    DocumentRoot "/usr/local/apache2/htdocs/blog"
    ServerName blog.martin1.com
    ErrorLog "logs/blog-error_log"
    CustomLog "logs/blog-access_log" common

# mkdir -p /usr/local/apache2/htdocs/{www,blog}
# vim /usr/local/apache2/htdocs/www/index.php
  # /usr/local/apache2/bin/apachectl restart
  # lsof -i :80
  COMMANDPID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
  httpd   8307 root    4uIPv6 295815      0t0TCP *:http (LISTEN)
  httpd   8309www    4uIPv6 295815      0t0TCP *:http (LISTEN)
  httpd   8310www    4uIPv6 295815      0t0TCP *:http (LISTEN)
  httpd   8312www    4uIPv6 295815      0t0TCP *:http (LISTEN)
  

  6、访问测试(如果出现php页面,则说明整合成功)


  再简单截图之前编译安装的过程

  


  


  

  最后说下如果要在lamp环境下安装编译zabbix 按照如下操作即可
  ./configure--prefix=/usr/local/zabbix-server --enable-server
--with-mysql--with-net-snmp --with-libcurl --with-libxml2
cp
-a/home/oldboy/tools/zabbix-3.0.3/frontends/php/*
/usr/local/apache2/htdocs/www/



页: [1]
查看完整版本: Apache运维架构之Apache+PHP