centos7.2 系统默认开启了防火墙,需关闭外部才能访问到 80 端口
- systemctl status firewalld.service # 查看防火墙服务状态
- systemctl stop firewalld.service # 关闭防火墙
- systemctl disable firewalld.service # 关闭防火墙开机自启动
- yum install epel - release
- yum install - y gcc gcc - c++autoconf libtool
- cd /usr/local/src
- wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-1.5.0.tar.gz
- tar zxvf apr-1.5.0.tar.gz
- cd apr-1.5.0
- ./configure --prefix=/usr/local/apr
- make && make install
- cd /usr/local/src/
- wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-util-1.5.3.tar.gz
- tar zxvf apr-util-1.5.3.tar.gz
- cd apr-util-1.5.3
- ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
- make && make install
- cd /usr/local/src/
- wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/pcre/pcre-8.38.tar.gz
- tar zxvf pcre-8.38.tar.gz
- cd pcre-8.38
- ./configure --prefix=/usr/local/pcre
- make && make install
- cd /usr/local/src/
- wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/apache/httpd-2.4.23.tar.gz
- tar zxvf httpd-2.4.23.tar.gz
- cd httpd-2.4.23
- ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-cgi --enable-rewrite --with-zlib --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-mods-shared=most --enable-mpms-shared=all --with-mpm=event
- make && make install
修改 / etc/httpd/httpd.conf 文件
- 将Require all denied改为Require all granted
- # 在文件末尾添加
- PidFile "/var/run/httpd.pid"
启动 apache 服务
- /usr/local / apache / bin / apachectl start
访问 IP 地址
设置 apache 开机自启动
- vim /etc/rc.d/rc.local
- # 文件尾部添加如下一行指令
- /usr/local/apache/bin/apachectl start
设置环境变量
- vim /root/.bash_profile
- # 在已有PATH的尾部追加apache bin目录
- PATH=$PATH:$HOME/bin:/usr/local/apache/bin
- rpm -qa | grep mysql
- rpm -qa | grep mariadb
若系统存在任何一个,则需要先进行删除再进行编译安装
- yum install -y libaio-*#安装依赖
- mkdir -p /usr/local/mysql
- cd /usr/local/src
- wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/mysql/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
- tar -xzvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
- mv mysql-5.7.17-linux-glibc2.5-x86_64/* /usr/local/mysql/
- groupadd mysql
- useradd -g mysql -s /sbin/nologin mysql
- /usr/local / mysql / bin / mysqld--initialize - insecure--datadir = /usr/local / mysql / data / --user = mysql
- chown - R mysql: mysql / usr / local / mysql
- cd /usr/local/mysql/support-files/
- cp mysql.server /etc/init.d/mysqld
- chmod +x /etc/init.d/mysqld
添加 / etc/init.d/mysqld start 到 / etc/rc.d/rc.local 中
启动并登录数据库
- /etc/init.d/mysqld start
- mysql -uroot -p # 默认密码为空
更改 mysql 密码
- mysqladmin - uroot password '******'
- yum install - y php - mcrypt libmcrypt libmcrypt - devel libxml2 - devel openssl - devel libcurl - devel libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg - devel.x86_64 libpng - devel.x86_64 freetype - devel.x86_64 libjpeg - turbo - devel libmcrypt - devel mysql - devel
- cd /usr/local/src
- wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/php/php-5.4.45.tar.gz
- tar zxvf php-5.4.45.tar.gz
- cd php-5.4.45
- ./configure --prefix=/usr/local/php --with-mysql=mysqlnd --with-openssl --with-mysqli=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-maintainer-zts --disable-fileinfo
- make && make install
- cp / usr / local / src / php - 5.4.45 / php.ini - product / etc / php.ini
- vim /etc/httpd/httpd.conf
- # 末尾增加如下两行
- AddType application/x-httpd-php .php
- AddType application/x-httpd-php-source .phps
并修改 DirectoryIndex index.html 为 DirectoryIndex index.php index.html
- /usr/local / apache / bin / apachectl restart
- vim /usr/local/apache/htdocs/phpinfo.php
- php
- phpinfo();
显示可以正常解析
来源: http://www.bubuko.com/infodetail-2452729.html