CentOS6.3搭建lnmp環境

來源:互聯網
上載者:User

1.本文直接禁用掉了防火牆iptables和selinux:
/etc/init.d/iptables stop
chkconfig iptables off
vi /etc/selinux/config
SELINUX=enforcing 改成 SELINUX=disabled
補充:# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo //直接163下載相關的源
2.下載第三方源
wget http://www.atomicorp.com/installers/atomic
sh ./atomic
yum check-update

3.安裝web伺服器nginx
yum install nginx
chkconfig nginx on

4.安裝資料庫mysql
yum install mysql mysql-server
chkconfig mysqld on

5.安裝php環境
yum install php php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm
chkconfig php-fpm on

6.
vi /etc/nginx/conf.d/default.conf
(a)."index  index.html index.htm;" 改為 "index  index.html index.htm index.php;"
(b).
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#   
#location ~ \.php$ {
#    root           html;
#    fastcgi_pass   127.0.0.1:9000;
#    fastcgi_index  index.php;
#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
#    include        fastcgi_params;
#}  
改成
location ~ \.php$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

7.
vi  /etc/php.ini   #編輯
date.timezone = PRC     #在946行 把前面的分號去掉,改為date.timezone = PRC
#在386行 列出PHP可以禁用的函數,如果某些程式需要用到這個函數,可以刪除,取消禁用。
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,
posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,
posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname

expose_php = Off        #在432行 禁止顯示php版本的資訊

magic_quotes_gpc = On   #在745行 開啟magic_quotes_gpc來防止SQL注入
open_basedir = .:/tmp/  #在380行,設定表示允許訪問目前的目錄(即PHP指令檔所在之目錄)和/tmp/目錄,可以防止php木馬跨站,如果改了之後安裝程式有問題,可登出此行,或者直接寫上程式目錄路徑/var/www/html/www.osyunwei.com/:/tmp/
:wq!  #儲存退出

8.
vi /etc/php-fpm.d/www.conf   #編輯
user = nginx   #修改使用者為nginx
group = nginx   #修改組為nginx

9.
chown nginx:nginx /usr/share/nginx/html/ -R
chmod 755 /usr/share/nginx/html/ -R

10.reboot

11.
vi /usr/share/nginx/html/index.php
輸入:
<?php
    phpinfo();
?>
在Windows瀏覽器輸入:http://192.168.1.101/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.