rpm -q httpd php gcc gcc-c++ glibc glibc-common gd gd-devel ncurses-devel make bison
#未存在则安装 yum install gcc gcc-c++ glibc glibc-common gd gd-devel ncurses-devel make bison #未安装apache/php/mysql则手动安装 【cmake】 tar zxvf cmake-2.8.8.tar.gz cd cmake-2.8.8 ./configure gmake;gmake install 【mysql】 /usr/sbin/groupadd mysql /usr/sbin/useradd -g mysql mysql mkdir -p /data/mysql chown -R mysql:mysql /data/mysql tar zxvf mysql-5.5.24.tar.gz cd mysql-5.5.24 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc/my.cnf make make installcd /usr/local/mysql
cp ./support-files/my-huge.cnf /etc/my.cnfvim /etc/my.cnf
在 [mysqld] 段增加 datadir = /data/mysql wait-timeout = 30 max_connections = 512 max_connect_errors = 10000000 在 [mysqld] 段修改 max_allowed_packet = 16M ./scripts/mysql_install_db --user=mysql cp ./support-files/mysql.server /etc/rc.d/init.d/mysqldvim /etc/rc.d/init.d/mysqld
把basedir=编辑成basedir=/usr/local/mysql 把datadir=编辑成datadir=/data/mysqlchmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld chkconfig --level 3 mysqld on service mysqld start ./bin/mysqladmin -u root password '123456' /usr/local/mysql/bin/mysql -uroot -p show databases; 【apache】 tar zxvf apr-1.4.6.tar.gz cd apr-1.4.6 ./configure make;make install tar zxvf apr-util-1.4.1.tar.gz cd apr-util-1.4.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make;make install tar zxvf pcre-8.30.tar.gz cd pcre-8.30 ./configure make;make installtar zxvf httpd-2.4.2.tar.gz
cd httpd-2.4.2 ./configure --prefix=/usr/local/apache2.4 --enable-rewrite --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre make;make installgroupadd apache
useradd -g apache -M -s /sbin/nologin apache vim /usr/local/apache2.4/conf/httpd.conf 修改User daemon为User apache 修改Group daemon为Group apacheservice iptables stop
chkconfig iptables off /usr/local/apache2/bin/apachectl start echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.local 【php】 yum install libjpeg* libpng* libxml2* tar zxvf php-5.4.3.tar.gz cd php-5.4.3 ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-mysql=/usr/local/mysql --disable-debug --enable-mbstring=all --enable-mbregex --enable-short-tags --with-gd --with-zlib --with-jpeg-dir --with-png-dir --disable-posix --enable-sockets --with-config-file-path=/usr/local/lib --with-mysqli=/usr/local/mysql/bin/mysql_config make;make installcp php.ini-production /usr/local/lib/php.ini
vim /usr/local/lib/php.ini 修改short_open_tag = Off为short_open_tag = Onvim /usr/local/apache2.4/conf/httpd.conf
在内容里搜一下是否有libphp5.so 我的情况 已经有了 如果没有追加下面那句前面不带#的 # LoadModule foo_module modules/mod_foo.so LoadModule php5_module modules/libphp5.so 再搜索AddType关键字 在那附近追加如下一句 AddType application/x-httpd-php .php .phtml 再搜索下面一段 把第二句DirectoryIndex的后面追加index.php <IfModule dir_module> DirectoryIndex index.html index.php </IfModule> #测试php vim /usr/local/apache2.4/htdocs/index.php <? phpinfo(); ?>vim /etc/selinux/config
注释掉#SELINUX=enforcing 并追加SELINUX=disabled 修改完需重启服务器 或者不重启: setenforce 0 chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache2.4/modules/libphp5.so /usr/local/apache2.4/bin/apachectl stop /usr/local/apache2.4/bin/apachectl start setenforce 1/usr/local/apache2.4/bin/apachectl stop
/usr/local/apache2.4/bin/apachectl start#测试php与mysql
vim /usr/local/apache2.4/htdocs/phpmysql.php <? mysql_connect("localhost","root","123456") or die("MySQL First Test:Failed"); echo "MySQL First Test:Success"; ?> 【phpMyAdmin】 tar zxvf phpMyAdmin-3.5.1-all-languages.tar.gz test -d /var/www || mkdir -p /var/www mv phpMyAdmin-3.5.1-all-languages /var/www/phpMyAdmin cp /var/www/phpMyAdmin/config.sample.inc.php /var/www/phpMyAdmin/config.inc.php vim /var/www/phpMyAdmin/config.inc.php 追加$cfg['Lang'] = 'zh-utf-8'; chown -R root.apache /var/www/phpMyAdmin vim /usr/local/apache2.4/conf/extra/phpmyadmin.conf Alias /phpmyadmin /var/www/phpMyAdmina <Location /phpMyAdmin> Order deny,allow Deny from all Allow from all </Location>vim /usr/local/apache2.4/conf/httpd.conf
追加:Include conf/extra/phpmyadmin.conf /usr/local/apache2.4/bin/apachectl stop /usr/local/apache2.4/bin/apachectl start