CentOS6.5搭建LNMP
1:查看环境:
1[root@10-4-14-168 html]# cat /etc/redhat-release
2.CentOS release 6.5 (Final)
2:关掉防火墙
1[root@10-4-14-168 html]# chkconfig iptables off
3:配置CentOS 6.0 第三方yum源(CentOS默认的标准源里没有Nginx软件包)
#wget http://www.atomicorp.com/installers/atomic
#sh ./atomic
#yum check-update
4:安装开发包和库文件
#yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng
libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel
gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2
libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel
# yum remove httpd
# yum remove MysqL
# yum remove PHP
6:安装Nginx
# yum install Nginx
# service Nginx start
# chkconfig --levels 235 Nginx on
//设2、3、5级别开机启动
7:安装MysqL
# yum install MysqL MysqL-server MysqL-devel
# service MysqLd start
# chkconfig --levels 235 MysqLd on
MysqL>select user,host,password from MysqL.user;
MysqL>drop user ''@localhost;
MysqL>update MysqL.user set password = PASSWORD('*********') where user='root';
MysqL>flush privileges;
8:安装PHP
# yum install PHP lighttpd-fastcgi PHP-cli PHP-MysqL PHP-gd PHP-imap PHP-ldap
PHP-odbc PHP-pear PHP-xml PHP-xmlrpc PHP-mbstring PHP-mcrypt PHP-mssql PHP-snmp PHP-soap
//安装PHP和所需组件使PHP支持MysqL、FastCGI模式
#yum install PHP-tidy PHP-common PHP-devel PHP-fpm PHP-MysqL
# service PHP-fpm start
# chkconfig --levels 235 PHP-fpm on
# mv /etc/Nginx/Nginx.conf /etc/Nginx/Nginx.confbak
# cp /etc/Nginx/Nginx.conf.default /etc/Nginx/Nginx.conf
//由于原配置文件要自己去写因此可以使用默认的配置文件作为配置文件
index index.PHP index.html index.htm;
//加入index.PHP
location ~ \.PHP$ {
root /usr/share/Nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.PHP;
fastcgi_param SCRIPT_FILENAME /usr/share/Nginx/html$fastcgi_script_name;
include fastcgi_params;
}
10:配置PHP
//编辑文件PHP.ini,在文件末尾添加cgi.fix_pathinfo = 1
[root@CentOS ~]# vi /etc/PHP.ini
# service Nginx restart
# service PHP-fpm restart
# vi /usr/share/Nginx/html/info.PHP
<?PHP
PHPinfo();
?>
本地浏览器输入:192.168.1.105/info.PHP
原文链接:https://www.f2er.com/centos/381610.html