1. 程式人生 > >mysql lamp 配置命令總結

mysql lamp 配置命令總結

mysql lamp

三 Mysql
1.卸載MySQL的RPM包
rpm -e mysql --nodeps
2.安裝cmake包
tar zxf cmake-2.8.6.tar.gz
cd cmake-2.8.6
./configure
gmake && gmake install
3.創建數據庫程序賬戶和組
groupadd mysql
useradd -M -s /sbin/nologin mysql -g mysql
4.編譯安裝MySQL
(1)解壓:tar zxf mysql-5.5.22.tar.gz -C /usr/src/
(2)配置:cd /usr/src/mysql-5.5.22/
cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql (註:MySQL安裝目錄)
-DSYSCONFDIR=/etc (註:MySQL配置文件路徑)
-DDEFAULT_CHARSET=utf8 (註:字符集)
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS=all
(3)編譯: make
(4)安裝: make install
5.安裝後調整
[root@www ~]# chown -R mysql:mysql /usr/local/mysql (註:更改MySQL安裝目錄屬主,屬組)
[root@www mysql-5.5.22]# cp support-files/my-medium.cnf /etc/my.cnf (註:復制MySQL配置文件)
[root@www mysql-5.5.22]# /usr/local/mysql/scripts/mysql_install_db
--user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ (註:初始化數據庫)
[root@www mysql-5.5.22]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile (註:添加環境變量)
[root@www mysql-5.5.22]# . /etc/profile (註:刷新環境變量)
6.註冊成系統服務
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
7.啟動服務
service mysqld start
8.設置數據庫用戶的密碼
mysqladmin -u root [-p] password 新密碼

四 LAMP
1.卸載PHP
rpm -e php --nodeps
2.安裝加密工具
數據加密工具libmcrypt、mhash、mcrypt
(1)安裝libmcrypt
tar zxf libmcrypt-2.5.8.tar.gz -C /usr/src/
cd /usr/src/libmcrypt-2.5.8/
./configure
make && make install
ln -s /usr/local/lib/libmcrypt. /usr/lib/
(2) 安裝mhash
tar zxf mhash-0.9.9.9.tar.gz -C /usr/src/
cd /usr/src/mhash-0.9.9.9/
./configure
make && make install
ln -s /usr/local/lib/libmhash
/usr/lib/
(3) 安裝mcrypt
tar zxf mcrypt-2.6.8.tar.gz -C /usr/src/
cd /usr/src/mcrypt-2.6.8/
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
./configure
make && make install
3.安裝PHP
tar zxf php-5.3.28.tar.gz -C /usr/src/
cd /usr/src/php-5.3.28/
./configure --prefix=/usr/local/php5
--with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs
--with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5
--enable-mbstring
make
make install
4.配置文件/usr/local/php5/php.ini調整
(1)復制模板:cp /usr/src/php-5.3.28/php.ini-development /usr/local/php5/php.ini
(2)修改配置: vim /usr/local/php5/php.ini
default_charset = "utf-8”
file_uploads = On
upload_max_filesize = 2M
max_file_uploads = 20
post_max_size = 8M
short_open_tag = On
(3)添加zend優化模塊
tar zxf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src/
cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ 、
cp ZendGuardLoader.so /usr/local/php5/lib/php/
vim /usr/local/php5/php.ini
zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
zend_loader.enable=1
5.apache配置文件修改
vim /usr/local/httpd/conf/httpd.conf

    LoadModule php5_module   modules/libphp5.so    (註:如果正常,則自動填寫)
    AddType application/x-httpd-php .php          (註:需要個人添加)

    DirectoryIndex index.php index.html

6.重啟Apache
/usr/local/httpd/bin/apachectl restart

7.測試PHP能否正確顯示
vim /usr/local/httpd/htdocs/test1.php
<?php
phpinfo( );
?>
8.測試數據庫能否正常訪問
vi /usr/local/httpd/htdocs/test2.php
<?php
$link=mysql_connect(‘localhost‘,‘root‘,‘123456‘);
if($link) echo "恭喜你,數據庫連接成功啦!!";
mysql_close();
?>

9.配置phpMyAdmin數據庫管理套件
(1)解包,並復制到網站目錄
tar zxf phpMyAdmin-4.2.5-all-languages.tar.gz
mv phpMyAdmin-4.2.5-all-languages/ /usr/local/httpd/htdocs/phpMyAdmin
(2)建立配置文件config.inc.php
cd /usr/local/httpd/htdocs/phpMyAdmin
cp config.sample.inc.php config.inc.php
(3)在瀏覽器訪問http://域名或IP/phpMyAdmin/

mysql lamp 配置命令總結