centos7搭建LAMP

lsb_release -a 查看系统版本

添加系统用户以及添加sudo权限

创建新用户username

useradd username

给用户设置密码

passwd username

给username用户设置sudo权限

首先找到文件位置,示例中文件在/etc/sudoers位置。

 whereis sudoers

强调内容 修改文件权限,一般文件默认为只读。

ls -l /etc/sudoers 查看文件权限
chmod -v u+w /etc/sudoers 修改文件权限为可编辑

修改文件,在如下位置增加一行,保存退出。

vim /etc/sudoers                 进入文件编辑器
文件内容改变如下:
root ALL=(ALL) ALL               已有行
username ALL=(ALL) ALL           新增行

记得将文件权限还原回只读。

ls -l /etc/sudoers 查看文件权限
chmod -v u-w /etc/sudoers 修改文件权限为只读

apache用户以username权限执行git、php、bash命令(根据是否需要设置)

root ALL=(ALL) ALL                                                       已有行
username ALL=(ALL) ALL                                                   新增行
apache ALL=(username) NOPASSWD: /usr/bin/git, /usr/bin/php, /bin/bash    新增行

B站更新需要,apache用户以username权限执行git、php、bash命令

username ALL=(ALL) ALL
apache ALL=(username) NOPASSWD: /usr/bin/git, /usr/bin/php, /bin/bash

apache安装

写在前面 : apache中虚拟站点指向的目录的上级必须是755 如/home/wwb/website,那么home与wwb与website都必须是755,而不是只设置/home/yyz/website就行了 这样的话会报错403

sudo yum install httpd
sudo systemctl restart httpd

安装mysql初始化root密码并新建mysql用户

MySQL5.6 rpm包

sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
sudo yum install mysql mysql-server
sudo service mysqld start

修改密码

方式一

mysql -u root mysql
use mysql
update user set Password=password('6Cgooyy9alv') where user='root';

方式二

mysql_secure_installation

重启

sudo service mysqld restart

建立mysql用户

GRANT USAGE ON *.* TO 'beta'@'localhost' IDENTIFIED BY 'beta123456' WITH GRANT OPTION;
#分配mysql用户权限
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER  ON pe762_beta.* TO 'beta'@'localhost';

安装php5.6

追加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
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

安装php拓展

yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-gd php-redis

安装php-fpm拓展

yum install --enablerepo=remi --enablerepo=remi-php56 php-fpm

apache中配置mysql

#进入apache的配置文件中查看是否含有以下配置 若无添加

LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

DirectoryIndex index.html index.php


apache虚拟站点配置


    DocumentRoot "/home/wwb/website/project/web"
    ServerName www.hehe.cn
    DirectoryIndex app.php
    
           Options Indexes FollowSymLinks
           AllowOverride All
           Require all granted
   

    ErrorLog /home/yyz/website/project-error_log
    CustomLog /home/yyz/website/project-access_log common

安装与配置git

sudo yum install -y git
ssh-keygen -t rsa -C git@account"
cat ~/.ssh/id_rsa.pub #此处将获取的公钥复制下来后登录码云在公钥进行设置(详情查看git帮助文档https://gitee.com/help/articles/4181#article-header0)

你可能感兴趣的:(linux)