centos 安装ngnix mysql php

Posted 正义的棒棒糖

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos 安装ngnix mysql php相关的知识,希望对你有一定的参考价值。

Centos7 nginx mysql php
# 查看版本号
cat /etc/redhat-release
#1. 安装工具
yum install -y make apr* autoconf cmake automake curl-devel gcc gcc-c++ openssl openssl-devel pcre-devel gd kernel keyutils perl kernel-headers mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* ncurses* libtool* libxml2 libxml2-devel patch bzip2-devel telnet jasper-devel libtiff-devel gtk+-devel wget
 
#2. 安装php
yum install -y php php-common php-devel php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash php-fpm php-json* php-soap php-process
php -v
php --ini
curl -Ss http://www.workerman.net/check.php | php
yum install libevent-devel -y
pecl install event
echo extension=event.so > /etc/php.d/30-event.ini
systemctl enable php-fpm.service
systemctl start php-fpm.service
 
#3. 安装nginx
wget http://tengine.taobao.org/download/tengine-2.2.1.tar.gz
tar -zxf tengine-2.2.1.tar.gz
cd tengine-2.2.1
./configure
make
make install
 
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -s reload
 
#4. 安装mysql
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server
systemctl start mysqld.service
systemctl enable mysqld.service
#mysqladmin password
 
安装mariadb,代替mysql
yum install mariadb-server.x86_64
systemctl enable mariadb.service
systemctl start mariadb.service
grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘password‘;
flush privileges;
 
#5.允许ssh密码登录
vi /etc/ssh/sshd_config
systemctl restart sshd.service
 
#6. 关闭selinux
vim /etc/selinux/config
修改为:SELINUX=disabled
 
#7. 防火墙修改
#启动防火墙
systemctl enable firewalld.service
#添加
firewall-cmd --zone=public --add-port=10000/tcp --permanent
firewall-cmd --zone=public --add-port=8282/tcp --permanent
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --zone=public --add-port=9990/tcp --permanent
systemctl restart firewalld.service
#查看
firewall-cmd --list-ports
 
Ubuntu 16.04 apach2 php7 mysql
sudo apt install php php-dev php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mcrypt libmcrypt4 libmcrypt-dev php-fpm php-json php-json-patch php-json-schema php-soap php-curl
sudo apt install apache2
 
cd /etc/apache2/mods-enabled
ln -sf ../mods-available/rewrite.load rewrite.load
vi /etc/apche2/apache2.conf
修改为以下部分为:
<Directory />
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
 
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
 
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

以上是关于centos 安装ngnix mysql php的主要内容,如果未能解决你的问题,请参考以下文章

lnmp配置(linux(centos7).ngnix.mariadb.php(php-fpm,phpmyadmin))

Linux学习--CentOS7 安装好MySQL及Apache后,宿主机无法打开网页

CentOS 6.5下源码安装LAMP(Linux+Apache+Mysql+Php)环境

CentOS7基于Apache+php+mysql的许愿墙网站的搭建

Linux精华篇—CentOS 7.4下源码编译构建LNMP架构

centOS7安装php7报错误