#yum install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel gd gd-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel openssl openssl-devel libtool libtool-devel libtool-ltdl-devel
安装iconv
#tar -zxf libiconv-1.14.tar.gz
#cd libiconv-1.14
#./configure --prefix=/usr/local/
#make && make install
安装mhash
#tar -jxf mhash-0.9.9.9.tar.bz2
#cd mhash-0.9.9.9
#./configure
# make && make instal
#ln -s /usr/local/lib/libmhash.* /usr/lib64/
安装mcrypt
#tar -zxf libmcrypt-2.5.7.tar.gz
#cd libmcrypt-2.5.7
#./configure
# make && make install
#./configure --enable-ltdl-install
#make && make install
#tar -zxf mcrypt-2.6.8.tar.gz
#cd mcrypt-2.6.8
#./configure
#export LD_LIBRARY_PATH=/usr/local/lib: LD_LIBRARY_PATH
#./configure
#make && make install
#tar -zxf apr-1.5.1.tar.gz
# ./configure --prefix=/usr/local/
# make && make install
# tar -zxf apr-util-1.5.4.tar.gz
# ./configure --prefix=/usr/local/ --with-apr=/usr/local/
# make && make install
# tar -zxf pcre-8.12.tar.gz
# ./configure --prefix=/usr/local/
#make && make install
安装iconv
#tar -zxf libiconv-1.14.tar.gz
#cd libiconv-1.14
#./configure --prefix=/usr/local/
#make && make install
安装mhash
#tar -jxf mhash-0.9.9.9.tar.bz2
#cd mhash-0.9.9.9
#./configure
# make && make instal
#ln -s /usr/local/lib/libmhash.* /usr/lib64/
安装mcrypt
#tar -zxf libmcrypt-2.5.7.tar.gz
#cd libmcrypt-2.5.7
#./configure
# make && make install
#./configure --enable-ltdl-install
#make && make install
#tar -zxf mcrypt-2.6.8.tar.gz
#cd mcrypt-2.6.8
#./configure
#export LD_LIBRARY_PATH=/usr/local/lib: LD_LIBRARY_PATH
#./configure
#make && make install
#tar -zxf apr-1.5.1.tar.gz
# ./configure --prefix=/usr/local/
# make && make install
# tar -zxf apr-util-1.5.4.tar.gz
# ./configure --prefix=/usr/local/ --with-apr=/usr/local/
# make && make install
# tar -zxf pcre-8.12.tar.gz
# ./configure --prefix=/usr/local/
#make && make install
安装mysql
#yum install bison
#tar -zxf cmake-2.8.4.tar.gz
#./configure
#gmake
#make install
#tar -zxf mysql-5.5.14.tar.gz
#cmake ./
#make
#make install
# cp /usr/local/src/mysql-5.5.14/support-files/my-medium.cnf/etc/my.cnf
# cp /usr/local/src/mysql-5.5.14/support-files/mysql.server/etc/init.d/mysqld
# chmod 770 /etc/init.d/mysqld
#chmod +w /usr/local/mysql
#chown -R mysql:mysql /usr/local/mysql
#mkdir -p /data/mysql/data/
#chown -R mysql:mysql /data/mysql/
#vim /etc/my.cnf
加入以下内容
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql/data
log-error = /data/mysql/mysql_error.log
pid-file = /data/mysql/mysql.pid
# /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql/data--basedir=/usr/local/mysql
#ln -s /usr/local/mysql/bin/mysql /bin/
#/etc/init.d/mysqld start
#/usr/local/mysql/bin/mysqladmin -u root passwordwhy890705.
安装httpd
# useradd www -s /sbin/nologin
#tar -jxvf httpd-2.2.24.tar.bz2
#./configure --prefix=/usr/local/apache --with-pcre --with-apr=/usr/local/ --with-apr-util=/usr/local/ --with-zlib --enable-so --enable-modules=most --enable-rewrite--enable-mpms-shared=all --with-mpm=event--enable-nonportable-atomics --enable-ssl --enable-cgi --enable-deflate --enable-mpms-shared=all --with-mpm=event --enable-disk-cache --enable-mem-cache --enable-proxy --enable-proxy-connect --enable-proxy-http --enable-proxy-ftp
#make && make install
#ln -s /usr/local/apache/bin/apachectl /etc/init.d/httpd
# /etc/init.d/httpd start
安装PHP
# tar -zxvf php-5.3.6.tar.gz
#./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-libxml-dir --with-iconv=/usr/local/ --with-zlib --with-bz2 --with-mcrypt --with-mhash --with-openssl --with-curl --with-curlwrappers --with-pear --enable-mbstring --enable-gd-native-ttf --enable-zip --enable-ftp --enable-sockets --enable-calendar --enable-bcmath --enable-exif --enable-shmop--enable-sockets
# make && make install
# cp php.ini-development /usr/local/php/etc/php.ini
查看是否生成PHP模块
# ls /usr/local/apache/modules/ |grep php
libphp5.so
#vim /usr/local/apache/conf/httpd.conf
找到AddType模块处添加
AddTypeapplication/x-httpd-php-source .phps
AddTypeapplication/x-httpd-php .php .phtml
在index.html前添加index.php
更改用户
www
更改主目录路径
/data/www/htdocs
更改日志路径
/data/www/logs/access_log
/data/www/logs/error_log
# chown www:www /data/www/ -R
# /etc/init.d/httpd -k restart
测试
http://IP/index.php
虚拟主机&别名&反向代理
别名
Alias /cacti/ "/data/www/cacti/"
<Directory "/data/www/cacti/">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
Alias /nagios/cgi-bin/images/ "/usr/local/nagios/share/images/"
<Directory "/usr/local/nagios/share/images/">
AllowOverride None
Options None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/.passwd.conf
Require valid-user
</Directory>
ScriptAlias /nagios/cgi-bin/ "/usr/local/nagios/sbin/"
<Directory "/usr/local/nagios/sbin/">
AllowOverride None
Options None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/.passwd.conf
Require valid-user
</Directory>
Alias /nagios/ "/usr/local/nagios/share/"
<Directory "/usr/local/nagios/share/">
AllowOverride None
Options None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/.passwd.conf
Require valid-user
</Directory>
AddDefaultCharset utf-8
Alias /cacti/ "/data/www/cacti/"
<Directory "/data/www/cacti/">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
虚拟主机2.2版本
NameVirtualHost *:80
<VirtualHost cacti.ylwkj.com:80>
DocumentRoot /data/www/cacti/
ServerName cacti.ylwkj.com
</VirtualHost>
<VirtualHost nagios.ylwkj.com:80>
DocumentRoot /usr/local/nagios/
ServerName nagios.ylwkj.com
</VirtualHost>
虚拟主机2.4版本虚拟主机
默认80
<VirtualHost cacti.ylwkj.com>
ServerName cacti.ylwkj.com
DocumentRoot /data/www/cacti/
<Directory "/data/www/cacti/">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
指定8088
<VirtualHost nagios.ylwkj.com:8088>
ServerName nagios.ylwkj.com
DocumentRoot /usr/local/nagios/
<Directory "/usr/local/nagios/">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
反向代理
<VirtualHost *:80>
ServerAdmin root@localhost
ServerName www.otomall.cc
ProxyPass / http://www.shop100.cc/
ProxyPassReverse / http://www.shop100.cc/
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
CustomLog /www/var/log/proxy.otomall.cc_access.log combined
</VirtualHost>
https协议
<VirtualHost *:443>
DocumentRoot "/home/www/new.zoomedia.com.cn"
ServerName zoomedia.com.cn
SSLEngine on
SSLCertificateChainFile "/usr/local/apache/conf/cert/4746882_zoomedia.com.cn_chain.crt"
SSLCertificateFile "/usr/local/apache/conf/cert/4746882_zoomedia.com.cn_public.crt"
SSLCertificateKeyFile "/usr/local/apache/conf/cert/4746882_zoomedia.com.cn.key"
<Directory "/home/www/new.zoomedia.com.cn">
# Options Indexes FollowSymLinks
AllowOverride All
<RequireAll>
Require all granted
</RequireAll>
</Directory>
ErrorLog "/home/www/logs/https.zoomedia.com.cn-error_log"
CustomLog "/home/www/logs/https.zoomedia.com.cn-access_log" common
</VirtualHost>