安装Apache
sudo apt-get install apache2
安装MySQL
sudo apt-get install mysql-server mysql-client
安装PHP
sudo apt-get install php7.0
其他模块
sudo apt-get install php7.0-fpm
sudo apt-get install libapache2-mod-php7.0
sudo apt-get install php7.0-mysql
sudo apt-get install php7.0-curl php7.0-xml php7.0-mcrypt php7.0-json php7.0-gd php7.0-mbstring
sudo apt-get install php-dev
重启服务
service apache2 restart
service mysql restart
修改权限
sudo chmod 777 /var/www
安装phpMyAdmin
sudo apt-get install phpmyadmin
安装:选择apache2,输入要配置数据库密码。
创建phpMyAdmin快捷方式:sudo ln -s /usr/share/phpmyadmin /var/www/html
浏览器访问:http://ubuntu地址/phpmyadmin
重写模块
sudo a2enmod rewrite //启用Apache mod_rewrite模块
mysql外部访问
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 127.0.0.1 //注释掉该行
接下来可以使用phpmyadmin来创建任意ip用户,也可以执行sql创建用户并赋予权限,如:
grant all on database.* to 'user'@'%' identified by 'password';
FLUSH PRIVILEGES;
database改成*就可以赋予所有数据库的权限了,不建议执行
安装swoole
sudo wget https://github.com/swoole/swoole-src/archive/v2.0.5.tar.gz
tar -xzf v2.0.5.tar.gz
打开该文件
cd swoole-src-2.0.5
sudo phpize
sudo ./configure
make && make install
找到php.ini加入 extension=swoole.so
php -m 查看有无成功
虚拟主机
apache
cd /etc/apache2/sites-available/
cp 000-default.conf xxx.conf
修改xxx.conf配置
ServerAlias url.com
ServerName www.url.com
DocumentRoot /var/www/laravel/public; #apache服务器的根目录指向Laravel的public文件夹下
然后
cd /etc/apache2/sites-enabled/
sudo ln -s ../sites-available/xxx.conf ./
nginx
sudo vim /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/laravel/public; #nginx服务器的根目录指向Laravel的public文件夹下
index index.php index.html index.htm; #将index.php排在最前面
server_name url.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
底部添加让其执行PHP文件
location ~ \.php$ { try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location / {
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
}
重启服务
service php7.0-fpm restart
service apache2 restart
service mysql restart
网友评论