centos6.5 yum安装LNMP(Nginx+PHP+MySQL)
买了个超低配置的VPS(128内存),装了CENTOS,以下是安装LNMP记录
安装详情参考:http://www.osyunwei.com/archives/2353.html
- Nginx安装
#配置nginx源,centos默认没有nginx源
wget http://www.atomicorp.com/installers/atomic
sh ./atomic
yum check-update
#安装Nginx
yum install nginx
service nginx start
chkconfig nginx on #设置开机启动
- PHP安装
yum install php
#组件
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc
yum install php-pear php-xml php-xmlrpc php-mbstring php-mcrypt
yum install php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm
service php-fpm start
chkconfig php-fpm on
- MySql安装
yum install mysql mysql-server
service mysqld start
chkconfig mysqld on
mysql_secure_installation #为root设置密码,一路回车
- 配置NGINX支持PHP
cp /etc/nginx/nginx.conf /etc/nginx/nginx.confbak #备份
vi /etc/nginx/nginx.conf
user nginx nginx; #修改nginx运行账号
:wq!
cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak
vi /etc/nginx/conf.d/default.conf
index index.php index.html index.htm; #增加index.php
#取消以下部分注释,并修改
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;
}
:wq
- 配置PHP-FPM
cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.confbak
vi /etc/php-fpm.d/www.conf
user = nginx
group = nginx
- 重启服务
service mysqld restart
service nginx restart
service php-fpm restart
- 一些默认的路径及配置文件(centos6.5 yum安装)
**nginx默认站点目录:/usr/share/nginx/html/
nginx默认站点配置文件:/etc/nginx/conf.d/default.conf
php默认配置文件:/etc/php.ini
php-fpm配置文件:/etc/php-fpm.d/www.conf
mysql默认配置文件:/etc/my.cnf**