LAMP單機環(huán)境搭建
創(chuàng)新互聯(lián)從2013年開始,先為周村等服務(wù)建站,周村等地企業(yè),進行企業(yè)商務(wù)咨詢服務(wù)。為周村企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。一.系統(tǒng)環(huán)境準(zhǔn)備。
1.系統(tǒng)環(huán)境:CentOS_6.5,32位
[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[root@localhost ~]# uname -r
2.6.32-431.el6.i686
2.軟件版本
httpd-2.2.31
mysql-5.1.72
php-5.5.32
3.關(guān)閉防火墻iptables和selinux
3.1關(guān)閉防火墻iptables
[root@localhost tools]# chkconfig --level 2345iptables off
[root@localhost tools]# chkconfig --listiptables
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@localhost tools]# service iptables stop
[root@localhost tools]# service iptablesstatus
iptables: Firewall is not running.
3.2關(guān)閉selinux
[root@localhost tools]# vim/etc/selinux/config #修改配置如下圖所示
4.新建軟件管理文件夾及上傳相關(guān)軟件
4.1創(chuàng)建軟件管理文件夾
[root@localhost tools]# mkdir -p/home/jeff/tools/
[root@localhost tools]# ll /home/jeff/
total 4
drwxr-xr-x. 5 root root 4096 May 16 10:16tools
4.2上傳相關(guān)軟件
[root@localhost /]# cd /home/jeff/tools/
利用rz命令上傳相關(guān)軟件。如果無法使用該命令,請安裝lrzsz軟件。
二.安裝相關(guān)軟件
1.安裝apache軟件
1.1解壓apache
root@localhost tools]# tar -zxvf httpd-2.2.31.tar.gz
[root@localhost tools]# ll
total 63248
-rw-r--r-- 1 root root 10364427 Feb 22 14:51 Discuz_X3.1_SC_GBK.zip
drwxr-xr-x 11 1000 1000 4096 Jul 16 2015 httpd-2.2.31
-rw-r--r-- 1 root root 7583841 May 16 10:11 httpd-2.2.31.tar.gz
-rw-r--r-- 1 root root 4984397 Feb 22 13:52libiconv-1.14.tar.gz
-rw-r--r-- 1 root root 24044338 Feb 22 10:47 mysql-5.1.72.tar.gz
-rw-r--r-- 1 root root 17773092 Feb 22 11:22 php-5.5.32.tar.gz
1.2進入apache軟件目錄并進行配置(安裝請先安裝apr、apr-util、prce、gcc gcc-c++)
[root@localhost tools]# cd httpd-2.2.31
[root@localhost httpd-2.2.31]#./configure \
--prefix=/usr/local/apache2.2.31 \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--with-pcre=/usr/local/pcre \
--enable-deflate \
--enable-expires \
--enable-headers \
--enable-modules=most \
--enable-so \
--with-mpm=worker \
--enable-rewrite
1.3編譯安裝
[root@localhost httpd-2.2.31]# make & makeinstall
1.4啟動及檢查apache安裝情況
1.4.1啟動apache
[root@localhost bin]# ./apachectl start #啟動apache
httpd: Could not reliably determine theserver's fully qualified domain name, using ::1 for ServerName
1.4.2檢查apache啟動情況
[root@localhost bin]# ps -ef | grep http* #查看apache進程
root 17464 1 0 11:45 ? 00:00:00/usr/local/apache2.2.31/bin/httpd -k start
daemon 17465 17464 0 11:45 ? 00:00:00/usr/local/apache2.2.31/bin/httpd -k start
daemon 17466 17464 0 11:45 ? 00:00:00/usr/local/apache2.2.31/bin/httpd -k start
daemon 17467 17464 0 11:45 ? 00:00:00/usr/local/apache2.2.31/bin/httpd -k start
daemon 17468 17464 0 11:45 ? 00:00:00 /usr/local/apache2.2.31/bin/httpd-k start
root 17552 3284 0 11:45 pts/1 00:00:00 grep httpd
[root@localhost bin]# netstat -lntp | grep 80 #查看apache監(jiān)聽端口
tcp 0 0 :::80 :::* LISTEN 17464/httpd
用瀏覽器檢查:
http://localhost,如出現(xiàn)如下頁面,則說明apache安裝成功。
2.安裝mysql軟件
2.1解壓mysql
[root@localhost tools]# tar -zxvfmysql-5.1.72.tar.gz
[root@localhost tools]# ll
total 67372
drwxr-xr-x 12 1000 1000 4096 May 16 11:42 httpd-2.2.31
-rw-r--r-- 1 root root 7583841 May 16 10:11httpd-2.2.31.tar.gz
drwxrwxrwx 32 7155 wheel 4096 Sep 10 2013 mysql-5.1.72
-rw-r--r-- 1 root root 24044338 Feb 22 10:47mysql-5.1.72.tar.gz
-rw-r--r-- 1 root root 17773092 Feb 22 11:22php-5.5.32.tar.gz
2.2建立mysql相應(yīng)的用戶的用戶組
[root@localhost mysql-5.1.72]# groupadd -g 800mysql #創(chuàng)建mysql用戶組
[root@localhost mysql-5.1.72]# useradd -gmysql -u 800 -M -s /sbin/nologin mysql #創(chuàng)建mysql用戶
[root@localhost mysql-5.1.72]# cat /etc/group| grep mysql #檢查mysql組創(chuàng)建情況
mysql:x:800:
[root@localhost mysql-5.1.72]# cat /etc/passwd| grep mysql #檢查mysql用戶創(chuàng)建情況
mysql:x:800:800::/home/mysql:/sbin/nologin
#-s /sbin/nologin表示禁止該用戶登錄,加強安全。
#-g mysql指定屬于mysql組。
#-M表示不創(chuàng)建用戶家目錄。
2.3進入mysql軟件目錄并進行編譯安裝
2.3.1進入mysql軟件目錄
[root@localhost tools]# cd mysql-5.1.72 #進入mysql安裝目錄
2.3.2配置mysql(配置前安裝ncurses-devel先)
[root@localhost mysql-5.1.72]#./configure \
--prefix=/usr/local/mysql5.1.72 \
--with-unix-socket-path=/usr/local/mysql5.1.72/tmp/mysql.sock\
--localstatedir=/usr/local/mysql5.1.72/data \
--enable-assembler \
--enable-thread-safe-client \
--with-mysqld-user=mysql \
--with-big-tables \
--without-debug \
--with-pthread \
--enable-assembler \
--with-extra-charsets=complex \
--with-readline \
--with-ssl \
--with-embedded-server \
--enable-local-infile \
--with-plugins=partition,innobase \
--with-plugin-PLUGIN \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static
2.3.3編譯安裝
[root@localhost mysql-5.1.72] #make & makeinstall
2.4獲取mysql配置文件
[root@localhost mysql-5.1.72]# cdsupport-files
[root@localhost support-files]# cp -amy-small.cnf /etc/my.cnf
2.5創(chuàng)建軟連接,方便維護及升級
[root@localhost local]# ln -s /usr/local/mysql5.1.72//usr/local/mysql
2.6創(chuàng)建mysql數(shù)據(jù)庫文件
[root@localhost local]# mkdir -p/usr/local/mysql/data #建立mysql數(shù)據(jù)文件目錄
[root@localhost local]# chown -R mysql:mysql/usr/local/mysql5.1.72 #授權(quán)mysql用戶訪問mysql的安裝目錄
[root@localhost local]#/usr/local/mysql/bin/mysql_install_db --user=mysql #安裝mysql數(shù)據(jù)庫文件
2.7啟動mysql數(shù)據(jù)庫
[root@localhost bin]# cp /home/jeff/tools/mysql-5.1.72/support-files/mysql.server/usr/local/mysql/bin/
#拷貝mysql啟動腳本到mysql的命令路徑
[root@localhost bin]# chmod 700/usr/local/mysql/bin/mysql.server #使腳本可執(zhí)行
[root@localhost bin]#/usr/local/mysql/bin/mysql.server start #啟動數(shù)據(jù)庫
Starting MySQL. SUCCESS!
2.8檢查mysql數(shù)據(jù)庫啟動情況
[root@localhost bin]# netstat -lnt | grep 3306 #檢查mysql監(jiān)聽端口
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
[root@localhost bin]# ps -ef | grep"mysql*" #檢查mysql進程
root 3085 1 0 14:43 pts/3 00:00:00 /bin/sh/usr/local/mysql5.1.72/bin/mysqld_safe --datadir=/usr/local/mysql5.1.72/data--pid-file=/usr/local/mysql5.1.72/data/localhost.pid
mysql 3200 3085 0 14:43 pts/3 00:00:00 /usr/local/mysql5.1.72/libexec/mysqld--basedir=/usr/local/mysql5.1.72 --datadir=/usr/local/mysql5.1.72/data--user=mysql --log-error=/usr/local/mysql5.1.72/data/localhost.err--pid-file=/usr/local/mysql5.1.72/data/localhost.pid --socket=/usr/local/mysql5.1.72/tmp/mysql.sock--port=3306
root 3239 18040 0 14:47 pts/3 00:00:00 grep mysql*
[root@localhost bin]#/usr/local/mysql/bin/mysql -uroot #進入mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.72 Source distribution
Copyright (c) 2000, 2013, Oracle and/or itsaffiliates. All rights reserved.
Oracle is a registered trademark of OracleCorporation and/or its
affiliates. Other names may be trademarks oftheir respective
owners.
Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.
mysql>
2.9配置mysql命令的全局路徑
[root@localhost bin]# echo 'exportPATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
[root@localhost bin]# tail -1 /etc/profile #檢查
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile #使生效
2.10配置/etc/init.d/mysqldstart 方式啟動數(shù)據(jù)庫
[root@localhost bin]# cp/usr/local/mysql/bin/mysql.server /etc/init.d/mysqld
#拷貝mysql啟動腳本到/etc/init.d/下
chmod 700 /etc/init.d/mysqld #授權(quán)700權(quán)限,即腳本可執(zhí)行
[root@localhost bin]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
2.11設(shè)置開機自啟動
[root@localhost bin]# chkconfig --add mysqld
[root@localhost bin]# chkconfig mysqld on
[root@localhost bin]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
2.12 mysql安全配置,設(shè)置登錄密碼
[root@localhost bin]# mysqladmin -urootpassword '123456' #設(shè)置密碼:123456
3.安裝PHP軟件
3.1檢查安裝PHP所需lib庫
[root@localhost tools]# rpm -qa zlib libxmllibjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-develfreetype-devel libpng-devel gd-devel curl-devel #檢查lib庫安裝情況
安裝所需lib庫
[root@localhost tools]# yum install zliblibxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devellibjpeg-devel freetype-devel libpng-devel gd-devel curl-devel –y
安裝libiconv庫
[root@localhost tools]# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
[root@localhost tools]# tar -zxvflibiconv-1.14.tar.gz
[root@localhost tools]#cd libiconv-1.14.tar.gz
[root@localhost libiconv-1.14]#./configure --prefix=/usr/local/libiconv
[root@localhost libiconv-1.14]#make
[root@localhost libiconv-1.14]#make install
3.2解壓php軟件
[root@localhost tools]# tar -zxvfphp-5.5.32.tar.gz
[root@localhost tools]# ll
total 67376
drwxr-xr-x 14 1001 1001 4096 Feb 2 21:36 php-5.5.32
-rw-r--r-- 1 root root 17773092 Feb 22 11:22php-5.5.32.tar.gz
3.3配置
./configure \
--prefix=/usr/local/php5.5.32 \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-xmlrpc \
--with-openssl \
--with-zlib \
--with-freetype-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-iconv=/usr/local/libiconv \
--enable-short-tags \
--enable-sockets \
--enable-soap \
--enable-mbstring \
--enable-static \
--enable-gd-native-ttf \
--with-curl \
--with-xsl \
--enable-ftp \
--with-libxml-dir
3.4編譯安裝
[root@localhost php-5.5.32]#make
Build complete.
Don't forget to run 'make test'.
[root@localhost php-5.5.32]#make install
3.5生成配置文件
[root@localhost php-5.5.32]# ls php.ini*
php.ini-development php.ini-production
[root@localhost php-5.5.32]# ln -s/usr/local/php5.5.32 /usr/local/php
[root@localhost php-5.5.32]# cpphp.ini-production /usr/local/php/lib/php.ini
3.6配置apache支持php
3.6.1修改apache配置文件
執(zhí)行如下命令編輯apache的主配置文件httpd.conf:
[root@localhost /]# cd /usr/local/apache/conf
[root@localhost conf]# cp httpd.confhttpd.conf.20160516.bak
[root@localhost conf]# vim httpd.conf
#增加如下內(nèi)容:
ServerName 127.0.0.1:80
轉(zhuǎn)到311行即#AddTypeapplication/x-gzip .tgz行的下一行加兩行對PHP的解析支持內(nèi)容:
#AddType application/x-httpd-php .php .php3
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
修改默認(rèn)的首頁文件,本例中增加一個index.php:
DirectoryIndex index.php index.html
3.7檢查并啟動apache
檢查apache配置文件的語法
[root@localhost conf]#/usr/local/apache/bin/apachectl -t
Syntax OK
重啟apache服務(wù)
[root@localhost conf]#/usr/local/apache/bin/apachectl graceful
[root@localhost conf]# netstat -lntp | grep 80
tcp 0 0 :::80 :::* LISTEN 8989/httpd
#查看httpd服務(wù)的80端口是否開啟
3.8測試php環(huán)境
進入指定的默認(rèn)站點目錄后,編輯index.php添加:
進入默認(rèn)的apache站點目錄
[root@localhost conf]# cd/usr/local/apache/htdocs/
[root@localhost conf]#vimindex.php
<?php
Phpinfo();
?>
#注以上代碼為顯示php配置信息的簡單php文件代碼,最好手工敲,以防出錯;
#通過訪問并刷新瀏覽器http://ip,如可以看到phpinfo信息,如下圖,說明php環(huán)境配置ok;
至此LAMP單機環(huán)境搭建完成!
附件:http://down.51cto.com/data/2367706另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
網(wǎng)站欄目:linux單機LAMP環(huán)境搭建-創(chuàng)新互聯(lián)
URL標(biāo)題:http://jinyejixie.com/article6/hgpog.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、電子商務(wù)、用戶體驗、域名注冊、網(wǎng)站建設(shè)、營銷型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容