centos7安装lnmp
一、配置CentOS 第三方yum源(CentOS默认的标准源里没有nginx软件包)
[root@localhost ~]# yum install wget #安装下载工具wget [root@localhost ~]#wget http://www.atomicorp.com/installers/atomic #下载atomic yum源 [root@localhost ~]#sh ./atomic #安装 [root@localhost ~]# yum check-update #更新yum软件包
二、安装开发包和库文件
[root@localhost ~]# 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
三、卸载已安装的apache、mysql、php
[root@localhost ~]# yum remove httpd[root@localhost ~]# yum remove mysql[root@localhost ~]# yum remove php
四、安装nginx
[root@localhost ~]# yum install nginx -y[root@localhost ~]# systemctl start nginx.service[root@localhost ~]# systemctl status nginx.service[root@localhost ~]# systemctl enable nginx.serviceCreated symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.[root@localhost ~]#
五、安装mariadb
[root@localhost ~]# yum install mariadb-devel mariadb mariadb-server[root@localhost ~]# systemctl start mariadb.service[root@localhost ~]# systemctl status mariadb.service● mariadb.service - MariaDB database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) Active: active (running) since Sat 2017-12-23 10:37:58 HKT; 4s ago Process: 18474 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS) Process: 18395 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS) Main PID: 18473 (mysqld_safe) CGroup: /system.slice/mariadb.service ├─18473 /bin/sh /usr/bin/mysqld_safe --basedir=/usr └─18635 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/... Dec 23 10:37:56 localhost.localdomain mariadb-prepare-db-dir[18395]: MySQL manual for more instructions.Dec 23 10:37:56 localhost.localdomain mariadb-prepare-db-dir[18395]: Please report any problems at http://mariadb.org/jiraDec 23 10:37:56 localhost.localdomain mariadb-prepare-db-dir[18395]: The latest information about MariaDB is available at http://mar...org/.Dec 23 10:37:56 localhost.localdomain mariadb-prepare-db-dir[18395]: You can find additional information about the MySQL part at:Dec 23 10:37:56 localhost.localdomain mariadb-prepare-db-dir[18395]: http://dev.mysql.comDec 23 10:37:56 localhost.localdomain mariadb-prepare-db-dir[18395]: Consider joining MariaDB's strong and vibrant community:Dec 23 10:37:56 localhost.localdomain mariadb-prepare-db-dir[18395]: https://mariadb.org/get-involved/Dec 23 10:37:56 localhost.localdomain mysqld_safe[18473]: 171223 10:37:56 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.Dec 23 10:37:56 localhost.localdomain mysqld_safe[18473]: 171223 10:37:56 mysqld_safe Starting mysqld daemon with databases from /v.../mysqlDec 23 10:37:58 localhost.localdomain systemd[1]: Started MariaDB database server.Hint: Some lines were ellipsized, use -l to show in full.[root@localhost ~]# systemctl enable mariadb.serviceCreated symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service
#为root账户设置密码[root@localhost ~]#mysql_secure_installation #初始化MySQLEnter current password for root (enter for none): <---输入现在的root密码,因为我们还没设置,直接回车Set root password? [Y/n] Y <---是否设定root密码,当然设置了,输入Y回车New password: <---输入root密码,并回车,输入的过程中不会有任何显示Re-enter new password: <---再次输入root密码,并回车,输入的过程中不会有任何显示Remove anonymous users? [Y/n] Y <---是否删除匿名用户,删除,输入Y回车Disallow root login remotely? [Y/n] Y <---是否删禁止root用户远程登录,当然禁止,输入Y回车Remove test database and access to it? [Y/n] <---是否删除测试数据库test,看个人喜好Reload privilege tables now? [Y/n] Y <---刷新权限,输入Y回车最后出现:Thanks for using MySQL!MySql密码设置完成,重新启动 MySQL:
六、安装php
[root@localhost ~]# yum -y install php 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 ~]# yum install php-tidy php-common php-devel php-fpm php-mysql -y[root@localhost ~]# systemctl start php-fpm.service[root@localhost ~]# systemctl status php-fpm.service● php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled) Active: active (running) since Sat 2017-12-23 10:53:59 HKT; 4s ago Main PID: 18953 (php-fpm) Status: "Ready to handle connections" CGroup: /system.slice/php-fpm.service ├─18953 php-fpm: master process (/etc/php-fpm.conf) ├─18955 php-fpm: pool www ├─18956 php-fpm: pool www ├─18957 php-fpm: pool www ├─18958 php-fpm: pool www └─18959 php-fpm: pool www Dec 23 10:53:59 localhost.localdomain systemd[1]: Starting The PHP FastCGI Process Manager...Dec 23 10:53:59 localhost.localdomain systemd[1]: Started The PHP FastCGI Process Manager.[root@localhost ~]# [root@localhost ~]# systemctl enable php-fpm.serviceCreated symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.[root@localhost ~]#
七、配置nginx支持php
[root@localhost ~]# cp /etc/nginx/nginx.conf{,.bak} #将配置文件改为备份文件 #修改nginx配置文件,添加fastcgi支持[root@localhost ~]# vim /etc/nginx/nginx.confvim /etc/nginx/nginx.conf #编辑user nginx nginx; #修改nginx运行账号为:nginx组的nginx用户:wq! #保存退出 [root@localhost nginx]# vim /etc/nginx/conf.d/default.conf location / { root /usr/share/nginx/html; index index.php index.html index.htm; #增加index.php } 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; include fastcgi_params; }
八、配置php
[root@localhost nginx]# cp /etc/php.ini{,.bak}[root@localhost nginx]#vim /etc/php.ini expose_php = Off #禁止显示php版本的信息
九、重启nginx php-fpm
[root@localhost ~]# systemctl restart nginx.service [root@localhost ~]# systemctl restart php-fpm.service
十、测试
[root@localhost ~]# cd /usr/share/nginx/html/ [root@localhost html]# vim index.php <?phpphpinfo(); ?> [root@localhost html]# chown nginx.nginx /usr/share/nginx/html/ -R #设置目录所有者
#配置防火墙,开启80端口、3306端口
[root@localhost html]# firewall-cmd --zone=public --add-port=80/tcp --permanent success [root@localhost html]# firewall-cmd --zone=public --add-port=3306/tcp --permanent success [root@localhost html]# systemctl restart firewalld.service [root@localhost html]# systemctl enable firewalld.service
在客户端浏览器输入服务器IP地址,可以看到相关的配置信息!
#############################################################################
备注
nginx默认站点目录是:/usr/share/nginx/html/ 权限设置:chown nginx.nginx/usr/share/nginx/html/ -R MySQL数据库目录是:/var/lib/mysql 权限设置:chown mysql.mysql -R /var/lib/mysql
参考:
https://www.cnblogs.com/xiaoit/p/3991037.html
http://www.kuitao8.com/20150305/3571.shtml
转载于:https://www.cnblogs.com/zhongguiyao/p/8092928.html
centos7安装lnmp相关推荐
- Centos7 安装lnmp
Centos7 安装lnmp 1.下载 wget http://soft.vpser.net/lnmp/lnmp1.5-full.tar.gz 2.解压 tar -zvxf lnmp1.5-full. ...
- CentOS7 安装LNMP(Linux+Nginx+MySQL+PHP)
安装make: yum -y install gcc automake autoconf libtool make 安装g++: yum install gcc gcc-c++ 1.选定源码目录 可以 ...
- CENTOS7 安装LNMP环境
------仅作为自己学习留存------ CENTOS 7.6/NGINX1.14.0/MYSQL8/PHP7.2 安装编译器 [root@VM-0-16-centos home]# yum ins ...
- centos7.0 lamp mysql_CentOS7 yum安装LNMP以及LAMP
简单记录在CentOS7下yum安装LNMP以及LAMP的过程. 首先配置防火墙 CentOS 7.0默认使用的是firewall作为防火墙 1.关闭firewall: systemctl stop ...
- Centos7下使用yum安装lnmp zabbix3.2
1:配置epel-release mysql zabbix 源 配置epel源 wget http://mirrors.aliyun.com/epel/epel-release-latest-7.no ...
- CentOS7下安装lnmp一键安装包
上一篇说到CentOS7无法使用yum安装,把这个问题解决后,就开始安装环境lnmp一键安装包,建议新手还是选择lnmp一键安装包吧,至于为什么?大家都懂,省心省事省时间没毛病! 首先输入命令检查一下 ...
- centos 编译nginx php mariadb,centos7安装nginx+mariadb+php-fpm
由 dp7f1f9f 创建,最后一次修改 2017-05-22 用CentOS-7-x86_64-Minimal-1611.iso最小化安装一个centos7,安装选项:英文.时区为上海.启用网络(如 ...
- 【转】Magento2 安装系列一 虚拟机、CentOS7 安装
前言 最近打算在Windows10安装最新的magento2.3,由于mg2.3对Windows支持不太友好,所以就打算在Windows10安装虚拟机,虚拟机安装CentOS7版本的Linux,Lin ...
- CentOS6.9编译安装LNMP环境
CentOS6.9编译安装LNMP环境 今天尝试一下用编译的方式来搭建lnmp运行环境.所有软件都采用当前最新版本,除了CentOS.这是由于目前企业大多数应该都还在使用CentOS6的缘故,并且Ce ...
- CentOS 7.6编译安装LNMP
一.前期准备 1.服务器以最小化方式安装CentOS 7.6 2.配置本地源及安装epel源 #cd /etc/yum.repos.d #vi CentOS-Base.repo 增加enable=1 ...
最新文章
- LVS原理详解(3种工作方式8种调度算法)--老男孩
- 贪心 ---- Educational Codeforces Round 90 (Rated for Div. 2)D Maximum Sum on Even Positions[偶数子段最大和]
- counterfactual
- 百度地图infoWindow圆角处理
- 【转】BMP图像文件格式
- transferto 文件不存在_文件上传时,MultipartFile.transferTo() 方法报 FileNotFoundException...
- (原)PyTorch中使用指定的GPU
- python排大小函数_python numpy 一些函数 大小排序和统计
- Mybatis获取已经赋值,没有问号的Sql
- PyTorch 1.6 发布:原生支持自动混合精度训练并进入稳定阶段
- WinForm 设置窗体启动位置在活动屏幕右下角
- 常用排序算法的python实现
- 《博客园精华集》web标准分册第2论筛选结果文章列表
- 使用GHOST打包制作gho镜像文件
- 怎么完全卸载赛门铁克_如何无密码卸载Symantec杀毒软件
- 全球40个免费电子图书馆网址~收藏
- KeilC51单片机外部中断原理解释
- 1941. Scary Martian Word
- R语言-豆瓣电影top250数据爬取和分析
- 楚门的世界/The Truman Show (1998)
热门文章
- 基本操作?这46个 Linux 面试常见问题送给你
- 运维,你是选择25k的996还是18k的八小时工作日?
- 验签传时间戳目的_不瞒你说:买来的海鸭蛋,一戳就流油,被中央台频频“曝光”,秘密终被解开...
- wifi共享大师电脑版_【小度wifi驱动下载】小度wifi驱动win10官方下载 v3.1 电脑版...
- 百度地图手机端单触点单击和长按事件,解决部分手机(小米手机)地图单击事件失效,多触点、拖动依然触发长按的bug...
- C++线程中packaged_tack
- Android学习Matrix对称变换5
- XmlAttribute与实体的转换和匹配方案(附源码)
- hdu2844 Coins -----多重背包+二进制优化
- learning scala 变量