一键安装 Apache2.4 php7 mariadb

资源下载(资源不要分):https://download.csdn.net/download/wanghaisheng/15849774

通常在安装一个WEB运行环境时太过于麻烦,要整理脚本安装,要不就是原码编译安装,而后还要进行大量的配置,耗时又浪费大量的精力,所以自己就想把其整理后记录了方便大家来使用。

         安装步骤:

  1. 环境要求centos7,因为里面有防火的特殊脚本所以只适应7.0以上。如果是其它的系统版请自行修改脚本。其次要配置好网络,因为要用到YUM安装,所以网络不通肯定不行。 还有一点是如果你和我一样怕出问题,又是LINUX菜鸟,请使用Centos7.0-mini 版,免的有冲突。
  2. 将下载的资源放到LINUX系统中进行解压。
  3. 进入解压目录apm-install,执行脚本,在命令行中输入 sh apache_php7_mariadb.sh
  4. 等待执行过程。如果有提示是否安装的,就键入 y  .  当安装完数据库时就会提示进行数据库配置,所以就请参考下面进行:


NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current

password for the root user. If you've just installed MySQL, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none):<–初次运行直接回车

OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation.

Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车

New password: <– 设置root用户的密码   为了后面和WEB更好的对接,此处密码可以使用 1980root

Re-enter new password: <– 再输入一次你设置的密码

Password updated successfully!

Reloading privilege tables..

… Success!

By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account created for

them. This is intended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] <– 是否删除匿名用户,生产环境建议删除,所以直接回车

… Success!

Normally, root should only be allowed to connect from 'localhost'. This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] <–是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止

… Success!

By default, MySQL comes with a database named 'test' that anyone can

access. This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] <– 是否删除test数据库,直接回车

- Dropping test database…

… Success!

- Removing privileges on test database…

… Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] <– 是否重新加载权限表,直接回车

… Success!

Cleaning up…

All done! If you've completed all of the above steps, your MySQL

installation should now be secure.

Thanks for using MySQL!


      5.  安装完成,执行命令 netstat -lntp|more  , 如果看见80 3306等端口都起来了,说明安装成功了。

          如果命令找不到请先安装 net-tool工具(工具下载).为了进一步确认请在浏览器中输入 http://ip/info.php  看一下是不是有显示。

          如果你只是看到 了

             说明PHP安装有问题,为什么会是这样呢? 因为这是网络安装,有可能网络不好没有装上,你可以再次执行脚本。 如果有没有成功的就会再次被安装, 如果是已经被安装的会被自动忽略。到数据库设置的地方时直接 Ctrl + c终止就可以了

             成功后会显示下面的信息:

注意点:

  1. 如果你在安装前就想修改 php的配置,那么可以修改你安装前目录下的PHP.INI文件,这个文件就是安装的配置文件。如果你已经安装完成请修改 /etc/php.ini 文件,完成进行重启, 命令行执行:

systemctl restart httpd   

     2. 只所以要求是CentOS7.0,是因为防火墙命令在7.0之下不能使用,你可将脚本中的如下命令暂时注释掉:

firewall-cmd --permanent --zone=public --add-port=8080-8081/tcp
firewall-cmd --permanent --zone=public --add-port=80-80/tcp
firewall-cmd --permanent --zone=public --add-port=3306-3306/tcp
firewall-cmd --permanent --zone=public --add-port=7272-7272/tcp
firewall-cmd --permanent --zone=public --add-port=6379-6379/tcp
firewall-cmd --permanent --zone=public --add-port=89-89/tcp
firewall-cmd --permanent --zone=public --add-port=1935-1935/tcp

firewall-cmd --reload

在安装完成后再去进行修改防火墙。此处我开的端口比较多,主要原因是我后面还要装其它的服务,所以干脆一起开了。

     3.  安装及重要目录

          var/www/html/        web页面脚本目录

          /var/lib/mysql/        数据库的数据目录

         /var/lib/php/             php相关缓存目录,如session文件的缓存

猜你喜欢

转载自blog.csdn.net/wanghaisheng/article/details/114884965