contos安装lnmp

来源:互联网 发布:网络语打卡的意思 编辑:程序博客网 时间:2024/06/05 19:17
1.登陆系统后使用yum安装MySQL,PHP,nginx,
 yum install mysql mysql-server nginx php php-fpm
2.安装软件信息查看
 rpm -ql XX(soft address)
 rpm -q XX(soft version)


3.配置nginx
 (1)启动nginx
 service nginx restart
 测试nginx是否正常启动,访问主机iP地址
 (2)
 启动php
 service php-fpm start
 查看php-fpm默认配置
 cat /etc/php-fpm.d/www.conf |grep -i 'listen='
 修改nginx配置
 vim /etc/nginx/conf.d/default.conf
 server {
  listen       80;
  root   /usr/share/nginx/html;
  server_name  localhost;
  #charset koi8-r;
  #access_log  /var/log/nginx/log/host.access.log  main;
  location / {
      index  index.html index.htm;
  }
  #error_page  404              /404.html;
  # redirect server error pages to the static page /50x.html
  #
  error_page   500 502 503 504  /50x.html;
  location = /50x.html {
      root   /usr/share/nginx/html;
  }
  # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  #
  #location ~ \.php$ {
  #    proxy_pass   http://127.0.0.1;
  #}
  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  #
  location ~ \.php$ {
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index   index.php;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include        fastcgi_params;
  }
  # deny access to .htaccess files, if Apache's document root
  # concurs with nginx's one
  #
  #location ~ /\.ht {
  #    deny  all;
  #}
}
 重启nginx,使配置生效
 service nginx restart
 (3)环境配置验证
 在web目录下创建index.php
 vim /usr/share/nginx/html/index.php
 输出php.info()
3.配置mysql
 (1)启动MySQL数据库
 service mysqld start
 配置MySQL为系统默认启动
 chkconfig mysqld on   #chkconfig设置服务为系统自动启动
 登陆数据库
 mysql -u root -p password
 (2)配置数据库密码
 mysqladmin -u root password XXX
 (3)配置php支持mysql_connect()
 /etc/php.ini
0 0
原创粉丝点击