linux下源碼安裝mysql+apache+php+phpMyAdmin小記

來源:互聯網
上載者:User

 //////////////////源碼編譯安裝mysql:
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
shell> cd mysql-VERSION
shell> ./configure --prefix=/usr/local/mysql
shell> make
shell> make install
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql var
shell> bin/mysqld_safe --user=mysql &

安裝成功會看到類似
[1] 3879
[root--1014--/usr/local/mysql]Starting mysqld daemon with databases from /usr/local/mysql/var
這樣的提示資訊
也可以通過ps -A | grep mysql查看mysql是否已經後台運行判斷是否成功,當然在/usr/local/mysql/bin
目錄下鍵入mysql後進入
mysql>     也表示mysql成功安裝。

為了在shell下進行資料庫操作直接輸入命令就可以,不用進入/usr/local/mysql/bin/目錄,建議建立如下連結:
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin
ln -s /usr/local/mysql/bin/mysql /usr/bin

另外,通過編譯源碼安裝的mysql每次電腦重啟後需要自己重新手動啟動mysql,為此有必要將mysql加入服務和
啟動項,如下:
mv share/mysql/mysql.server /etc/init.d/mysql
chmod 775 /etc/init.d/mysql
chkconfig --add mysql
(小注備忘:775表示rwx rwx r-x,因為r--4,w--2,x--1)

///////////////////源碼安裝apache
shell>./configure --prefix=/usr/local/apache    
shell>make    
shell>make install 
//
ln -s /usr/local/apache/bin/apachectl /usr/bin/
啟動:
shell>apachectl start
測試:鍵入127.0.0.1能看到It Works表明apache安裝成功

//////////////////源碼安裝php
shell>./configure   --prefix=/usr/local/php   --with-apxs2=/usr/local/apache/bin/apxs   --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config
shell>make
shell>make install
shell>cp php.ini-dist /usr/local/lib/php.ini

php和apache的整合
開啟/usr/local/apache/conf/httpd.conf    
對apache做如下配置    
#佈建網站跟目錄      
  DocumentRoot   "/home/httpd/html/"    #自己設定 
(注意:修改預設設定後,其下方的
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>
中的“Deny from all”改為“Allow from all”,否則訪問測試頁面會出現forbidden錯誤
並且修改
<Directory "/xxx">中的“/xxx"修改為之前設定的DocumentRoot)

 
   
#設定是否允許索引目錄      
  Options   FollowSymLinks   MultiViews  
     
#設定php檔案尾碼     
  AddType   application/x-httpd-php   .php   .phtml   .php3   .inc    
  AddType   application/x-httpd-php-source   .phps    
   
#設定apache的預設檔案名稱次序        
  DirectoryIndex   index.php   index.shtml   index.html   index.htm    

 

shell>apachectl restart

///////測試
寫個簡單的php檔案
http://127.0.0.1/xx.php

 

///////////////////////////////////////////////phpMyAdmin安裝

源碼解壓後直接放到DocumentRoot下

配置可能需要用到的命令

cd phpMyAdmin
mkdir config                        # create directory for saving
chmod o+rw config                   # give it world writable permissions

cp config.inc.php config/           # copy current configuration for editing
chmod o+w config/config.inc.php     # give it world writable permissions

 

進入http://xxx/phpMyAdmin/scripts/setup.php可以可視化的進行配置

 

 

置過程中搞了很長時間還是每次進入http://xxx/phpMyAdmin時提示

#1045 - Access denied for user 'root'@'localhost' (using password: NO)

錯誤,可以地址http://xxx/phpMyAdmin/index.php進入則正常,沒搞明白怎麼回事

 

 

聯繫我們

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