• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

基于CentOS6.5的LNMP环境手工搭建

php 搞代码 3年前 (2022-01-22) 21次浏览 已收录 0个评论

这篇文章主要介绍了关于基于CentOS6.5的LNMP环境手工搭建,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下

  Lnmp安装有两种方式,一是一键安装,由于安装过程中升级系统文件,在编译golang的时候出现问题,有待于进一步解决;二是分布安装,该过程安装后可以正常编译相关程序。    1、查看环境:[root@localhost ~]# cat /etc/redhat-releaseCentOS release 6.5 (Final)[root@localhost ~]#     2、关闭防火墙:[root@localhost ~]# service iptables stopiptables: Setting chains to policy ACCEPT: filter          [  OK  ]iptables: Flushing firewall rules:                         [  OK  ]iptables: Unloading modules:                               [  OK  ][root@localhost ~]# service iptables statusiptables: Firewall is not running.[root@localhost ~]#      3、配置CentOS 6.0 第三方yum源(CentOS默认的标准源里没有nginx软件包)[root@localhost src]# wget http://www.atomicorp.com/installers/atomic  [root@localhost src]# sh ./atomic [root@localhost src]# yum check-update     4、安装开发包和库文件:    [root@localhost src]# 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     5、卸载已安装的Apache、MySQL、PHP;(分别执行)[root@localhost src]# yum remove httpd  [root@localhost src]# yum remove mysql[root@localhost src]# yum remove php    6、安装Nginx;[root@localhost src]# yum install nginx[root@localhost src]# service nginx start[root@localhost src]# chkconfig –levels 235 nginx on//设2、3、5级别开机启动    7、安装MySQL;[root@localhost src]# yum install mysql mysql-server mysql-devel[root@localhost src]# service mysqld start[root@localhost src]# chkconfig --levels 235 mysqld on    登录MySQL,删除空用户及修改用户密码;[root@localhost src]# mysql -uroot -pEnter password:Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 2Server ver<div style="color:transparent">!本文来源gaodai.ma#com搞#代!码(网</div><em>搞gaodaima代码</em>sion: 5.5.55 MySQL Community Server (GPL) by AtomicorpCopyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> use mysql Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changed //查看mysql用户信息;mysql>select user,host,password from mysql.user;//删除空用户;mysql> drop user ''@localhost;Query OK, 0 rows affected (0.00 sec) mysql> delete from user where user = '';Query OK, 1 row affected (0.00 sec) //更新用户密码;mysql> update mysql.user set password = password('root') where user='root';Query OK, 4 rows affected (0.00 sec)Rows matched: 4  Changed: 4  Warnings: 0//授权:允许root用户用root密码登录,*.*表示哪个库的哪个表;%从哪个IP地址访问;mysql>  grant all privileges on *.* to root@'%' identified by 'root' with grant option;Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)//更新数据库生效;mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)//退出 mysql> exit;Bye    8、安装PHP; [root@localhost src]# 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模式;[root@localhost src]# yum install  php-tidy php-common php-devel php-fpm php-mysql     //启动PHP服务和设置开机启动;[root@localhost src]# service php-fpm startStarting php-fpm: No log handling enabled - turning on stderr loggingCreated directory: /var/lib/net-snmp/mib_indexes                                                           [  OK  ][root@localhost src]# chkconfig --levels 235 php-fpm on[root@localhost src]#     9、配置Nginx,支持PHP;[root@localhost wwwroot]# cd /etc/nginx/conf.d/[root@localhost conf.d]# vi default.conf //配置文件如下:server {    listen       80;    server_name localhost;    location / {        root   /home/wwwroot;        index  index.html index.htm index.php;        if (!-e $request_filename){            rewrite ^(.*)$ /index.php?s=$1 last;        }    }    error_page   500 502 503 504  /50x.html;    location = /50x.html {        root   /usr/share/nginx/html;    }    location ~ \.php$ {        root           /home/wwwroot;        fastcgi_pass   127.0.0.1:9000;        fastcgi_index  index.php;        include        fastcgi_params;        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;        set $path_info "";        set $fastcgi_script_name_new $fastcgi_script_name;        if ($fastcgi_script_name ~*   "^(.+\.php)(/.+)$"  ) {                set $fastcgi_script_name_new $1;                set $path_info $2;         }        fastcgi_param   SCRIPT_FILENAME   $document_root$fastcgi_script_name_new;        fastcgi_param   SCRIPT_NAME   $fastcgi_script_name_new;        fastcgi_param   PATH_INFO $path_info;    }}    10、重启Nginx和php-fpm;[root@localhost conf.d]# service nginx restartStopping nginx:                                            [  OK  ]Starting nginx:                                            [  OK  ][root@localhost conf.d]# service php-fpm restartStopping php-fpm:                                          [  OK  ]Starting php-fpm:                                          [  OK  ][root@localhost conf.d]#      11、测试,在Nginx解析的目录下创建info.php文件,并在浏览器访问http://localhost/info.php,查看是否显示PHP页面;//info.php文件内容如下:<?php    phpinfo();?>

相关推荐:

基于CentOS 6.5操作系统搭建MongoDB服务

以上就是基于CentOS6.5的LNMP环境手工搭建的详细内容,更多请关注搞代码gaodaima其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:基于CentOS6.5的LNMP环境手工搭建
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址