安裝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
重啟服務(wù)
service apache2 restart
service mysql restart
修改權(quán)限
sudo chmod 777 /var/www
安裝phpMyAdmin
sudo apt-get install phpmyadmin
安裝:選擇apache2,輸入要配置數(shù)據(jù)庫密碼涩禀。
創(chuàng)建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來創(chuàng)建任意ip用戶,也可以執(zhí)行sql創(chuàng)建用戶并賦予權(quán)限,如:
grant all on database.* to 'user'@'%' identified by 'password';
FLUSH PRIVILEGES;
database改成*就可以賦予所有數(shù)據(jù)庫的權(quán)限了,不建議執(zhí)行
安裝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 查看有無成功
虛擬主機(jī)
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服務(wù)器的根目錄指向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服務(wù)器的根目錄指向Laravel的public文件夾下
index index.php index.html index.htm; #將index.php排在最前面
server_name url.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
底部添加讓其執(zhí)行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;
}
}
重啟服務(wù)
service php7.0-fpm restart
service apache2 restart
service mysql restart