centos 安装lnmp

时间:2022-09-25 06:33:17

1:查看环境

cat /etc/redhat-release

2:关闭防火墙

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-develgcc 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

 

5:卸载已安装的apachemysqlphp

yum remove httpd

yum remove mysql

yum remove php

 

6:安装nginx

yum install nginx

service nginx start

chkconfig --levels 235 nginx on

7:安装mysql

yum install mysql mysql-server mysql-devel

service mysqld start

chkconfig --levels 235 mysqld on

登陆MySQL删除空用户,修改root密码

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

Nginx配置

Symfony nginx访问配置

server {

listen       80;

server_name  localhost;

charset utf-8;

root /home/fujie/www/lecar/web;

location / {

try_files $uri /app_dev.php$is_args$args;

}

location ~ ^/(app_dev|config)\.php(/|$) {

fastcgi_pass 127.0.0.1:9000;

fastcgi_split_path_info ^(.+\.php)(/.*)$;

include fastcgi_params;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param HTTPS off;

}

error_log /var/log/nginx/project_error.log;

access_log /var/log/nginx/project_access.log;

}