yum install -y epel-release
yum clean all && yum makecache
yum install -y nginx
nginx -v 查看是否安装成功
service nginx reload 重启服务
nginx 的配置文件目录 /etc/nginx/nginx.conf
根目录 root /usr/share/nginx/html;
systemctl status -l nginx.service是否激活
二.安装mysql(mariadb)
yum install -y mariadb-server
yum install mariadb*
安装完成MariaDB,首先启动MariaDB
systemctl start mariadb
设置开机启动systemctl enable mariadb
接下来进行MariaDB的相关简单配置:
首先是设置密码,会提示先输入密码mysql_secure_installation
出现
Enter current password for root (enter for none):<–初次运行直接回车
设置密码
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
其他配置
Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车,
Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
测试登录
mysql -uroot -ppassword
常用指令
mariadb数据库的启动命令是:
systemctl start mariadb #启动MariaDB
systemctl stop mariadb #停止MariaDB
systemctl restart mariadb #重启MariaDB
systemctl enable mariadb #设置开机启动
三.安装php
php 7.0有两个源可以选择,一个是webtatic提供的,也就是php70w,那个w指得就是webtatic,这个源数据传输很慢,另一个可以使用remi源
本来想通过下面的方式安装的PHP的,可是webtatic的PHP的yum源获取不了,网站ping mirror.webtatic.com显示无主机
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel
另外的方法
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum --enablerepo=remi update remi-release
yum --enablerepo=remi-php70
# 搜索PHP
yum search php70 安装自己想要的拓展
# 各取所需
yum install php70 php70-php-devel php70-php-fpm php70-php-mbstring php70-php-mcrypt php70-php-mysqlnd php70-php-gd php70-php-opcache php70-php-pdo php70-php-json php70-php-xml php70-php-pecl-xdebug php70-php-pecl-zip php70-php-pecl-redis php70-php-pecl-memcached php70-php-pecl-swoole
yum install -y memcached redis
查看是否安装成功 php70 -v
四.配置nginx可以调用PHP解析器打开PHP文件
vi /etc/nginx/nginx.conf
Nginx.conf配置
location ~* \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
查看是否9000端口被php-fpm占用:
netstat -tunpl | grep 9000
php-cgi -b 127.0.0.1:9000 &