yum配置源

使用nginx官方源

新建文件/etc/yum.repos.d/nginx.repo,内容如下:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

使用remi源

  • 追加CentOS 6.5的epel及remi源
    rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
    rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
  • CentOS 7.0的源。
    yum install epel-release -y
    rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

安装

安装nginx

yum install -y nginx

安装mysql

CentOS 6
yum install --enablerepo=remi -y mysql mysql-server

CentOS 7
CentOS 7上把MySQL从默认软件列表中移除了,用MariaDB来代替。
yum -y install mariadb mariadb-server mariadb-libs

安装php,php-fpm及php常用扩展

yum install --enablerepo=remi --enablerepo=remi-php56 -y php php-bcmath php-cli php-common php-devel php-fpm php-gd php-imap php-ldap php-mbstring php-mcrypt php-mysqlnd php-pdo php-pear php-pecl-igbinary php-xml php-xmlrpc php-opcache php-intl php-pecl-memcache php-redis

配置

配置nginx

vim /etc/nginx/conf.d/default.conf

location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
location ~ \.php$ {
    root           /usr/share/nginx/html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

配置mysql

启动并设置开机自启动

CentOS6

service nginx start
service php-fpm start
service mysqld start
chkconfig nginx on
chkconfig php-fpm on
chkconfig mysqld on

CentOS7

systemctl start nginx
systemctl enable nginx
systemctl start php-fpm
systemctl enable php-fpm
systemctl start mariadb
systemctl enable mariadb

目录

  • 默认nginx网页根目录: /usr/share/nginx/html
分类: 运维

0 条评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注