CentOS LAMP搭建

來源:互聯網
上載者:User

一、安裝MySQL
# useradd mysql -s /sbin/nologin
#tar zxvf mysql-5.0.90.tar.gz
#cd mysql-5.0.90
#./configure --prefix=/usr/local/mysql localstatedir=/usr/local/mysql/date --enable-local-infile --with-charset-gbk --with-extra-charsets=all --with-low-memory --with-mysqld-user=mysql --enable-thread-safe-client

# make && make install      //編譯+安裝
# cp support-files/my-large.cnf /etc/my.cnf
# /usr/local/mysql/bin/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql    //初始化MySQL
# chown -R root /usr/local/mysql
# chown -R mysql /usr/local/mysql/date
# chgrp -R mysql /usr/local/mysql
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
#/usr/local/mysql/bin/mysqladmin -uroot password 123456 //設定MySQL的管理員密碼
cp support-files/mysql.server /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 345 mysqld on

安裝mysql-devel:
#rpm -ivh MySQL-devel-5.0.90-1.i386.rpm

安裝 zlib libpng jpeg freetype fontconfig gd
yum install zlib libpng jpegsrc jpegsrc-devel freetype freetype-devel fontconfig fontconfig-devel gd-devel

二、安裝Apache
#tar jxvf httpd-2.2.13.tar.bz2
#cd httpd-2.2.13
#./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-ssl --with-ssl=/usr/bin/openssl --with-zlib --enable-mods-shared=all --enable-track-vars --with-mysql=/usr/local/mysql
#make && make install
#/usr/local/apache/bin/apachectl start   //啟動Apache
#echo "/usr/local/apache/bin/apachectl start" >>/etc/rc.local     //加入開機啟動

三、安裝PHP
#tar jxvf php-5.2.13.tar.bz2
#cd php-5.2.13
# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --enable-fastcgi --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd --with-libxml-dir --with-png-dir --with-jpeg-dir --enable-sockets --with-pdo-mysql=/usr/local/mysql

#make && make install
# ln -s /usr/local/php/bin/* /usr/local/bin/
# cp php.ini-dist /usr/local/php/php.ini

建立php測試頁面:
vi /usr/local/apache/htdocs/index.php

<?php
phpinfo();
?>

整合apache和php
#vi /usr/local/apache/conf/httpd.conf

①    確認PHP模組是否添加進來,只要我們在前面安裝Apache時允許Apache動態載入模組次模組就會自動添加進來,設定檔中沒有此項請手工添加,約在53行
LoadModule php5_module        modules/libphp5.so
②    添加對 PHP檔案的支援,在310行下面添加如下內容(AddType application/x-gzip .gz .tgz下面)
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

③    修改預設首頁167行
DirectoryIndex index.php index.html

/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl start

訪問phpinfo測試頁面進行測試!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.