我是centos / laravel配置的初学者,所以请光临我。 我工作的所有laravel项目都是由其他人开始安装/配置的。 很久以前,我设法使用WAMP在Windows机器上安装了一个Laravel项目,据我记忆,它更容易。 最近我安装了Centos 7,从digitalocean.com获得了一个干净的液滴。 我认为Droplet就像VPS。 你有一个IP和SSH访问在一些headacke之后我设法使用composer成功安装了laravel。 我也安装了mysql和apache(httpd)现在我有了
在/ var / WWW / laravel
文件夹,安装最新的Laravel(5.3)
我进去/ var / www /并打电话
作曲家创作项目laravel / laravel mypro
现在,我有一个新应用程序的laravel app scheleton
在/ var / WWW / mypro
我想从浏览器访问它,所以我可以开始工作,但我不知道我需要做什么。 关于如何做到这一点有很多教程,但它们对我来说非常困惑。
接下来我必须做什么才能看到我正在做的工作的结果? 如果,在浏览器中,我现在通过IP访问Droplet,比如
http://xxx.xxx.xxx.xxx
我明白了
未找到在此服务器上找不到请求的URL /。
如果我向URL添加我的应用程序的名称,则相同
http://xxx.xxx.xxx.xxx/mypro
我相信我必须配置httpd? 或者可能将项目的文件夹移动到其他地方?
我尝试在/ var / www / html文件夹中移动我的项目文件夹,所以
在/ var / www / html等/ mypro
现在,当我尝试访问该URL时,我收到一个空页面(浏览器页面的视图源也返回一个空页面)我甚至尝试过
http://xxx.xxx.xxx.xxx/mypro/server.php
因为我的项目文件夹的根目录中有一个server.php文件...相同的结果
我甚至在名为mypro.conf的/etc/httpd/conf.d/文件夹中添加了一个conf,其中我添加了这些行:
<VirtualHost *:80> ServerName mypro DocumentRoot "/var/www/html/mypro/public" <Directory /var/www/html/mypro/public> AllowOverride all </Directory> </VirtualHost>没有什么新的事情发生我每次改变的东西“服务httpd重启”。
我甚至试过了
php artisan serve --host xxx.xxx.xxx.xxx --port 8000
并尝试了网址http://xxx.xxx.xxx.xxx:8000
现在我从浏览器中收到“无法连接”页面,所以我停止了“服务”
为了能够最终开始工作,我必须做什么......?
谢谢
All the laravel projects I worked on were installed/configured started by other people. A long time ago I managed to install a Laravel project on a Windows machine using WAMP and it was easier as far as I remember. I recently received access to a clean droplet from digitalocean.com with Centos 7 installed. I think a droplet is something like a VPS. You have an IP, and SSH access After some headache I managed to successfully install laravel using composer. I have also installed mysql and apache(httpd) Now I have
/var/www/laravel
folder, with the installation of the latest Laravel (5.3)
I went inside /var/www/ and called
composer create-project laravel/laravel mypro
Now, I have a laravel app scheleton of a new application at
/var/www/mypro
I would like to access it from a browser so I can start working on it, but I do not know what I need to do. There are many tutorials on how to do that but they are very confusing for me.
What must I do next in order to be able to see the results of what I am working on? If , in the browser, I access now the droplet by IP, like
http://xxx.xxx.xxx.xxx
I get
Not Found The requested URL / was not found on this server.
Same if I add to the URL the name of my app like
http://xxx.xxx.xxx.xxx/mypro
I believe I must configure the httpd ? Or maybe move the project's folder somewhere else?
I tried moving my project folder inside /var/www/html folder, so
/var/www/html/mypro
and now when I try to access the url I receive an empty page (view-source of the browser page returns also an empty page) I even tried
http://xxx.xxx.xxx.xxx/mypro/server.php
since there is a server.php file in the root of my project folder... same result
I even added a conf to the /etc/httpd/conf.d/ folder called mypro.conf where I added these lines:
<VirtualHost *:80> ServerName mypro DocumentRoot "/var/www/html/mypro/public" <Directory /var/www/html/mypro/public> AllowOverride all </Directory> </VirtualHost>Nothing new happens I did "service httpd restart" everytime a changed something.
I even tried
php artisan serve --host xxx.xxx.xxx.xxx --port 8000
and tried the url http://xxx.xxx.xxx.xxx:8000
Now I get "Unable to connect" page from the browser so I stopped the "serve"
What is it that I have to do in order to be able to finally start working?
最满意答案
以下是我在Ubutnu 16.04上的表现方式(可以在Centos上进行一些更改)。
更新您的包回购。
sudo apt update更新包装。
sudo apt dist-upgrade安装PHP
apt install php安装apache2
apt install apache2安装PHP插件
apt install php-mbstring php-pdo php-tokenizer php-xml php-mcrypt php-gd libapache2-mod-php php-curl php-mysql启用mcrypt
phpenmod mcrypt a2enmod rewrite重启Apache Server
service apache2 restart安装Composer
curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer安装Git
apt install git安装mysql-server
apt install mysql-server安装Phpmyadmin(可选)
apt install phpmyadmin安装zip并解压缩
apt install zip unzip现在为您的网站创建apache虚拟主机配置。
cd /etc/apache2/sites-available touch pqr.xyz.com.conf基本内容是pqr.xyz.com.conf
#content of pqr.xyz.com.conf <VirtualHost *:80> ServerName pqr.xyz.com ServerAdmin webmaster@xyz.com DocumentRoot /var/www/html/pqr.xyz.com/public <Directory /var/www/html/pqr.xyz.com> AllowOverride All </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>现在转到/ var / www / html
cd /var/www/html/使用您的网站名称创建一个目录
mkdir pqr.xyz.com现在添加一个用户,因为在创建laravel项目时以root身份使用composer并不是一个好主意。
adduser admin --ingroup admin现在将admin设为此目录的所有者
chown -R admin pqr.xyz.com现在以admin身份登录
转到/ var / www / html
cd /var/www/html使用composer安装Laravel
composer create-project laravel/laravel pqr.xyz.com cd /var/www/html/pqr.xyz.com现在你的存储和引导程序目录应该具有apache 2服务器的写权限,所以make apache是这两个目录的所有者。
chown -R www-data storage chown -R www-data bootstrap现在以root身份登录
激活pqr.xyz.com.conf
a2dissite 000-default.conf service apache2 reload a2ensite shopperstock.eveningx.com.conf service apache2 reload service apache2 restart它可能不是与任何larave项目合作的最佳方式,因此请随意评论或建议编辑。
Following is way how i do it on Ubutnu 16.04 (It can be done with some changes on Centos).
Update your package repo.
sudo apt updateUpdate packeges.
sudo apt dist-upgradeInstall PHP
apt install phpInstall apache2
apt install apache2Install PHP Plugins
apt install php-mbstring php-pdo php-tokenizer php-xml php-mcrypt php-gd libapache2-mod-php php-curl php-mysqlEnable mcrypt
phpenmod mcrypt a2enmod rewriteRestart Apache Server
service apache2 restartInstall Composer
curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composerInstall Git
apt install gitInstall mysql-server
apt install mysql-serverInstall Phpmyadmin (Optional)
apt install phpmyadminInstall zip & unzip
apt install zip unzipNow create apache virtual host configuration for your website.
cd /etc/apache2/sites-available touch pqr.xyz.com.confThe basic content of is pqr.xyz.com.conf
#content of pqr.xyz.com.conf <VirtualHost *:80> ServerName pqr.xyz.com ServerAdmin webmaster@xyz.com DocumentRoot /var/www/html/pqr.xyz.com/public <Directory /var/www/html/pqr.xyz.com> AllowOverride All </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>Now goto /var/www/html
cd /var/www/html/Create a directory with your website name
mkdir pqr.xyz.comNow add a user because it is not good idea to work with composer as root while creating laravel project.
adduser admin --ingroup adminNow make admin as owner of this directory
chown -R admin pqr.xyz.comNow login as admin
go to /var/www/html
cd /var/www/htmlInstall Laravel using composer
composer create-project laravel/laravel pqr.xyz.com cd /var/www/html/pqr.xyz.comNow your storage and bootstrap directory should have write permission for apache 2 server so make apache owner of these two directories.
chown -R www-data storage chown -R www-data bootstrapNow login as root
Activate pqr.xyz.com.conf
a2dissite 000-default.conf service apache2 reload a2ensite shopperstock.eveningx.com.conf service apache2 reload service apache2 restartIt may not be the best way to work with any larave project , So feel free to comment or suggest an edit.
更多推荐
发布评论