本文共 2739 字,大约阅读时间需要 9 分钟。
#首先删除httpdyum -y remove httpd#安装仓库源yum -y install epel-releaseyum -y install nginx mysql mysql-server php php-fpm php-mysql #lnmp常用的包yum -y install php-gd php-mbstring php-xml #php可选的扩展包#查看php版本:默认是php5.3[root@c6 www]# php -vPHP 5.3.3 (cli) (built: Nov 1 2019 12:28:08) Copyright (c) 1997-2010 The PHP GroupZend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
nginx配置fastcgi官方示例:
#启动mysql[root@c6 ~]# service mysqld start[root@c6 ~]# mysqladmin -uroot password '123456';#启动php-fpm: fastcgi 程序,默认端口9000[root@c6 ~]# service php-fpm start[root@c6 ~]# ss -nltp |grep 9000LISTEN 0 128 127.0.0.1:9000 *:* users:(("php-fpm",6119,7),("php-fpm",6120,0),("php-fpm",6121,0),("php-fpm",6122,0),("php-fpm",6123,0),("php-fpm",6124,0))#查看nginx配置[root@c6 ~]# ls /etc/nginx/conf.d koi-utf scgi_paramsdefault.d koi-win scgi_params.defaultfastcgi.conf mime.types uwsgi_paramsfastcgi.conf.default mime.types.default uwsgi_params.defaultfastcgi_params nginx.conf win-utffastcgi_params.default nginx.conf.default[root@c6 ~]# ls /etc/nginx/conf.d/default.conf.bak proxy.conf.bak virtual.confmyfashcgi.conf ssl.conf web.conf.bak[root@c6 ~]# cat /etc/nginx/conf.d/myfashcgi.conf server { listen 80; server_name c6; location ~ \.php$ { root /data/www; #fastcgi_pass unix:/tmp/php-fpm.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; include fastcgi_params; }}
[root@c6 ~]# grep listen /etc/php-fpm.d/www.conf; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on; 'port' - to listen on a TCP socket to all addresses on a; '/path/to/unix/socket' - to listen on a unix socket.#listen = 127.0.0.1:9000listen = /tmp/php-fpm.sock; Set listen(2) backlog. A value of '-1' means unlimited.;listen.backlog = -1; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each addresslisten.allowed_clients = 127.0.0.1;listen.owner = nobody;listen.group = nobody;listen.mode = 0666
#测试lnmp环境[root@c6 ~]# ls /data/www/index.html index.php mysql.php[root@c6 ~]# cat /data/www/index.php [root@c6 ~]# cat /data/www/mysql.php [root@c6 ~]# curl localhost/index.php |head % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 51216 0 51216 0 0 31.8M 0 --:--:-- --:--:-- --:--:-- 48.8M
转载地址:http://xcdef.baihongyu.com/