CentOS apache2.2.x mysql5.1.x php5.3.x

环境如下:

CentOS 5.10 x86
httpd-2.2.26.tar.bz2
mysql-5.1.72.tar.gz
php-5.3.27.tar.bz2


如果不知道怎么下,就直接复制名字去搜索.


源码包放置于(安装完要删掉的,放哪都可以):

/usr/local/src

安装目录:

apache:
/usr/local/apache
mysql:
/usr/local/mysql
php:
/usr/local/php


系统要最小化安装,5.x系统最小化也小不到哪。

关闭SELINUX:

sed -i '/SELINUX=enforcing/s/SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux


安装依赖包,以免出现各种各样的错误。

yum groupinstall "Development Libraries" "Development Tools" "Legacy Software Development" "X Software Development" -y


#MySQL

groupadd mysql
useradd -g mysql mysql -M -s /sbin/nologin
tar zxvf mysql-5.1.72.tar.gz
cd mysql-5.1.72
./configure --prefix=/usr/local/mysql --without-debug --with-charset=utf8 --with-extra-charsets=all --enable-assembler --with-pthread --enable-thread-safe-client --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-big-tables --with-readline --with-embedded-server --enable-local-infile --with-plugins=innobase && make && make install
cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql/
bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql var
chgrp -R mysql .
bin/mysqld_safe --user=mysql &
cd /usr/local/src/mysql-5.1.72
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld
/etc/init.d/mysqld start



#Apache

groupadd www
useradd -g www www -M -s /sbin/nologin
./configure --prefix=/usr/local/apache --enable-so --enable-rewrite
make && make install
cd /usr/local/apache/bin/
./apachectl start


#PHP 真的很麻烦,卧槽+++++

tar jxvf php-5.3.27.tar.bz2
cd php-5.3.27
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config -enable-mbstring=all --with-libxml-dir --with-zlib --with-gd  -with-jpeg-dir --with-png-dir --with-zlib-dir --with-mhash
make && make install
cp php.ini-production /usr/local/lib/php.ini


Apache、PHP整合

编辑 httpd.conf


67,68行,运行用户改为www
User www
Group www
106,133行改为网站根目录
DocumentRoot "/home/wwwroot"
<Directory "/home/wwwroot">
日志设置:
188     ErrorLog "logs/error_log"             #错误日志
217     CustomLog "logs/access_log" common  #访问日志
可将logs/access_log更改为你想设置的目录,如
Errorlog "/var/log/apache/error_log"
以下是php设置
168行,Apache默认索引页面,将index.php
DirectoryIndex index.php index.html
309-311
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php



#MySQL设置

设置mysql密码,将123456替换成你要的密码
/usr/local/mysql/bin/mysqladmin -u root password '123456'
登录
/usr/local/mysql/bin/mysql -uroot -p123456
查看状态
STATUS;
--------------
/usr/local/mysql/bin/mysql  Ver 14.14 Distrib 5.1.72, for pc-linux-gnu (i686) using readline 5.1
Connection id:      7
Current database:  
Current user:       root@localhost
SSL:            Not in use
Current pager:      stdout
Using outfile:      ''
Using delimiter:    ;
Server version:     5.1.72-log Source distribution
Protocol version:   10
Connection:     Localhost via UNIX socket
Server characterset:    utf8
Db     characterset:    utf8
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:        /tmp/mysql.sock
Uptime:         16 hours 54 sec
Threads: 1  Questions: 60  Slow queries: 0  Opens: 22  Flush tables: 1  Open tables: 16  Queries per second avg: 0.1
--------------
显示所有数据库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
3 rows in set (0.01 sec)
删除测试数据库
DROP DATABASE TEST;
创建一个给网站用的数据库,数据库名为phpwind,用户为xx,密码为aaaaaa.拥有所有权限
CREATE DATABASE phpwind;            #创建数据库
GRANT ALL PRIVILEGES ON phpwind.* TO xx@localhost IDENTIFIED BY 'aaaaaa';  #创建用户,赋权限
FLUSH PRIVILEGES ;   #刷新


#PHP,通常就是禁用一些函数而已

vim /usr/local/lib/php.ini
找到
disable_functions =phpinfo,exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source


本文出自 “bsder” 博客,谢绝转载!

你可能感兴趣的:(apache2,centos5,php5.3,MYSQL5.1)