常用指令: 查詢已安裝的軟件:rpm -qa | grep 軟件名稱 卸載已安裝的軟件:rpm -e 軟件名稱 –nodeps –nodeps為強制卸載,無視包的依賴關系 查看目錄:whereis 目錄名 刪除文件:rm -rf 文件或目錄名
①、將所需軟件拖到linux系統中(軟件下載網址見底部)
②、對linux中的AMP軟件進行解壓 解壓指令: .tar.gz 格式解壓為 tar -zxvf xx.tar.gz .tar.bz2 格式解壓為 tar -jxvf xx.tar.bz2 解壓后: 
aPR-1.5.1.tar.bz2 apr-util-1.5.4.tar.bz2 pcre-8.36.tar.bz2 這些是Apache依賴的一些安裝包。
① 安裝cd apr-1.5.1 cd apr-1.5.1 ./configure –prefix=/usr/local/apr make && make install
② 安裝apr-util-1.5.4 cd apr-util-1.5.4 ./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr make && make install
③ 安裝pcre-8.36 cd pcre-8.36 ./configure make && make install
④ 都完成后正式安裝Apache cd httpd-2.4.10 ./configure –prefix=/usr/local/apache2 –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util –with-pcre=/usr/local/pcre –enable-so –enable-rewrite make && make install
cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
⑤啟動apache service httpd start
啟動時,如果提示如下信息: 正在啟動 httpd:httpd: Could not reliably determine the server’s fully qualified domain name, using localhost.localdomain for ServerName 編輯 /usr/local/apache2/conf/httpd.conf 找到如下內容: #ServerName www.example.com:80 更改為 ServerName localhost:80 再重啟一下Apache服務即可
測試是否安裝成功 出現“It works”就說明Apache已經正常安裝。
① 需要先安裝好 cmake yum -y install cmake make
② 安裝MySQL cd mysql-5.5.21 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFIGDIR=/usr/local/mysql/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_USER=mysql make && make install
如果安裝出現一下錯誤: — Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH) CMake Error at cmake/readline.cmake:82 (MESSAGE): Curses library not found. Please install appropriate package, remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel. Call Stack (most recent call first): cmake/readline.cmake:126 (FIND_CURSES) cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT) CMakeLists.txt:250 (MYSQL_CHECK_READLINE) — Configuring incomplete, errors occurred! 則解決方法為: cd mysql-5.5.21 rm CMakeCache.txt yum install ncurses-devel yum install bison make && make install
③ 配置mysql 5.5.21 cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf vi /etc/my.cnf 修改my.cnf配置,把innodb相關選項前面的#去掉,大概在115-130行之間。
④ mysql 啟動及自啟動配置 cp /usr/loacl/mysql/support-files/mysql.server /etc/init.d/mysqld /usr/local/mysql/scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data & chkconfig –add mysqld chkconfig –level 345 mysqld on
⑤ 啟動mysql服務 service mysqld start
⑥ 為MySQL的root賬戶設置密碼 /usr/local/mysql/bin/mysqladmin -u root passWord ‘new-password’
⑦ 登陸MySQL,設置遠程連接(根據自己情況決定是否設置) grant all privileges on . to ‘root’@’%’ identified by ‘root’ with grant option; flush privileges;
在使用mysql命令時,如果遇到以下錯誤: -bash: mysql: command not found 則解決方法為: 映射一個鏈接到/usr/bin目錄下,相當于建立一個鏈接文件 比如mysql的路徑是:/usr/local/mysql/bin/mysql,則可以這樣執行命令: # ln -s /usr/local/mysql/bin/mysql /usr/bin
安裝php cd php-5.6.4 ./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs –with-libxml-dir=/usr/include/libxml2 –with-config-file-path=/usr/local/apache2/conf –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-gd –enable-gd-native-ttf –with-zlib –with-mcrypt –with-pdo-mysql=/usr/local/mysql –enable-shmop –enable-soap –enable-sockets –enable-wddx –enable-zip –with-xmlrpc –enable-fpm –enable-mbstring –with-zlib-dir –with-bz2 –with-curl –enable-exif –enable-ftp –with-jpeg-dir=/usr/lib –with-png-dir=/usr/lib –with-freetype-dir=/usr/lib/
在編譯PHP時可能會遇到一些問題,如ssl沒裝、bzip2軟件包沒有安裝、curl和curl庫文件沒有安裝等問題,致使PHP編譯失敗。 解決方法: 安裝前.先安裝些軟件和庫文件 yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
安裝完這些軟件后,還可能遇到以下問題: configure: error: mcrypt.h not found. Please reinstall libmcrypt. 解決方法: 使用yum命令安裝 yum install php-mcrypt libmcrypt libmcrypt-devel
這些問題都解決好后,則再一次編譯PHP,編譯沒有問題,則執行以下命令即可: make && make install
修改配置文件:vi /usr/local/apache/conf/httpd.conf ① 添加php支持 在AddType text/html .shtml下面添加: AddType application/x-httpd-php .php .phtml AddType application/x-httpd-php-source .phps
② 添加默認索引頁面index.php,再找到“DirectoryIndex”,在index.html后面加上“ index.php” DirectoryIndex index.html index.php
③ 不顯示目錄結構(根據自己情況決定是否顯示) 找到“Options Indexes FollowSymLinks”,修改為 Options FollowSymLinks
④ 開啟Apache支持偽靜態 找到“AllowOverride None”,修改為 AllowOverride All
⑤ 更改Apache默認網站目錄 找到 DocumentRoot “/usr/local/apache2/htdocs ” 這一段 把/usr/local/apache2/htdocs 這個目錄改為/var/www/html 再找到 <Directory "/usr/local/apache2/htdocs">這個區域 把 /usr/local/apache2/htdocs改成/var/www/html

保存httpd.conf配置
更改文件權限: chmod -R 755 /var/www/html
⑥ 如果httpd.conf還未保存,則保存文件。
⑦ 執行以下兩行命令 chown -R nobody. /usr/local/apache/htdocs/ chmod -R 777 /usr/local/apache/htdocs/
⑧ 重啟apache服務 service httpd restart
注:該文章內容主要取自于以下鏈接(http://blog.csdn.net/flang6157/article/details/49336109),如需下載amp軟件包,也請到該網址下載。
新聞熱點
疑難解答