1.準備linux環境php
這裏以CentOs爲例
下載CentOshttp://mirrors.aliyun.com/centos/
虛擬機或電腦安裝html
2.安裝apache2mysql
下載apache2源碼包http://httpd.apache.org/download.cgi
放到安裝好的服務器linux
安裝依賴sql
yum install gcc prec-devel apr-devel apr-util-devel
安裝apache2apache
tar -zxvf httpd-2.4.23.tar.gz cd httpd-2.4.23 ./configure --prefix=/usr/apache2 --enable-so --enable-modules=all --enable-mods-shared=all make && make install
安裝好後測試是否安裝成功
啓動apache服務器segmentfault
/usr/apache2/bin/httpd
在瀏覽器輸入ip地址
頁面出現It Works!安裝成功centos
配置apache 解析phpapi
編輯/usr/apache2/conf/httpd.conf文件
添加AddType application/x-httpd-php .php
在DirectoryIndex index.html後加上 index.php
加上 ServerName localhost:80 否則啓動apache會報AH00558錯誤瀏覽器
3.安裝mysql
這裏用Mariadb
mariadb就很少介紹了,其實它就是mysql
這裏有我寫好的文章CentOS下編譯安裝mariadb
4.安裝php7
下載php7 http://php.net/downloads.php
放到安裝好的服務器
安裝依賴
yum install libmcrypt-devel libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel
安裝php7
tar -zxvf php-7.1.0.tar.gz cd php-7.1.0 ./configure --prefix=/usr/php7 --with-apxs2=/usr/apache2/bin/apxs --enable-mbstring --with-curl --with-gd --enable-fpm --enable-mysqlnd --with-config-file-path=/usr/php7/etc --with-pdo-mysql=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --with-openssl --with-zlib --with-iconv --with-mysqli --with-freetype-dir=/usr/include/freetype2/freetype/ make && make install
安裝完以後配置php
cp php.ini-production /usr/php7/etc/php.ini cp /usr/php7/etc/php-fpm.conf.default /usr/php7/etc/php-fpm.conf cp /usr/php7/etc/php-fpm.d/www.conf.default /usr/php7/etc/php-fpm.d/www.conf cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm chmod +x /etc/init.d/php7-fpm
測試apache+php
在/usr/apache2/htdocs下新建index.php
添加內容
<?phpphpinfo();?>
在瀏覽器輸入 ip地址/index.php