- 安裝 apache
yum -y install httpd apr apr-util httpd-manual mod_ssl mod_perl mod_auth_mysql httpd-devel
- 啓動 apache
systemctl start httpd.service
或
service httpd start
- apache 多端口監聽
- 編輯 apache 配置文件
vi /etc/httpd/conf/httpd.conf
- 找到 Listen 80,在其下方增加 Listen 8080
- 保存退出
- 重啓 apache
systemctl restart httpd.service
或service httpd restart
- 編輯 apache 配置文件
設置站點虛擬目錄和多站點配置
在
/etc/httpd/conf/httpd.conf
文檔下可能會看到以下命令IncludeOptional conf.d/*.conf
這段話的意思是 在 /etc/httpd/conf.d/ 目錄下所有後綴爲 .conf 的文件都會被包含進來。so 我們只需要在 /etc/httpd/conf.d/ 目錄下添加我們的多個 .conf 文件就可以了vi /etc/httpd/conf.d/test1.conf
NameVirtualHost *:80 #綁定端口,一定要設置 <VirtualHost *:80> ServerAdmin test@test.com #出現問題後發送的郵件地址 ServerName test1.cn #域名 DocumentRoot "/var/www/test1" #站點根目錄 ServerAlias www.test1.cn blog.test1.cn #單站點多域名配置 </VirtualHost>
也可以在
/etc/httpd/conf.d/test1.conf
文件中添加其他站點(單端口多域名設置)<VirtualHost ServerName *:80> ServerAdmin [email protected] DocumentRoot /var/www/test2 ServerName blog.test.com </VirtualHost>
重啓 apache 服務器
systemctl restart httpd.service
或
service httpd restart
安裝 libmcrypt 擴展
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
tar -zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make && make install
echo "/usr/local/lib" >> /etc/ld.so.conf
# 將擴展添加到 centos 環境變量 (ld) 中ldconfig
編譯安裝 php7 下載地址
wget http://124.202.164.13/files/425300000A4693F4/cn2.php.net/distributions/php-7.1.6.tar.gz
tar -zxvf php-7.1.6.tar.gz
編譯安裝
./configure --prefix=/etc/php7 --with-apxs2=/usr/bin/apxs #apxs 地址,請使用 whereis apxs 查找(使用時,請刪除這段) --exec-prefix=/etc/php7 --bindir=/etc/php7/bin --sbindir=/etc/php7/sbin --includedir=/etc/php7/include --libdir=/etc/php7/lib/php --mandir=/etc/php7/php/man --with-config-file-path=/etc/php7/etc --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mcrypt=/usr/local/libmcrypt --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --with-opcache --with-redis --enable-fpm --enable-fastcgi --with-fpm-user=www --with-fpm-group=www --without-gdbm --disable-fileinfo
cd /etc/php7/bin/
cp phar.phar /usr/bin/phar.phar
cp php /usr/bin/php
cp php-cgi /usr/bin/php-cgi
cp php-config /usr/bin/php-config
cp phpize /usr/bin/phpize
cp /etc/php7/sbin/php-fpm /usr/bin/php-fpm
cd /etc/php7/etc/
cp php-fpm.conf.default php-fpm.conf
cp cp php-fpm.d/www.conf.default php-fpm.d/www.conf
- 進入 php7 源碼目錄
cp php.ini-development /etc/php7/etc/php.ini
groupadd www && useradd www -g www
配置 apache 運行 php 文件
vi /etc/httpd/conf/httpd.conf
- 找到 AddType 關鍵字 增加
AddType application/x-httpd-php .php .phtml
- 找到 LoadModule 關鍵字 增加
LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so
- 保存退出並重啓 httpd
service httpd restart
[centos] apache、php配置
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.