标签存档: lamp

lamp | linux+apache+mysql+php配置

linux+apache+mysql+php配置:
1.apache

$ cd /home
$ mkdir super
$ wget http://labs.renren.com/apache-mirror/httpd/httpd-2.2.17.tar.gz
$ tar -zxvf httpd-2.2.17.tar.gz
$ cd httpd-2.2.17
$ ./configure --prefix=/usr/local/apache2 --enable-vhost-alias --enable-deflate --enable-rewrite --with-mpm=worker --enable-ssl
# --prefix=/usr/local/apache 设置安装位置
# --enable-so 让apache核心装载DSO
# --enable-rewrite 启用重写功能
$ make && make install //编译并且安装
$ /usr/local/apache2/bin/apachectl start //启动apache服务
$ vim /usr/local/apache2/conf/httpd.conf
# prefork和worker模式的配置

ServerLimit         2048
StartServers         100
MinSpareServers      50
MaxSpareServers      150
MaxClients          1000  # 设定的是 Apache可以同时处理的请求
MaxRequestsPerChild 10000

ServerLimit 30
ThreadLimit 64
StartServers 20
MaxClients 1024
MinSpareThreads 75
MaxSpareThreads 250
ThreadsPerChild 64
MaxRequestsPerChild 10000

$ /usr/local/apache2/bin/apachectl restart //重启apache服务

注:在编译安装apache之前需要安装apr、apr-util、zlib

配置文件httpd.conf在php模块下面加一句:AddType application/x-httpd-php .php //执行php文件格式

遇到问题:

$ vim /etc/resolv.conf
> nameserver 8.8.8.8

2.mysql

$ cd /home/super
$ wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.35.tar.gz
$ tar -zxvf mysql-mysql-5.5.35.tar.gz
$ cd mysql-5.5.35.tar.gz
$ groupadd mysql
$ useradd -g mysql mysql
$ 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=/tmp/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 mysql.mysql /usr/local/mysql/ -R
#把你编译目录的一个脚本COPY过去
$ cp support-files/mysql.server /etc/init.d/mysqld
#增加一项新的服务
$ chkconfig --add mysqld
#启动mysql
$ /etc/rc.d/init.d/mysqld start

成功启动!!!

3.php

$ cd /home/super
$ wget  http://cn.php.net/get/php-5.2.9.tar.gz/from/cn2.php.net/mirror
$ tar -zxvf php-5.2.9.tar.gz
$ cd php-5.2.9
$ ./configure --prefix=/usr/local/php/ --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli --with-zlib-dir --with-zlib --enable-ftp --enable-mbstring --enable-sockets --enable-soap --enable-fpm --with-curl --with-libxml-dir=/usr/local/libxml2 --with-openssl --with-mcrypt
#如果是64位系统:增加 --libdir=/usr/lib64
#配置php、生成可编译文件
$ make && make install
$ cd /home/super/php-5.2.9
$ cp php.ini-development /usr/local/php/lib/php.ini
$ cd /usr/local/php/lib
$ vim php.ini
> register_globals = On
$ vi /usr/local/apache/conf/httpd.conf
#查找
#在此范围添加
> AddType application/x-httpd-php .php
> AddType application/x-httpd-php-source .phps
$ /usr/local/apache2/bin/apachectl restart #重启apache服务
$ cd /usr/local/apache2/htdocs
$ vim phpinfo.php
> <?php
> phpinfo();
> ?>;
#访问phpinfo.php尝试正常哈哈!
$ cd /usr/local/apache2/lib
$ vim http.conf
#更改php执行目录,将#DocumentRoot "/usr/local/apache2/htdocs"改为
> DocumentRoot "/var/www/html/"
#增加扩展虚拟主机配置
> Include conf/extra/httpd-vhosts*.conf
$ cd extra
$ vim http-vhosts-pma.conf
#添加扩展pma配置文件
DocumentRoot   "/var/www/html/phpMyAdmin"
ServerName pma.zhouchao.com
ServerAlias pma.chaoji.com
ServerAdmin zhouchao@qeeka.com
DirectoryIndex index.php index.html index.htm index.shtml
#       LogLevel debug
HostNameLookups off

Options Includes FollowSymLinks
AllowOverride all
Allow from all
#                        AuthName "Auth Name :"
#                        AuthType Basic
#                        AuthUserFile /etc/phphtaccess.pwd
#                        require valid-user
Order allow,deny

CustomLog "logs/access_pma.log" combined

遇到问题:
php编译报错:/usr/local/ssl/lib/libcrypto.a: could not read symbols: Bad value
解决方案:
重新编译openssl:./config no-shared -fPIC

4.mcrypt //加密算法扩展库

$ wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
$ tar -zxvf libmcrypt-2.5.8.tar.gz
$ cd libmcrypt-2.5.8
$ ./configure
$ make && make install

遇到问题:
进去phpMyAdmin时,缺少:mcrypt
然后再重新编译PHP,加上编译参数:–with-mcrypt
测试下是否编译成功:
$ /usr/local/php/bin/php -m | grep mcrypt
mcrypt
别忘了重新启动apache!!!!

5.phpmyadmin

$ cd /home/super
$ wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.9.2/phpMyAdmin-3.3.9.2-all-languages.tar.gz?r=http%3A%2F%2Fwww.phpmyadmin.net%2Fhome_page%2Fdownloads.php&ts=1298912166&use_mirror=ncu
$ tar -zxvf phpMyAdmin-3.3.9.2-all-languages.tar.gz
$ mkdir -p /var/www/html
$ mv phpMyAdmin-3.3.9.2-all-languages /var/www/html/phpMyAdmin
$ cd !$
$ cp -a config.sample.inc.php config.inc.php
#找到 /libraries/config.default.php文件(config.default.php复制到phpmyadmin目录下,然后更名为 config.inc.php)

遇到问题:
(1)配置好apache虚拟主机后若出现Wrong permissions on configuration file, should not be world writable! 则需要修改权限 chmod 755 config.* ;chmod 755 libraries/config.default.php
(2)若出现:配置文件现在需要绝密的短语密码(blowfish_secret) 要改配置文件里的:$cfg['blowfish_secret'] = ‘ ‘; 单引号里面随便写个数
(3)pma无法登陆,要在mysql中root用户授权(默认密码为空)#GRANT ALL PRIVILEGES ON *.* TO root@’localhost’ IDENTIFIED BY ’123456′;

第 1 页,共 1 页1