lamp平台搭建完整代码

1.查看电脑实际cpu 核数

Ctrl shift esc

安装虚拟机时 ctrl alt可以释放光标

  1. 配置网络

先查看虚拟机的网段以及网关 网关需要一致 IP需要在网段内

这里需要超级管理员模式打开软件 编辑-虚拟网络编辑器-

网关:192.168.92.2

vim   /etc/sysconfig/network-scripts/ifcfg-ens33

BOOTPROTO="static"

IPADDR=192.168.92.30

NETMASK=255.255.255.0

GATEWAY=192.168.92.2

DNS1=8.8.8.8

systemctl restart network

ping baidu.com

  1. 配置yum源

挂载失败的话:

没有添加磁盘 添加即可

刷新:

alias scan='echo "- - -" > /sys/class/scsi_host/host0/scan;echo "- - -" > /sys/class/scsi_host/host1/scan;echo "- - -" > /sys/class/scsi_host/host2/scan'

scan

mount /dev/cdrom /mnt/

cd /etc/yum.repos.d/

mkdir repos.bak

mv * repos.bak

vim local.repo

[local]

name=local

baseurl=file:///mnt

enabled=1

gpgcheck=0

priority=1

[online]

name=online

baseurl=https://mirrors.aliyun.com/epel/7Server/x86_64/

gpgcheck=0

enabled=1

priority=2

yum clean all && yum makecache

网络配置好了在线源才会生效不报错

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

安装mysql:

yum -y install gcc gcc-c++ ncurses ncurses-devel bison cmake

cd /opt

tar xf mysql-5.7.17.tar.gz

tar xf boost_1_59_0.tar.gz

mv  -f  boost_1_59_0 /usr/local/boost

cd /opt/mysql-5.7.17/

末尾\后面不能有空格

cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \

-DSYSCONFDIR=/etc \

-DSYSTEMD_PID_DIR=/usr/local/mysql \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_EXTRA_CHARSETS=all \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DWITH_BOOST=/usr/local/boost \

-DWITH_SYSTEMD=1 \

/opt/mysql-5.7.17

make -j 4 && make install  

useradd -M -s /sbin/nologin  mysql

vim /etc/my.cnf

[client]

port = 3307

socket=/usr/local/mysql/mysql.sock

auto-rehash

[mysql]

port = 3307

socket = /usr/local/mysql/mysql.sock

auto-rehash

[mysqld]

user = mysql

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

port = 3307

character-set-server=utf8

pid-file = /usr/local/mysql/mysqld.pid

socket=/usr/local/mysql/mysql.sock

bind-address = 0.0.0.0

skip-name-resolve

max_connections=4096

default-storage-engine=INNODB

max_allowed_packet=32M

server-id = 1

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES

chown -R mysql:mysql /usr/local/mysql/

chown mysql:mysql /etc/my.cnf

echo 'export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile

source /etc/profile

cd /usr/local/mysql/bin/

./mysqld \

--initialize-insecure \

--user=mysql \

--basedir=/usr/local/mysql \

--datadir=/usr/local/mysql/data

cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/

systemctl daemon-reload

systemctl start mysqld.service

systemctl enable mysqld

netstat -anpt | grep 3307

mysqladmin -u root password "abc123"

mysql  -uroot -pabc123 -P3307

grant all privileges on *.* to 'root'@'%' identified by 'abc123';

show databases;

quit

配置下载apache:

systemctl stop firewalld

systemctl disable firewalld

setenforce 0

cd /opt/

yum -y install gcc gcc-c++ make pcre pcre-devel expat-devel perl

tar xf apr-1.6.2.tar.gz

tar xf apr-util-1.6.0.tar.gz

tar xf httpd-2.4.29.tar.bz2

mv -f apr-1.6.2 /opt/httpd-2.4.29/srclib/apr

mv -f apr-util-1.6.0 /opt/httpd-2.4.29/srclib/apr-util

cd /opt/httpd-2.4.29/

./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi

make -j 4 && make install

ln -s /usr/local/httpd/conf/httpd.conf /etc/

ln -s /usr/local/httpd/bin/* /usr/local/bin/

cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd

chmod +x /etc/init.d/httpd

vi /etc/init.d/httpd

#!/bin/bash

# chkconfig: 35 85 21

# description: Apache is a World Wide Web server

chkconfig --add httpd

systemctl start httpd.service

vim /etc/httpd.conf

Esc 52G

Listen 192.168.92.30:80

Esc 197G

ServerName www.kgc.com:80

Esc 221G

DocumentRoot "/usr/local/httpd/htdocs"

Esc 255G

DirectoryIndex index.html

httpd -t

cat /usr/local/httpd/htdocs/index.html

systemctl restart httpd.service

netstat -anpt | grep 80

echo "192.168.92.30 www.wt.com" >> /etc/hosts

http://192.168.92.30

http://www.wt.com

PHP安装:

cd /opt

yum -y install \

gd \

libjpeg libjpeg-devel \

libpng libpng-devel \

freetype freetype-devel \

libxml2 libxml2-devel \

zlib zlib-devel \

curl curl-devel \

openssl openssl-devel

tar xf php-7.1.10.tar.bz2

cd /opt/php-7.1.10/

./configure \

--prefix=/usr/local/php7 \

--with-apxs2=/usr/local/httpd/bin/apxs \

--with-mysql-sock=/usr/local/mysql/mysql.sock \

--with-config-file-path=/usr/local/php7 \

--with-mysqli \

--with-zlib \

--with-curl \

--with-gd \

--with-jpeg-dir \

--with-png-dir \

--with-freetype-dir \

--with-openssl \

--enable-mbstring \

--enable-xml \

--enable-session \

--enable-ftp \

--enable-pdo \

--enable-tokenizer \

--enable-zip

make -j 4 && make install

cp /opt/php-7.1.10/php.ini-development  /usr/local/php7/php.ini

vim /usr/local/php7/php.ini

1170G

mysqli.default_socket = /usr/local/mysql/mysql.sock

939G

取消注释

date.timezone = Asia/Shanghai

ln -s /usr/local/php7/bin/* /usr/local/bin/

php -m

vim /etc/httpd.conf

393G

AddType application/x-httpd-php .php

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

255G

DirectoryIndex index.html index.php

/LoadModule php7_module        modules/libphp7.so

rm -rf /usr/local/httpd/htdocs/index.html

vim /usr/local/httpd/htdocs/index.php

phpinfo();

?>

systemctl restart httpd.service

http://192.168.92.30

安装论坛:

mysql  -uroot -pabc123 -P3307

CREATE DATABASE bbs;

GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123';

flush privileges;

show databases;

quit

unzip /opt/Discuz_X3.4_SC_UTF8.zip -d /opt/dis

cd /opt/dis/dir_SC_UTF8/

cp -r upload/ /usr/local/httpd/htdocs/bbs

ps aux | grep httpd

cd /usr/local/httpd/htdocs/bbs

chown -R daemon ./config

chown -R daemon ./data

chown -R daemon ./uc_client

chown -R daemon ./uc_server/data

http://192.168.92.30/bbs

http://192.168.92.30/bbs/admin.php

数据库服务器:localhost     

数据库名字:bbs

数据库用户名:bbsuser

数据库密码:admin123

管理员账号:admin

管理员密码:admin123

你可能感兴趣的:(linux,vim,运维)