LAMP安裝細則
利用xshell從Windows向Linux傳輸文件
[[email protected] ~]#yum install lrzsz
[[email protected] ~]#rz
MySq二進制包安裝
mysql包——搜狐
http://222.21.218.207/mirrors.sohu.com/mysql/MySQL-5.0/mysql-5.0.95-linux-x86_64-glibc23.tar.gz
http://mirrors.sohu.com/mysql/MySQL-5.0/ ;
2. cd /usr/local/src
tar zxvf mysql-5.0.95-linux-x86_64-glibc23.tar.gz //解壓二進制包
mv mysql-5.0.95-linux-x86_64-glibc23 /usr/local/mysql/ //移動到mysql
cd mysql/
3.useradd -s /sbin/nologin mysql //添加mysql用戶
mkdir datadir
chmod -R mysql:mysql /data/mysql/ //將剛才創建的mysql添加的mysql組中
4.cp support-files/mysql/mysql_install_ db/my-large.cnf /etc/my.cnf //拷貝配置文件
vim /etc/my.cnf //將bin-log 註釋掉 //修改配置文件
cp support-files/myslql.server /etc/init.d/mysqld //拷貝 啟動文件
vim /etc/init.d/mysqld //修改 datadir=/data/mysql basedir=/usrlocal/mysql
5 ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql //初始化數據庫
6. /etc/init.d/mysqld //啟動mysql服務
7. ps aux|grep mysql //查看mysql進程是否存在
Apache安裝
安裝的三部曲:
1.配置安裝參數 以及編譯參數
2.make 編譯
3.make isntall 安裝
apache安裝包下載地址
http://archive.apache.org/dist/httpd/
[[email protected] src]#cd /usr/local/src
[[email protected] src]#rz //傳輸apache的安裝包
[[email protected] src]#tar zxvf httpd-2.2.0.tar.gz //解壓包 ; 註 tar.ga2包需要將參數 zxvf 換為 jxvf ; 去掉參數V不顯示解壓過程
[[email protected] src]#cd httpd-2.2.0
[[email protected] src]# ./configure --prefix=/usr/local/apache2 --with-included-apr --with-pcre --enable-nodes-shared==most
//配置編譯參數 apache2為安裝的位置, 紅字部分很重要(可移植的.....),不加的話影響make install過程;
[[email protected] src]# yum install gcc //編譯所需的$PATH(變量環境), 這是個 C語言在Linux下的 編譯器;
[[email protected] src]# make //編譯
[[email protected] src]# make isntall //安裝
PHP安裝
下載PHP包 http://www.php.net/downloads.php
cd /usr/local/src
rz
tar zxf php-5.5.30.tar.gz
cd php-5.5.30/
./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
//配置編譯參數;
//config-file->配置文件
//libxml,jpeg,.......->為各種模塊
configure: error: xml2-config not found. Please check your libxml2 installation. //錯誤1:缺少libxml2模塊
yum list|grep -i ‘xml2‘ //查找本地yum
yum install libxmllibxml2-devel.x86_64
yum install libxml2-devel.x86_64
configure: error: Cannot find OpenSSL‘s <evp.h> //同錯誤1解決方式
yum list |grep openssl-devel
yum install openssl-devel.x86_64
checking for BZip2 in default path... not foundconfigure: error: Please reinstall the BZip2 distribution
yum list | grep bzip2
yum install bzip2-devel.x86_64
error:jpeg
yum list | grep jpeg
yum install libjpeg-turbo-devel.x86_64
configure: error: png.h not found.
yum list |grep png
yum install libpng-devel.x86_64
configure: error: freetype.h not found.
yum list |grep freetype
yum install freetype-devel.x86_64
configure: error: mcrypt.h not found. Please reinstall libmcrypt. //最經典的一個錯誤
yum list|grep mcrypt //結果是本地yum中沒找到,必須依靠epel擴展源
rpm -ivh ‘http://www.lishiming.net/data/attachment/forum/epel-release-6-8_64.noarch.rpm‘ //安裝epel 擴展源
yum list|grep mcrypt //能在epel擴展源中找到
yum isntall libmcrypt-devel.x86_64
make //編譯
echo $? //查看上條命令的執行結果(是否編譯成功)
make install //安裝
/usr/local/php/bin/php -i|less //查看PHP配置文件
// Configuration File (php.ini) Path => /usr/local/php/etc
// Loaded Configuration File => (none) (加載配置文件路徑不存在)
cp php.ini-production /usr/local/php/etc/php.ini //復制配置文件到解決上個路徑不存在
apache結合php
vim /usr/local/apache2/conf/httpd.conf //apache的配置文件
找到:
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
測試LAMP是否成功
/usr/local/apache2/bin/apachectl -t //啟動apache之前先檢驗配置文件是否正確->Syntax OK
/usr/local/apache2/bin/apachectl start //啟動apache,如果打開之後測試出問題,去修改上邊的httpd.conf文件
//一定要重啟apache——>/usr/local/apache2/bin/apachectl restart
netstat -lnp |grep httpd //查看是否啟動
curl localhost //測試
<html><body><h1>It works!</h1></body></html>
vim /usr/local/apache2/htdocs/1.php //測試是否解析PHP
<?php echo "php解析正常";?>
curl localhost/1.phpphp解析正常[[email protected] ~]# //解析正常,如果解析失敗,要去仔細檢查
//vim /usr/local/apache2/conf/httpd.conf
初次使用瀏覽器訪問我們的web服務的時候,你可能無法訪問,這是因為防火墻的緣故
iftables -F //關閉防火墻
在瀏覽器中輸入 127.0.0.1
頁面顯示 welcome nana //測試成功
LAMP安裝細則