centos7之yum安裝lnmp

安裝LNMP之前要安裝EPEL,以便安裝源以外的軟件,如Nginx,phpMyAdmin等

yum install epel-release -y

安裝nginx

yum install nginx -y
systemctl start nginx
systemctl enable nginx

安裝php

yum install -y php php-devel php-fpm php-mysql php-common php-devel php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel
systemctl start php-fpm
systemctl enable php-fpm

安裝mysql

這裏不介紹了,可以參考我的源碼安裝,或者yum安裝在“系統監控”的zabbix教程裏面有

添加nginx配置

[root@jenkins ~]# cat /etc/nginx/conf.d/default.conf 
server {
    listen       80;
    server_name  10.0.40.245;

    root   /usr/share/nginx/html;

        location / {
            root   /usr/share/nginx/html;
            index index.php 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;
    }

    location ~ \.php$ {
        root           /usr/share/nginx/html;
        try_files $uri =404;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

}

重啓nginx即可

測試php是否正常運行

[root@jenkins ~]# cat /usr/share/nginx/html/index.php 
<?php

// Show all information, defaults to INFO_ALL
phpinfo();

// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);

?>

php官方文檔

web訪問index.php

10.0.40.245/index.php

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章