首页 > 代码库 > lnmp搭建
lnmp搭建
一,安装php
1,列出php php-fpm是否存在
yum list php php-fpm
2,安装
yum -y install php php-fpm
3,启动php-fpm:
/etc/init.d/php-fpm start
service php-fpm start
二,安装ngnix
yum list nginx
yum -y install ngnix
service nginx start #启动nginx进程方法[1]
/etc/init.d/nginx start #启动nginx进程方法[2]
ps -ef | grep nginx #查看nginx进程
修改nginx配置文件,如下
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘
# ‘$status $body_bytes_sent "$http_referer" ‘
# ‘"$http_user_agent" "$http_x_forwarded_for"‘;
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
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 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$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; #$script需改为/usr/share/nginx/html
include fastcgi_params;
}
# deny access to .htaccess files, if Apache‘s document root
# concurs with nginx‘s one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
# }
}
三,安装mysql(cetos7以上安装mariadb)
yum install mysql
yum install mysql-service -y
service mysqld start
mysql 进入数据库
设置mysql允许远程访问
在mysql数据库的user表中添加以下数据
INSERT INTO `user` ( `Host` , `User` , `Password` , `Select_priv` , `Insert_priv` , `Update_priv` , `Delete_priv` , `Create_priv` , `Drop_priv` , `Reload_priv` , `Shutdown_priv` , `Process_priv` , `File_priv` , `Grant_priv` , `References_priv` , `Index_priv` , `Alter_priv` , `Show_db_priv` , `Super_priv` , `Create_tmp_table_priv` , `Lock_tables_priv` , `Execute_priv` , `Repl_slave_priv` , `Repl_client_priv` , `ssl_type` , `ssl_cipher` , `x509_issuer` , `x509_subject` , `max_questions` , `max_updates` , `max_connections` ) VALUES (‘%‘, ‘root‘, PASSWORD( ‘myadmin‘ ) , ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘‘, ‘‘, ‘‘, ‘‘, ‘0‘, ‘0‘, ‘0‘);
刷新权限
flush privileges;
yum -y install php-mysql #安装php-mysql 扩展
service php-fpm restart #重启php-fpm进程
lnmp搭建