LAMP

(һ)��װapache

1����װapache������

 yum install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel openssl-devel libxml2-devel

2�����ز���װapache2.2.31

wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.2.31.tar.gz
tar xf httpd-2.2.31.tar.gz 
cd httpd-2.2.31
./configure \
--prefix=/application/apache2.2.31 \
--enable-deflate \
--enable-expires \
--enable-headers \
--enable-modules=most \
--enable-so \
--with-mpm=worker \
--enable-rewrite
make
make install
ln -s /application/apache2.2.31/ /application/apache
ls -l /application/
������ 4
lrwxrwxrwx  1 root root   26 6��  27 22:37 apache -> /application/apache2.2.31/
drwxr-xr-x 15 root root 4096 6��  27 22:35 apache2.2.31

3����дapache�����ű�

#!/bin/bash
# chkconfig: 2345 85 15
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
        . /etc/sysconfig/httpd
fi
INITLOG_ARGS=""
apachectl=/application/apache/bin/apachectl     ���޸ģ�
httpd=/application/apache/bin/httpd             ���޸ģ�
pid=$httpd/logs/httpd.pid
prog=httpd
RETVAL=0
start() {
        echo -n $"Starting $prog: "
        daemon $httpd $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
        return $RETVAL
}
stop() {
        echo -n $"Stopping $prog: "
        killproc $httpd
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd $pid
}
reload() {
        echo -n $"Reloading $prog: "
        killproc $httpd -HUP
        RETVAL=$?
        echo
}
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status $httpd
        RETVAL=$?
        ;;
  restart)
        stop
        start
        ;;
  condrestart)
        if [ -f $pid ] ; then
                stop
                start
        fi
        ;;
  reload)
        reload
        ;;
  graceful|help|configtest|fullstatus)
        $apachectl $@
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $prog {start|stop|restart|condrestart|reload|status"
        echo $"|fullstatus|graceful|help|configtest}"
        exit 1
esac
exit $RETVAL

4������apache��������

chkconfig  --add httpd
chkconfig  --list  httpd
chmod +x  /etc/init.d/httpd
/etc/init.d/httpd restart

5�����û����������������

cd /application/apache/conf/
vim httpd.conf �޸�98��
ServerName 127.0.0.1:80
�޸�132 
<Directory "/application/apache2.2.31/html">
�޸�378 
Include conf/extra/httpd-mpm.conf
�޸�396 
Include conf/extra/httpd-vhosts.conf

==============================

[root@web02 conf]# cd extra/
[root@web02 extra]# vim httpd-vhosts.conf 
<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/application/apache2.2.31/html/www"
    ServerName www.etiantian.org
    ServerAlias etiantian.org
    ErrorLog "/app/logs/www-error_log"
    CustomLog "/app/logs/www-access_log" common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/application/apache2.2.31/html/bbs"
    ServerName bbs.etiantian.org
    ErrorLog "/app/logs/bbs-error_log"
    CustomLog "/app/logs/bbs-access_log" common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/application/apache2.2.31/html/blog"
    ServerName blog.etiantian.org
    ErrorLog "/app/logs/blog-error_log"
    CustomLog "/app/logs/blog-access_log" common
</VirtualHost>

6������վ��Ŀ¼�������ļ�

mkdir -p /application/apache2.2.31/html/{www,bbs,blog}
echo www.etiantian.org >/application/apache2.2.31/html/www/index.html
echo bbs.etiantian.org >/application/apache2.2.31/html/bbs/index.html
echo blog.etiantian.org >/application/apache2.2.31/html/blog/index.html
mkdir /app/logs -p
/etc/init.d/httpd graceful    (��������)

7�����ÿͻ���host���������������̣����

curl www.etiantian.org                  
curl bbs.etiantian.org
curl blog.etiantian.org

apache��������������������óɹ���


(��) ��װmysql(�����ö����ư�)

1����װmysql������

yum -y install libaio*

2������mysql�����ư�װ��

wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.49-linux2.6-x86_64.tar.gz

3������mysql�û�

useradd mysql -s /sbin/nologin -M

4����ѹ����װmysql

tar xf mysql-5.5.49-linux2.6-x86_64.tar.gz   
mv mysql-5.5.49-linux2.6-x86_64   /application/mysql-5.5.49
ln -s /application/mysql-5.5.49/ /application/mysql 
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql  ����ʼ��mysql��
chown -R mysql.mysql /application/mysql/
cp /application/mysql/support-files/my-small.cnf  /etc/my.cnf
cp /application/mysql-5.5.49/support-files/mysql.server  /etc/init.d/mysqld
chkconfig --add mysqld  
sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe  /etc/init.d/mysqld   ���޸�mysql�����ű���
/etc/init.d/mysqld start

5�����û�������

echo "PATH="/application/mysql/bin:$PATH"" >> /etc/profile
source /etc/profile

6������mysql����

mysqladmin -uroot password '123456' 
mysqladmin -uroot -p'������' password '������'   ���޸ģ�

7������mysql

/etc/init.d/mysqld start



(��) ��װPHP

1����װphp������

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum install zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel libmcrypt-devel mhash mhash-devel mcrypt openssl-devel -y
 
mkdir -p /home/oldboy/tools
cd /home/oldboy/tools
 
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make
make install
cd ..

2����װphp

wget http://mirrors.sohu.com/php/php-5.5.26.tar.gz
cd /home/oldboy/tools
tar xf php-5.5.26.tar.gz
cd php-5.5.26
./configure \
--prefix=/application/php5.5.26 \
--with-apxs2=/application/apache/bin/apxs \
--with-mysql=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-safe-mode \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-curlwrappers \
--enable-mbregex \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-zend-multibyte \
--enable-static \
--with-xsl \
--enable-ftp
make
make install
ln -s /application/php5.5.26/ /application/php

3�������

[root@web02 php-5.5.26]# ll /application/apache/modules/
������ 30568
-rw-r--r-- 1 root root     9194 11�� 10 20:37 httpd.exp
-rwxr-xr-x 1 root root 31285631 11�� 10 23:51 libphp5.so
[root@web02 php-5.5.26]# grep libphp5.so /application/apache/conf/httpd.conf
LoadModule php5_module        modules/libphp5.so
[root@web02 php-5.5.26]# cp php.ini-production /application/php/lib/php.ini

4������apache���php������httpd.conf��

311�������ӣ�
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
168�������ӣ�
DirectoryIndex index.php index.html
67��������
User www
Group www

5�������û�

useradd www -s /sbin/nologin
id www 
/application/apache/bin/apachectl -t
Syntax OK
/application/apache/bin/apachectl graceful

6�����php

<?php
phpinfo();
?>

7�����mysql

<?php
  $link_id=mysql_connect('localhost','root','123456') or mysql_error();
    if($link_id){
           echo "mysql successful by oldboy training!";
     }
     else{
           echo mysql_error();
     }
?>


LAMP����




���ģ��wordpress

1������wordpress

wget  https://cn.wordpress.org/wordpress-4.5.3-zh_CN.tar.gz
tar xf wordpress-4.5.3-zh_CN.tar.gz
mv wordpress/* /application/apache/html/blog/
chown -R www.www /application/apache/html/blog/

2������wordpress��ݿ�

mysql> create database wordpress; 
mysql> grant all on wordpress.* to wordpress@'172.16.1.%' identified by 'wordpress123'
mysql> flush privileges;

3���޸�hosts��¼ 

vi /etc/hosts                   ���޸�hosts��¼��mysqlָ��
172.16.1.31 MysqlServer.com

4�����ʲ����ò��� http://blog.etiantian.org/index.php 

LAMP_第1张图片


5������wordpressα��̬

(1)��WordPress��̨-����-�̶�����-�Զ���ṹ����������Ĵ��룬����ļ��ɡ�        

/archives/%post_id%.html

(2)��������������Ȩ�޿��ƣ�ֻ��Ҫ����blogվ�㱻���ʾͿ�����,����Ҫдrewrite��

[root@Oldboy extra]# tail -15 httpd-vhosts.conf 
<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/application/apache2.2.31/html/blog"
    ServerName blog.etiantian.org
    ErrorLog "/app/logs/blog-error_log"
    CustomLog "/app/logs/blog-access_log" common
    
    # ������������
    <Directory "/application/apache2.2.31/html/blog">
       Options Includes ExecCGI FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all
    </Directory>
</VirtualHost>

(3)�鿴Ч��

LAMP_第2张图片






���ij��� ��21����ԥ�� ���ͣ�л��ת�أ�

你可能感兴趣的:(LAMP)