linux lnmp搭建
1、安装nginx:
yum install gcc -y
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
yum -y install nginx
2、安装php和php-fpm:
yum -y install php
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-mysql php-fpm
3、配置nginx支持php:
在nginx的配置文件server里加上
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;
}
4、service nginx start/restart
5、service php-fpm start/restart
注:nginx放置网页文件:/usr/share/nginx/html
配置文件:/etc/nginx
安装mysql
1、yum install -y mysql-server mysql mysql-deve
2、service mysqld start
3、允许远程登陆:
A) 改表法:更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
B) 授权法:mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION
mysql>FLUSH PRIVILEGES;
或
grant all on *.* to root@'%' identified by '你的密码' with grant option;
flush privileges;
注:mysql主配置文件:/etc/my.cnf