Centos 6.4用源代码安装LAMP环境
Apache是世界使用排名第一的Web服务器软件,其安全性和稳定性颇受业界认可,功能十分强大,是基于模块化的服务,可以动态加载模块,处理动态和静态页面都很好的效果.1.下载和安装apache软件
# wget http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.10.tar.gz
# wget http://mirror.bit.edu.cn/apache//apr/apr-1.5.1.tar.gz
# wget http://mirror.bit.edu.cn/apache//apr/apr-util-1.5.4.tar.gz
# groupadd -g 503 apache
# useradd -u 503 -r -s /sbin/nologin -g 503 apache
# yum install pcre* -y
# tar xvf apr-1.5.1.tar.gz
# cd apr-1.5.1
# ./configure --prefix=/usr/local/apr-1.5.1
# make && make install
# cd ..
# tar xvf apr-util-1.5.4.tar.gz
# ./configure --prefix=/usr/local/apr-uttil --with-apr=/usr/local/apr-1.5.1/
# make && make install
# cd ..
# tar xvf httpd-2.4.10.tar.gz
# cd httpd-2.4.10
# ./configure--prefix=/usr/local/apache-2.4.10 --enable-cache --enable-cache-disk --enable-so --enable-http --enable-proxy --enable-info --enable-rewrite --with-apr=/usr/local/apr-1.5.1/--with-apr-util=/usr/local/apr-uttil/ --with-pcre
# make && make install
# cd /usr/local/apache-2.4.10/
# vim conf/httpd.conf
ServerName 127.0.0.1
# /usr/local/apache-2.4.10/bin/apachectl -k restart
httpd not running, trying to start
# netstat -antup | grep 80
tcp 0 0 :::80 :::* LISTEN 821/httpd
# vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
# /etc/init.d/iptables restart
iptables: Flushing firewall rules:
iptables: Setting chains to policy ACCEPT: filter
iptables: Unloading modules:
iptables: Applying firewall rules:
#
2.测试访问页面
3.安装mysql数据库
# yum install cmake ncurses-devel -y
# groupadd -g 502 mysql
# useradd-r -u 502 -s /sbin/nologin -g 502mysql
# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.22.tar.gz
# tar xvf mysql-5.6.22.tar.gz
# cd mysql-5.6.22
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.22
-DMYSQL_DATADIR=/usr/local/mysql-5.6.22/data
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DMYSQL_USER=mysql
# make && make install
# echo $?
0
# cd /usr/local/mysql-5.6.22/
# cp -a support-files/mysql.server/etc/init.d/mysqld
# chkconfig--add mysqld
# chkconfigmysqld on
# vim /etc/my.cnf
datadir=/usr/local/mysql-5.6.22/data
basedir=/usr/local/mysql-5.6.22
socket=/tmp/mysql.sock
# ./scripts/mysql_install_db--basedir=/usr/local/mysql-5.6.22/
--datadir=/usr/local/mysql-5.6.22/data/ --defaults-file=/etc/my.cnf--user=mysql
# /etc/init.d/mysqld restart
ERROR! MySQL server PID file could not be found!
Starting MySQL...... SUCCESS!
# vim ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql-5.6.22/bin
# . ~/.bash_profile
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.22 Source distribution
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.22 |
+-----------+
1 row in set (0.00 sec)
mysql>
4.安装php软件
# wget http://mirrors.sohu.com/php/php-5.5.20.tar.gz
# wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
# tar xvf libmcrypt-2.5.7.tar.gz
# ./configure --prefix=/usr/local/libmcrypt
# make && make install
# cd ..
# yum install libjpeg* libpng* freetype* libcurl-devellibvpx-devel libxml2-devel libXpm-devel openldap-devel
# tar xvf php-5.5.20.tar.gz
# cd php-5.5.20
# ./configure--prefix=/usr/local/php-5.4.28 --with-apxs2=/usr/local/apache-2.4.10/bin/apxs --with-libxml-dir --with-zlib --with-curl --with-gd--with-vpx-dir--with-jpeg-dir--with-png-dir--with-zlib-dir--with-xpm-dir--with-iconv --with-ldap --with-mcrypt=/usr/local/libmcrypt/--with-mysql=/usr/local/mysql-5.6.22/ --with-mysqli=/usr/local/mysql-5.6.22/bin/mysql_config --with-pdo-mysql--with-freetype-dir
# make && make install
# echo $?
0
# cp -a php.ini-development/usr/local/php-5.4.28/lib/php.ini
# vim /usr/local/php-5.4.28/lib/php.ini
date.timezone = Asia/ShangHai
#
5.apache和php结合
# cd /usr/local/apache-2.4.10/
# vim conf/httpd.conf
ServerName 127.0.0.1
User apache
Group apache
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phps
DirectoryIndex index.php index.html
# vim htdocs/index.php
<?php
phpinfo();
?>
# /usr/local/apache-2.4.10/bin/apachectl -k restart
# netstat -antup | grep 80
tcp 0 0 :::80 :::* LISTEN 821/httpd
#
6.测试是否正常
7.安装php加速器(zend guard loader)
页:
[1]