环境
yum -y install openssl-devel ncurses-devel libtermcap-devel libxml2-devel
apache 安装
tar zxf /httpd-2.2.26.tar.gz -C /usr/src/
cd /usr/src/httpd-2.2.26/
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-cgi --enable-charset-lite --enable-ssl --enable-suexec --with-suexec-caller=daemon --with-suexec-docroot=/usr/local/httpd/htdocs
echo $?
make && make install
echo $?
\cp -f /usr/local/httpd/bin/apachectl
sed -i ‘1 a #chkconfig: 35 85 15‘ /etc/init.d/httpd
sed -i ‘2 a #description: Apache is a World Wide Web Server‘ /etc/init.d/httpd
chmod +x /etc/init.d/httpd
chkconfig --add httpd
mysql 安装
tar zxf /mysql-5.15 -C /usr/src/
cd /usr/src/mysql-5.15/
useradd -M -u 49 -s /sbin/nologin mysql
./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charset=gbk,gb2312
make && make install
echo $?
#建立my.cnf配置文件
cp -f /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
vim /etc/my.cnf
sed -i ‘s/^skip-locking/#skip-locking/‘ /etc/my.cnf
sed -i ‘/#skip-locking/a skip-external-locking‘ /etc/my.cnf
#mysql执行优化、添加库路径
ln -sf /usr/local/mysql/bin/* /usr/local/bin/
echo "/usr/local/mysql/lib/mysql" > /etc/ld.so.conf.d/mysql-64.conf
ldconfig
#建立 mysqld 服务控制脚本
cp -f /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
cd /usr/local/mysql/bin
mysql_install_db --user=mysql
#调整mysql目录权限
chown -R root:mysql /usr/local/mysql/
chown -R mysql /usr/local/mysql/var/
mysqladmin -uroot -p password 1234567
PHP 安装
tar zxf /php-5.4.24.tar.gz -C /usr/src/
cd /usr/src/php-5.4.24/
./configure --prefix=/usr/local/php --enable-mbstring --enable-sockets --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php
make && make install
echo $?
确认HTTP 对 PHP
awk ‘/^LoadModule/ { print }‘ /usr/local/httpd/conf/httpd.conf
sed -i ‘/DirectoryIndex/s/$/ index.php/‘ /usr/local/httpd/conf/httpd.conf
sed -i ‘/AddHandler allows/i \\tAddType application/x-httpd-php .php‘ /usr/local/httpd/conf/httpd.conf
启动LAMP平台、测试
service mysqld restart
service httpd restart
vim /usr/local/httpd/htdocs/test2.php
<?php
$link=mysql_connect(‘localhost‘,‘root‘,‘1234567‘);
if($link) echo "Success !!";
else echo "Failure !!";
mysql_close();
?>