1:查看環境:
1
2
2</codebitstream></p>
<p><codebitstream vera sans mono new min-height:inherit background:none>
html]# cat /etc/redhat-release</codebitstream></p></tdbitstream></tdbitstream></tr>CentOS
release 6.5 (Final)</tbody></table>
<p><span></span></p>
<p></p>
<p></p>
<p>2:關掉防火牆</p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none> <tbody>
<tr><tdbitstream vera sans mono new min-height:inherit color:rgb background:none>[root@10-4-14-168
html]# chkconfig iptables <p></p>off<tdbitstream vera sans mono new min-height:inherit background:none><p></p>
<p><codebitstream vera sans mono new min-height:inherit background:none><codebitstream vera sans mono new min-height:inherit color:rgb background:none></codebitstream></codebitstream></p></tdbitstream></tdbitstream></tr>3:配置CentOScg </tbody>
</table> 1<p><span></span></p>
<p></p>
<p>#wget http://www.atomicorp.com/installers/atomic</p>
<p></p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none><tbody><tr><tdbitstream vera sans mono new min-height:inherit color:rgb background:none><p></p>
<tdbitstream vera sans mono new min-height:inherit background:none><p></p>
<p><codebitstream vera sans mono new min-height:inherit background:none></codebitstream></p></tdbitstream></tdbitstream></tr></tbody></table> <p>1</p>
<p></p>
<p></p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none><tbody><tr><tdbitstream vera sans mono new min-height:inherit color:rgb background:none>#sh
./atomic<p></p>
<tdbitstream vera sans mono new min-height:inherit background:none><p></p>
<p><codebitstream vera sans mono new min-height:inherit background:none></codebitstream></p></tdbitstream></tdbitstream></tr></tbody></table> -<p></p>
<p>update</p>
<p></p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none><tbody><tr><tdbitstream vera sans mono new min-height:inherit color:rgb background:none><p></p>
<p><span>4:安裝開發包與庫檔案 </span></p>
<p></p>
<p></p>
<p></p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none><tbody><tr><tdbitstream vera sans mono new min-height:inherit color:rgb background:none><p>1</p>22<p>2</p> <p>#yum
-y install ntp make openssl openssl-devel pcre pcre-devel libpng</p>
<p></p>libpng-devel
libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel<tdbitstream vera sans mono new min-height:inherit background:none><p></p>
<p><codebitstream vera sans mono new min-height:inherit background:none>gcc
gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2</codebitstream></p>
<p><codebitstream vera sans mono new min-height:inherit background:none>libxml2-devel
imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel</codebitstream></p>
<p><codebitstream vera sans mono new min-height:inherit background:none></codebitstream></p>
<p><codebitstream vera sans mono new min-height:inherit background:none></codebitstream></p> </tdbitstream></tdbitstream></tr></tbody></table>1 2<p>3<span></span></p>
<p></p>
<p></p>
<p>#
yum remove httpd</p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none><tbody><tr><tdbitstream vera sans mono new min-height:inherit color:rgb background:none>#
yum remove mysql<p></p>
<p></p>#
yum remove php<p></p>
<tdbitstream vera sans mono new min-height:inherit background:none><p></p>
<p><codebitstream vera sans mono new min-height:inherit background:none></codebitstream></p>
<p><codebitstream vera sans mono new min-height:inherit background:none>6:安裝nginx</codebitstream></p>
<p> <codebitstream vera sans mono new min-height:inherit background:none>4</codebitstream></p></tdbitstream></tdbitstream></tr></tbody></table>#
yum install nginx<p>#
service nginx start<span></span></p>
<p>#
chkconfig </p>
<p></p>
<p>--levels
235 nginx on</p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none><tbody><tr><tdbitstream vera sans mono new min-height:inherit color:rgb background:none>//設2、3、5級開機啟動<p></p>
<p></p>
<p></p>
<p></p>
<p><span>7:安裝mysql</span></p>
<p></p>
<p></p>
<p></p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none><tbody><tr><tdbitstream vera sans mono new min-height:inherit color:rgb background:none><p>1</p>
<p>2
yum install mysql mysql-server mysql-devel</p>
<p></p>#
服務mysqld啟動<tdbitstream vera sans mono new min-height:inherit background:none><p></p>
<p><codebitstream vera sans mono new min-height:inherit background:none>#
chkconfig </codebitstream></p>--級別
235 mysqld 開啟<p><codebitstream vera sans mono new min-height:inherit background:none></codebitstream></p>
<p><codebitstream vera sans mono new min-height:inherit background:none></codebitstream></p>
<p></p>
<p></p>
<p></p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none><tbody><tr><tdbitstream vera sans mono new min-height:inherit color:rgb background:none><p>1</p>
<p>2</p>
<p>3</p>
<p>4</p> <p></p>
<p>登陸MySQL刪除空用戶,修改root密碼</p>
<p> </p>
<p>mysql></p>select<tdbitstream vera sans mono new min-height:inherit background:none> <p>user</p>
<p><codebitstream vera sans mono new min-height:inherit background:none>,host,</codebitstream></p>password<p> <codebitstream vera sans mono new min-height:inherit background:none>from <codebitstream vera sans mono new min-height:inherit color:rgb background:none>my. <codebitstream vera sans mono new min-height:inherit color:rgb background:none>drop <codebitstream vera sans mono new min-height:inherit background:none>user <codebitstream vera sans mono new min-height:inherit color:rgb background:none>''<codebitstream vera sans mono new min-height:inherit color:rgb background:none>@ localhost;<codebitstream vera sans mono new min-height:inherit background:none><p><codebitstream vera sans mono new min-height:inherit background:none>mysql><codebitstream vera sans mono new min-height:inherit color:rgb background:none>update <codebitstream vera sans mono new min-height:inherit background:none>mysql.<codebitstream vera sans mono new min-height:inherit color:rgb background:none>user <codebitstream vera sans mono new min-height:inherit color:rgb background:none>set <codebitstream vera sans mono new min-height:inherit color:rgb background:none>password <codebitstream vera sans mono new min-height:inherit background:none>*** <codebitstream vera sans mono new min-height:inherit color:rgb background:none>) <codebitstream vera sans mono new min-height:inherit background:none>where <codebitstream vera sans mono new min-height:inherit color:blue background:none> user<codebitstream vera sans mono new min-height:inherit background:none>=<codebitstream vera sans mono new min-height:inherit color:rgb background:none>'root'<codebitstream vera sans mono new min-height:inherit color:rgb background:none>;<codebitstream vera sans mono new min-height:inherit background:none><codebitstream vera sans mono new min-height:inherit color:blue background:none>mysql>flush <codebitstream vera sans mono new min-height:inherit background:none>privileges</codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></p>;修改資料庫使用者密碼的方法:<p><codebitstream vera sans mono new min-height:inherit background:none> mysqladmin -u root password "123456" <codebitstream vera sans mono new min-height:inherit color:rgb background:none>//為root使用者設定密碼<codebitstream vera sans mono new min-height:inherit background:none></codebitstream></codebitstream></codebitstream></p></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></p>service
mysqld restart</tdbitstream></tdbitstream></tr></tbody></table>8:安裝php<p></p>
<p><span></span><span></span></p>
<p><span>1<span></span><br></span></p>
yum install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap<p><span></span></p>php-odbc
php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap<p></p>
<p></p>
<p></p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none><tbody><tr><tdbitstream vera sans mono new min-height:inherit color:rgb background:none><p>//安裝php和所需組件使PHP支援MySQL、FastCGI模式</p>
<p></p>
<p></p>
<p></p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none>
<tbody><tr><tdbitstream vera sans mono new min-height:inherit color:rgb background:none><p>1</p>#
install php-tidy php-common php-devel php-fpm php-mysql<tdbitstream vera sans mono new min-height:inherit background:none><p></p>
<p><codebitstream vera sans mono new min-height:inherit background:none></codebitstream></p></tdbitstream></tdbitstream></tr></tbody> </table>#
service php-fpm start<p></p>
<p></p>
<p>#
chkconfig </p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none><tbody>--levels
235 php-fpm on<tr><tdbitstream vera sans mono new min-height:inherit color:rgb background:none><p></p>
<p></p>
<p><span>9:配置nginx支援php</span></p>
<p></p>
<p></p>
<p></p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none><tbody><tr>3<tdbitstream vera sans mono new min-height:inherit color:rgb background:none>14 <p>7</p>
<p>8</p>
<p>9</p>
<p>10</p> <p>11</p>
<p>12</p>
<p>13</p>
<p>14</p>
<p>15</p>
<p>16</p>
<p>17</p>
<p>188
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak</p>
<p></p>
<p>/</p>
<p>/</p>
<p>將設定檔改為備份檔</p>
<p></p>
<p></p>將設定檔改為備份檔<p></p>
<tdbitstream vera sans mono new min-height:inherit background:none><p>
cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf</p>
<p><codebitstream vera sans mono new min-height:inherit color:rgb background:none></codebitstream></p>/<p><codebitstream vera sans mono new min-height:inherit color:rgb background:none>/<codebitstream vera sans mono new min-height:inherit color:rgb background:none>由於原設定檔要自己去寫因此可以使用預設的設定檔作為設定檔<codebitstream vera sans mono new min-height:inherit background:none>由於原設定檔要自己去寫因此可以使用預設的設定檔作為檔案當檔/</codebitstream></codebitstream></codebitstream></p>
<p>/<codebitstream vera sans mono new min-height:inherit color:rgb background:none>修改nginx設定文件,加入fastcgi支援</codebitstream></p>
<p><codebitstream vera sans mono new min-height:inherit color:rgb background:none>#
vi /etc/nginx/nginx.conf<codebitstream vera sans mono new min-height:inherit color:rgb background:none><codebitstream vera sans mono new min-height:inherit background:none>index
index.php index.html index.htm;</codebitstream></codebitstream></codebitstream></p>
<p><codebitstream vera sans mono new min-height:inherit color:rgb background:none>/<codebitstream vera sans mono new min-height:inherit color:rgb background:none>/<codebitstream vera sans mono new min-height:inherit background:none>加入index.php</codebitstream></codebitstream></codebitstream></p>
<p><codebitstream vera sans mono new min-height:inherit color:rgb background:none>location
~ .php$ {</codebitstream></p>
<p></p>
<p><codebitstream vera sans mono new min-height:inherit background:none> <codebitstream vera sans mono new min-height:inherit background:none>root <codebitstream vera sans mono new min-height:inherit color:rgb background:none>/<codebitstream vera sans mono new min-height:inherit background:none>usr<codebitstream vera sans mono new min-height:inherit color:rgb background:none>/<codebitstream vera sans mono new min-height:inherit background:none>分享<codebitstream vera sans mono new min-height:inherit color:rgb background:none>/<codebitstream vera sans mono new min-height:inherit background:none>nginx<codebitstream vera sans mono new min-height:inherit color:rgb background:none>/<codebitstream vera sans mono new min-height:inherit background:none>html;</codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></p> <p><codebitstream vera sans mono new min-height:inherit background:none> <codebitstream vera sans mono new min-height:inherit background:none>fastcgi_pass <codebitstream vera sans mono new min-height:inherit color:rgb background:none>127.0<codebitstream vera sans mono new min-height:inherit background:none>.<codebitstream vera sans mono new min-height:inherit color:rgb background:none>0.1<codebitstream vera sans mono new min-height:inherit background:none>: <codebitstream vera sans mono new min-height:inherit color:rgb background:none>9000<codebitstream vera sans mono new min-height:inherit background:none>;</codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></p>
<p><codebitstream vera sans mono new min-height:inherit background:none> <codebitstream vera sans mono new min-height:inherit background:none>fastcgi_index
索引.php;</codebitstream></codebitstream></p>
<p><codebitstream vera sans mono new min-height:inherit background:none> <codebitstream vera sans mono new min-height:inherit background:none>fastcgi_param
SCRIPT_FILENAME <codebitstream vera sans mono new min-height:inherit color:rgb background:none>/<codebitstream vera sans mono new min-height:inherit background:none>usr<codebitstream vera sans mono new min-height:inherit color:rgb background:none>/<codebitstream vera sans mono new min-height:inherit background:none>share<codebitstream vera sans mono new min-height:inherit color:rgb background:none>/<codebitstream vera sans mono new min-height:inherit background:none>nginxfast <codebitstream vera sans mono new min-height:inherit color:rgb background:none>include
fastcgi_params;<codebitstream vera sans mono new min-height:inherit background:none></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></codebitstream></p> <p><codebitstream vera sans mono new min-height:inherit background:none>}<codebitstream vera sans mono new min-height:inherit background:none></codebitstream></codebitstream></p>/<p><codebitstream vera sans mono new min-height:inherit background:none>/<codebitstream vera sans mono new min-height:inherit background:none></codebitstream></codebitstream></p>/<p> <codebitstream vera sans mono new min-height:inherit color:rgb background:none><codebitstream vera sans mono new min-height:inherit color:rgb background:none><codebitstream vera sans mono new min-height:inherit background:none>10:配置php</codebitstream></codebitstream></codebitstream></p> </tdbitstream></tdbitstream>
</tr></tbody></table>1<p>2</p>
<p></p>
<p></p>
<p></p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none><tbody>//編輯檔案php.ini,檔案末尾加上cgi.fix_pathinfo
= 1<tr><tdbitstream vera sans mono new min-height:inherit color:rgb background:none><p></p>[root@CentOS
~]# vi /etc/php.ini<p></p>
<tdbitstream vera sans mono new min-height:inherit background:none><p></p>
<p><codebitstream vera sans mono new min-height:inherit background:none></codebitstream></p>
<p><codebitstream vera sans mono new min-height:inherit background:none>11:重啟nginx php-fpm</codebitstream></p>1 </tdbitstream></tdbitstream></tr>
</tbody></table>#
service nginx restart<p></p>#
service php-fpm restart<p></p>
<p></p>
<p></p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none><tbody><tr><tdbitstream vera sans mono new min-height:inherit color:rgb background:none><p>12:建立info.php文件</p>
<p></p>
<p></p>
<p></p>
<table border="0" cellpadding="0" cellspacing="0" bitstream vera sans mono new font-size:12px min-height:inherit background:none><tbody><tr><tdbitstream vera sans mono new min-height:inherit color:rgb background:none><p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<tdbitstream vera sans mono new min-height:inherit background:none><p></p>
<p><codebitstream vera sans mono new min-height:inherit background:none>#
vi /usr/share/nginx/html/info.php</codebitstream></p>
<p><codebitstream vera sans mono new min-height:inherit background:none><?php
phpinfo();
13:測試nginx是否解析php
|
1
2
本地瀏覽器輸入:127.0.1/37.
環境搭建成功
14:測試mysql是否安裝成功
<?php
$link = mysql_connect("localhost","root","mysql密码");
if (!$link){
<span style="white-space:pre"> </span>die('Could not connect: ' . mysql_error());
}else{
<span style="white-space:pre"> </span> echo "Mysql已经正确配置";
}
mysql_close($link);
?>
完成後,可透過指令 rpm -ql 查看軟體套件特定的安裝目錄。 以查看nginx的安裝目錄為例:
#rpm -ql nginx
可透過指令 rpm -q 檢視軟體套件的版本資訊。
以查看nginx的版本為例:
#rpm -q nginx
原文網址:http://www.cnblogs.com/xiaoit/p/3991037.html
以上就介紹了CentOS65搭建LNMP,包含了面向的內容,希望對PHP教學有興趣的朋友有幫助。