配置网卡
配置本地yum
1 cd /etc/yum.repos.d/
2 ls
3 rm -rf *
4 vi dvd.repo
5 mkdir /111
6 mount /dev/cdrom /111
连接xshell
下载lrzsz
yum -y install lrzsz
创建目录/data/sevser /data/scripts
安装gcc gcc-c++(出现下面这种情况,说明你本来就有)
安装nginx
上传nginx包
解包
tar -xzvf nginx-1.6.0.tar.gz -C /usr/local/src
安装oppenssl(openssl软件包是用于提供网站加密证书服务的程序文件,在安装该程序时需要自定义服务程序的安装目录,以便于稍后调用它们的时候更可控。)
[root@localhost data]# yum -y install openssl-devel
创建并设置nginx运行账号
[root@localhost data]# groupadd nginx
[root@localhost data]# useradd -M -g nginx -s /sbin/nologin nginx
编译安装(到/data/servernginx目录里)
[root@localhost nginx-1.6.0]# ./configure --prefix=/data/server/nginx --user=nginx --group=nginx
make && make install
设置nginx为系统服务
vim /lib/systemd/system/nginx.service
文件内容
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/data/server/nginx/sbin/nginx
ExecReload=/data/server/nginx/sbin/nginx -s reload
ExecStop=/data/server/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
创建软链接
[root@localhost nginx-1.6.0]# ln -s /data/server/nginx/sbin/nginx /usr/local/sbin
开启nginx服务:
systemctl start nginx.service
查看nginx是否启动成功:
systemctl status nginx
[root@localhost nginx-1.6.0]# systemctl status nginx
● nginx.service - nginx
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2019-12-25 14:19:06 CST; 2min 57s ago
Process: 8297 ExecStart=/data/sevser/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
Main PID: 8298 (nginx)
CGroup: /system.slice/nginx.service
├─8298 nginx: master process /data/sevser/nginx/sbin/nginx
└─8299 nginx: worker process
Dec 25 14:19:06 localhost.localdomain systemd[1]: Starting nginx…
Dec 25 14:19:06 localhost.localdomain systemd[1]: Started nginx.
关闭防火墙
[root@localhost server]# iptables -F
网页验证
安装Mysql
卸载已有mysql
查看是否已安装mysql:
rpm -qa mysql
有则卸载:
rpm -e --nodeps 文件名称
是否存在与mysql相关的文件或目录:
whereis mysql
是则删除。
查看是否存在mariadb:
rpm -qa | grep mariadb
存在则卸载:
rpm -e --nodeps 文件名 //文件名是上一个命令查询结果
存在/etc/my.cnf,则需要先删除:
rm /etc/my.cnf
安装编译mysql需要的依赖包
yum install libevent* libtool* autoconf* libstd* ncurse* bison* openssl*
安装cmake(mysql5.5之后需要用cmake支持编译安装
)
yum -y install cmake
上传mysql安装包并解包
tar -xzvf mysql-5.6.19.tar.gz -C /usr/local/src/
编译安装/data/sever/mysql
cmake -DCMAKE_INSTALL_PREFIX=/data/sevser/mysql -DMYSQL_DATADIR=/data/sevser/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make && make install
配置mysql
groupadd mysql
useradd -M -g mysql -s /sbin/nologin mysql
chown -R mysql:mysql /data/sevser/mysql
初始化配置
cd /data/sevser/mysql/scripts
./mysql_install_db --basedir=/data/sevser/mysql --datadir=/data/sevser/mysql/data --user=mysql
设置mysql为系统服务
vim /lib/systemd/system/mysql.service
文件内容:
[Unit]
Description=mysql
After=network.target
[Service]
Type=forking
ExecStart=/data/sevser/mysql/support-files/mysql.server start
ExecStop=/data/sevser/mysql/support-files/mysql.server stop
ExecRestart=/data/sevser/mysql/support-files/mysql.server restart
ExecReload=/data/sevser/mysql/support-files/mysql.server reload
PrivateTmp=true
[Install]
WantedBy=multi-user.target
创建软连接
[root@localhost scripts]# ln -s /data/sevser/mysql/bin/* /usr/local/bin/
启动mysql
systemctl start mysql.service
查看mysql
systemctl status mysql
安装php
.
安装php依赖包
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-deve
若提示yum中没有可用的软件包libmcrypt和libmcrypt-devel,则需要手动编译安装,可以先在windows宿主主机中前往libmcrypt官网下载然后使用rz指令将包上传至centos7进行编译安装。我下载的包为libmcrypt-2.5.8.tar.gz:
tar -zxvf libmcrypt-2.5.8.tar.gz -C /usr/local/src
cd /usr/local/src/libmcrypt-2.5.8/
./configure --prefix=/data/sevser/libmcrypt
make && make install
上传php包并释放
tar -zxvf php-7.2.0.tar.gz -C /usr/local/src/
编译安装(到/data/sevser/php目录)
./configure --prefix=/data/sevser/php --disable-fileinfo --enable-fpm --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-openssl --with-zlib --with-curl --enable-ftp --with-gd --with-xmlrpc --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-mbstring --with-mcrypt=/usr/local/libmcrypt --enable-zip --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --without-pear --enable-bcmath
make && make install
~~创建软连接~
~
ln -s /data/sevser/php/sbin/php-fpm /usr/local/sbin
将php包解压目录中的配置文件放置到正确位置(configure命令中的–with-config-file-path设置的位置)
cd /usr/local/src/php-7.2.0/
cp php.ini-development /etc/php.ini
创建并设置php-fpm运行账号
groupadd www-data
useradd -M -g www-data -s /sbin/nologin www-data
cd /data/sevser/php/etc
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
发现搜索不到“user”(设置运行账号的位置),但发现文件的最后一行:
cd php-fpm.d
cp www.conf.default www.conf(否则include匹配不到文件)
vim www.conf
25 user=www-data
26 group=www-data
.配置nginx支持php
vim /data/sevser/nginx/conf/nginx.conf
把45行改成index index.php index.html index.htm;
65到71行的#号删除
69会写成
69 fastcgi_param SCRIPT_FILENAME fastcgi_script_name;
设置php-fpm为系统服务
vim /etc/systemd/system/php-fpm.service
内容
[Unit]
Description=php-fpm
After=network.target
[Service]
Type=forking
ExecStart=/data/sevser/php/sbin/php-fpm
PrivateTmp=True
[Install]
WantedBy=multi-user.target
启动php-fpm
[root@localhost php-fpm.d]# systemctl start php-fpm.service
验证
[root@localhost php-fpm.d]# systemctl status php-fpm.service
写一个php脚本测试nginx是否已支持php,php是否已支持mysql。
[root@localhost php-fpm.d]# cd /data/sevser/nginx/html
[root@localhost html]# vim index.php
写入
上百度
来源:CSDN
作者:weixin_45835451
链接:https://blog.csdn.net/weixin_45835451/article/details/103680308