LNMP环境的安装(yum安装)

  • 2019-09-02
  • 0
  • 0

1、 使用官方仓库安装Nginx

[root@ljc ~]# vim /etc/yum.repos.d/nginx.repo 
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

#安装Nginx
[root@ljc ~]# yum install nginx -y

2.安装php7.1

[root@ljc ~]# yum remove php-mysql-5.4 php php-fpm php-common
[root@ljc ~]# vim /etc/yum.repos.d/php.repo
[php]
name = php Repository
baseurl = http://us-east.repo.webtatic.com/yum/el7/x86_64/
gpgcheck = 0

[root@ljc ~]# yum -y install php71w php71w-cli php71w-common \
php71w-devel php71w-embedded php71w-gd php71w-mcrypt \
php71w-mbstring php71w-pdo php71w-xml php71w-fpm \
php71w-mysqlnd php71w-opcache php71w-pecl-memcached \
php71w-pecl-redis php71w-pecl-mongodb

3.安装Mariadb数据库

[root@ljc ~]# yum install mariadb-server mariadb -y

4.配置nginx与php集成,修改配置文件

[root@ljc conf.d]# cat php.conf 
server {
    listen 80;
    server_name php.ljc.com;
    root /code;

    location / {
        index index.php index.html;
        }

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }
}

5.重载NGINX并加入开机自启

[root@nginx conf.d]# systemctl start nginx 
[root@nginx conf.d]# systemctl enable nginx

6.启动php-fpm,并加入开机自启

[root@ljc conf.d]# systemctl start php-fpm
[root@ljc conf.d]# systemctl enable  php-fpm

7.准备一个php文件,测试nginx与php是否集成成功

[root@ljc conf.d]# cat /code/page.php
<?php
    phpinfo();
?>

8.启动数据库并加入开机自启

[root@ljc conf.d]# systemctl start mariadb
[root@ljc conf.d]# systemctl enable mariadb

#给数据库设置一个密码
[root@ljc conf.d]# mysqladmin password '123'

评论

还没有任何评论,你来说两句吧

提供支持 - 友情链接 - 衫小寨