折腾了好久的环境,终于搭出来了。现在总结一下!!!
vim /etc/selinux/config SELINUX=disabled * 若安装时没有禁用SELinux ,将enforcing改为disabled。修改后需重新启动Linux方可生效!
允许防火墙80(Nginx)、3306(MysqL)端口访问
vi /etc/sysconfig/iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT(允许80端口通过防火墙) -A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT(允许3306端口通过防火墙) 特别提示:很多网友把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败,正确的应该是添加到默认的22端口这条规则的下面
安装Nginx
1. 安装拓展:yum install wget gcc gcc-c++ pcre-devel zlib-devel openssl openssl-devel 2.cd /usr/local/ 3.下载Nginx:wget http://Nginx.org/download/Nginx-1.1.16.tar.gz 4.解压 tar -zxvf Nginx-1.1.16 5.取消Debug编译模式: cd Nginx-1.1.16 vi auto/cc/gcc #CFLAGS="$CFLAGS -g" #将这句注释掉 取消Debug编译模式 大概在172行
6.预编译:./configure --prefix=/usr/local/Nginx --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre --with-http_gzip_static_module --with-http_dav_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module
解释
--with-http_gzip_static_module :支持压缩
--with-http_stub_status_module :支持Nginx状态查询
--with-http_ssl_module :支持https
--with-pcre :为了支持rewrite重写功能,必须制定pcre
--with-http_dav_module #启用支持(增加PUT,DELETE,MKCOL:创建集合,copY和MOVE方法)
--with-http_addition_module #启用支持(作为一个输出过滤器,支持不完全缓冲,分部分相应请求)
--with-http_sub_module #启用支持(允许一些其他文本替换Nginx相应中的一些文本)
--with-http_flv_module #启用支持(提供支持flv视频文件支持)
--with-http_mp4_module #启用支持(提供支持mp4视频文件支持,提供伪流媒体服务端支持)
7.make && make install
8.添加系统变量:
vim /etc/profile
export PATH=/usr/local/Nginx/sbin:$PATH #在末尾添加即可
重启配置 source /etc/profile
使用命令Nginx -V查看Nginx版本信息,能查到就表示安装成功
9.常用命令
Nginx 启动
Nginx -s stop 停止
Nginx -s reload 重启
安装PHP
cd /usr/local/ wget https://www.PHP.net/distributions/PHP-7.2.21.tar.gz tar -zxvf PHP-7.2.21.tar.gz 预编译:./configure --prefix=/usr/local/PHP/ --with-config-file-path=/usr/local/PHP/etc/ --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/ --with-mcrypt=/usr/local/libmcrypt/ --with-MysqLi=/usr/local/MysqL/bin/MysqL_config --enable-soap --enable-mbstring=all --enable-sockets --with-pdo-MysqL=/usr/local/MysqL --with-gd --without-pear
预编译完成后make && makeinstall
安装完成后:
cp PHP.ini-production /usr/local/PHP/etc/PHP.ini
cd /usr/local/PHP/etc
cp PHP-fpm.conf.default PHP-fpm.conf
cd PHP-fpm.d/
cp www.conf.default www.conf
将PHP的安装目录也加入到系统的环境变量 在最后一行加入
vim /etc/profile
export PATH=/usr/local/PHP/bin:$PATH
source /etc/profile 重新加载
PHP -v查看版本
安装MysqL5.7
原文地址:https://www.cnblogs.com/daemon-/p/9009360.html
1、下载tar包,这里使用wget从官网下载 wget https://dev.MysqL.com/get/Downloads/MysqL-5.7/MysqL-5.7.22-linux-glibc2.12-x86_64.tar.gz 2、将MysqL安装到/usr/local/MysqL下 # 解压 tar -xvf MysqL-5.7.22-linux-glibc2.12-x86_64.tar.gz # 移动 mv MysqL-5.7.22-linux-glibc2.12-x86_64 /usr/local/ # 重命名 mv /usr/local/MysqL-5.7.22-linux-glibc2.12-x86_64 /usr/local/MysqL 3、新建data目录 mkdir /usr/local/MysqL/data 4、新建MysqL用户、MysqL用户组 # MysqL用户组 groupadd MysqL # MysqL用户 useradd MysqL -g MysqL 5、将/usr/local/MysqL的所有者及所属组改为MysqL chown -R MysqL.MysqL /usr/local/MysqL 6、配置 /usr/local/MysqL/bin/MysqL_install_db --user=MysqL --basedir=/usr/local/MysqL/ --datadir=/usr/local/MysqL/data # 如果出现以下错误: 复制代码 2018-07-14 06:40:32 [WARNING] MysqL_install_db is deprecated. Please consider switching to MysqLd --initialize 2018-07-14 06:40:32 [ERROR] Child process: /usr/local/MysqL/bin/MysqLdterminated prematurely with errno= 32 2018-07-14 06:40:32 [ERROR] Failed to execute /usr/local/MysqL/bin/MysqLd --bootstrap --datadir=/usr/local/MysqL/data --lc-messages-dir=/usr/local/MysqL/share --lc-messages=en_US --basedir=/usr/local/MysqL -- server log begin -- -- server log end -- 复制代码 # 则使用以下命令: /usr/local/MysqL/bin/MysqLd --user=MysqL --basedir=/usr/local/MysqL/ --datadir=/usr/local/MysqL/data --initialize # 如果出现以下错误: /usr/local/MysqL/bin/MysqLd: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory # 则执行以下命令: yum -y install numactl # 完成后继续安装: /usr/local/MysqL/bin/MysqLd --user=MysqL --basedir=/usr/local/MysqL/ --datadir=/usr/local/MysqL/data --initialize # 编辑/etc/my.cnf 复制代码 [MysqLd] datadir=/usr/local/MysqL/data basedir=/usr/local/MysqL socket=/tmp/MysqL.sock user=MysqL port=3306 character-set-server=utf8 # 取消密码验证 skip-grant-tables # disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # skip-grant-tables [MysqLd_safe] log-error=/var/log/MysqLd.log pid-file=/var/run/MysqLd/MysqLd.pid 复制代码 7、开启服务 # 将MysqL加入服务 cp /usr/local/MysqL/support-files/MysqL.server /etc/init.d/MysqL # 开机自启 chkconfig MysqL on # 开启 service MysqL start 8、设置密码 # 登录(由于/etc/my.cnf中设置了取消密码验证,所以此处密码任意) /usr/local/MysqL/bin/MysqL -u root -p # 操作MysqL数据库 >>use MysqL; # 修改密码 >>update user set authentication_string=password('你的密码') where user='root'; >>flush privileges; >>exit; 9、将/etc/my.cnf中的skip-grant-tables删除 10、登录再次设置密码(不知道为啥如果不再次设置密码就操作不了数据库了) /usr/local/MysqL/bin/MysqL -u root -p >>ALTER USER 'root'@'localhost' IDENTIFIED BY '修改后的密码'; >>exit; 11、允许远程连接 /usr/local/MysqL/bin/MysqL -u root -p >>use MysqL; >>update user set host='%' where user = 'root'; >>flush privileges; >>eixt; 12、添加快捷方式 ln -s /usr/local/MysqL/bin/MysqL /usr/bin
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。