搭建LAMP環境

來源:互聯網
上載者:User

標籤:軟體版本

軟體版本:

apache 2.2.31版本下載:http://mirrors.sohu.com/apache/httpd-2.2.31.tar.gz

mysql 5.1.72版本下載:http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.72-linux-x86_64-glibc23.tar.gz

php  5.3.28版本下載:http://mirrors.sohu.com/php/php-5.3.28.tar.gz

安裝LAMP之前必備安裝包

yum install wget gcc gcc-c++ make re2c curl curl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel libmcrypt libmcrypt-devel zlib zlib-devel openssl openssl-devel freetype freetype-devel gd gd-devel perl perl-devel ncurses ncurses-devel bison bison-devel libtool gettext gettext-devel cmake bzip2 bzip2-devel pcre pcre-devel

編譯安裝mysql

解壓並移動;

# tar zxvf mysql-5.1.40-linux-i686-icc-glibc23.tar.gz# mv mysql-5.1.40-linux-x86_64-icc-glibc23 /usr/local/mysql

建立資料庫使用者、目錄、更改屬主;

# useradd -s /sbin/nologin mysql # mkdir -p /data/mysql # chown -R mysql:mysql /data/mysql

初始化資料庫;

# cd /usr/local/mysql # ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

拷貝設定檔,修改my.cnf;

# cp support-files/my-large.cnf /etc/my.cnf # vim /etc/init.d/mysqld[mysqld]user=mysql datadir=/data/mysql

編輯mysqld啟動指令碼,找到basedir和datadir添加路徑;

# vi /etc/init.d/mysqldbasedir=/usr/local/mysqldatadir=/data/mysql


拷貝開機檔案、添加開機啟動;

# cp support-files/mysql.server /etc/init.d/mysqld# chmod 755 /etc/init.d/mysqld # chkconfig --add mysqld # chkconfig mysqld on

啟動mysql;

service mysqld  start

編譯安裝apache

·/usr/local/apache2/bin/apachectl -M:查看安裝了哪些模組     ·/usr/local/apache2/bin/apachectl -t:檢查語法錯誤   ·/usr/local/apache2/bin/apachectl -l:查看安裝的庫檔案·/usr/local/apache2/bin/apachectl graceful:重新載入配置·/usr/local/apache2/htcocs            首頁存放目錄·/usr/local/apache2/bin/apachectl     開機檔案目錄·/usr/local/apache2/conf              設定檔路徑

Centos6 yum安裝的apr版本已經不適用httpd-2.4版本了。所以,需要源碼編譯安裝apr以及apr-util

# cd /usr/local/src/# wget http://mirrors.cnnic.cn/apache/apr/apr-1.5.2.tar.gz# wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.5.4.tar.gz

編譯apr

[[email protected] src]# tar zxf apr-1.5.2.tar.gz [[email protected] src]# cd apr-1.5.2[[email protected] apr-1.5.2]# ./configure --prefix=/usr/local/apr[[email protected] apr-1.5.2]# make && make install

編譯apr-util

[[email protected] src]# tar zxf apr-util-1.5.4.tar.gz [[email protected] src]# cd apr-util-1.5.4[[email protected] apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr[[email protected] apr-util-1.5.4]# make && make install

編譯安裝apache

[[email protected] src]# tar zxf httpd-2.4.12.tar.gz [[email protected] src]# cd httpd-2.4.12[[email protected] httpd-2.4.12]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre --enable-mods-shared=most --enable-so

編譯安裝php 

[[email protected] src]# tar zxvf php-5.3.28.tar.gz [[email protected] src]# cd php-5.3.28[[email protected] php-5.6.8]# ./configure   --prefix=/usr/local/php   --with-apxs2=/usr/local/apache2/bin/apxs   --with-config-file-path=/usr/local/php/etc   --with-mysql=/usr/local/mysql   --with-libxml-dir   --with-gd   --with-jpeg-dir   --with-png-dir   --with-freetype-dir   --with-iconv-dir   --with-zlib-dir   --with-bz2   --with-openssl   --with-mcrypt   --enable-soap   --enable-gd-native-ttf   --enable-mbstring   --enable-sockets   --enable-exif   --disable-ipv6 [[email protected] php-5.6.8]# make && make install

拷貝php設定檔

[[email protected] php-5.3.28]# cp /usr/local/src/php-5.3.28/php.ini-production /usr/local/php/etc/php.ini

配置apache解析php

找到:AddType application/x-gzip .gz .tgz在該行下面添加:AddType application/x-httpd-php .php找到:     <IfModule dir_module>          DirectoryIndex index.html      </IfModule>將該行改為:     <IfModule dir_module>          DirectoryIndex index.html index.htm index.php     </IfModule>找到:#ServerName www.example.com:80修改為:ServerName localhost:80

測試apache解析php

[[email protected] ]# cat /usr/local/apache2/htdocs/test.php<?phpecho "PHP解析正常\n";?>[[email protected] htdocs]# /usr/local/apache2/bin/apachectl start[[email protected] htdocs]# curl localhost/test.php出現:PHP解析正常


搭建LAMP環境

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.