一、准备工作
1、为保证流畅安装,先切换至root权限:
su root
2、更新软件列表
apt-get update
二、安装Apache
1、安装
apt-get install apache2
2、开启URL重写
a2enmod rewrite
或
ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
然后修改apachep配置文件
vim /etc/apache2/apache2.conf
修改你代码文件所在的目录(默认/var/www)的配置项
Options Indexes FollowSymLinks
AllowOverride All #将None修改为All
Require all granted
3、配置虚拟主机
vim /etc/apache2/sites-available/000-default.conf
ServerAdmin localhost
DocumentRoot /var/www/YourProgram #项目所在目录
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
重启Apache
service apache2 restart
浏览器输入localhost
将会出现Apache页面
三、安装PHP
1、安装
apt-get install php7.0
2、安装Apache-PHP的扩展模块
apt-get install libapache2-mod-php7.0
3、安装PHP常用扩展
apt-get install -y php-dev php7.0-mysql php7.0-curl php7.0-mcrypt php7.0-gd php-redis php7.0-cli php7.0-fpm php7.0-gd php7.0-json php7.0-mysql php7.0-readline php7.0-xml php7.0-mbstring php7.0-common
安装 openssl扩展
apt-get install -y autoconf g++ make openssl libssl-dev libcurl4-openssl-dev
安装pear扩展(pecl命令:以pecl方式在线编译安装PHP其他扩展)
apt-get install php-pear
安装swoole扩展
##方法一:方式用pecl命令
pecl install swoole
##方法二:github下载,编译安装
wgat https://github.com/swoole/swoole-src/archive/v2.0.5.tar.gz
cd swoole
phpize
./configure
make && make install
##安装完成以后在php.ini中将扩展开启
extension=swoole.so
4、php7.0常用扩展列表
php7.0 php7.0-fpm php7.0-mysql php7.0-sqlite3
php7.0-bcmath php7.0-gd php7.0-odbc php7.0-sybase
php7.0-bz2 php7.0-gmp php7.0-opcache php7.0-tidy
php7.0-cgi php7.0-imap php7.0-pgsql php7.0-xml
php7.0-cli php7.0-interbase php7.0-phpdbg php7.0-xmlrpc
php7.0-common php7.0-intl php7.0-pspell php7.0-xsl
php7.0-curl php7.0-json php7.0-readline php7.0-zip
php7.0-dba php7.0-ldap php7.0-recode
php7.0-dev php7.0-mbstring php7.0-snmp
php7.1
php7.1 php7.1-fpm php7.1-mysql php7.1-sqlite3 php7.1-bcmath php7.1-gd php7.1-odbc php7.1-sybase php7.1-bz2 php7.1-gmp php7.1-opcache php7.1-tidy php7.1-cgi php7.1-imap php7.1-pgsql php7.1-xml php7.1-cli php7.1-interbase php7.1-phpdbg php7.1-xmlrpc php7.1-common php7.1-intl php7.1-pspell php7.1-xsl php7.1-curl php7.1-json php7.1-readline php7.1-zip php7.1-dba php7.1-ldap php7.1-recode php7.1-dev php7.1-mbstring php7.1-snmp
四、安装MySQL
1、安装,过程中要输入密码
apt-get install mysql-server mysql-client
2、远程登录授权(以root用户为例)
进入MySQL客户端 mysql -uroot -p
grant all privileges on *.* to root@'%' identified by 'yourpasswd' with grant option;
刷新权限或重启MySQL
flush privileges
修改 vim /etc/mysql/mysql.conf.d/mysqld.cnf
# bind-address = 127.0.0.1 ##将这一行注释掉
重启MySQL
service mysql restart
必要时关闭防火墙
iptables -F
五、安装Redis
1、安装
apt-get install redis-server
2、安装php-redis扩展
apt-get install php-redis